Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **The Pulls screen is redrawn, and its list is sorted by what each pull request needs.** Open ones are grouped into Ready to merge, Needs work, In review and Drafts, in place of the All, Ready, Drafts and Failing filters and the Approved state. Inside a pull request, its facts stand beside the description, and Copy link and Copy Markdown are in the `⋯` menu.
- **The Git panel shows one thing at a time.** Changes and History are now two tabs, and a commit opens beside the log when you click it. The branches open from the branch's name in the panel's header: click one to check it out, type a new name to create it, and find the rest in its `⋯`.
- **A finished turn in the chat is your message, the answer and the files it changed.** The calls, thoughts and texts on the way fold under one line with the time they took, like Worked for 4m 6s; click it to read them in order. Each changed file is listed once under the answer, and a click opens all its edits.
- **A permission the agent asks for in the chat now waits over the message box.** It says what the agent wants to do and shows the whole command, or each file with its diff, with the answers always in view. Once you answer, only the call is left in the conversation, or a Denied line.
- **Review threads in Pulls show who answers whom.** Each thread is a card with its file and code, and its replies hang from a line under the comment they answer, in Conversation and between the lines in Files.
- **Long conversations no longer slow the window down.** Scrolling, typing and watching an answer come in cost about the
same in a chat of thousands of messages as in a new one, and several agents working at once take about a third of the
Expand Down
5 changes: 5 additions & 0 deletions docs/ceilings.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,11 @@ work when nobody knows it and that the call site never shows. The mechanism and
one-time allow and every digit answers. Crush has no chat. On every provider Enter answers nothing and an
"always" option is never the suggestion; a digit typed on an empty composer the instant the box comes still
answers, since nothing holds the keys for a moment after it shows.
- **A chat permission finds its call by name and target, not by id** (`native/cmd/lich-native/chat_rows.go`,
`asksAbout`). A permission item carries a copy of the call and no id of it, so the window hides the call while it
waits, and once denied, by the nearest one before it in the turn with the same name and title that did not go
well. A provider whose ask words the call otherwise than the call itself shows both: the call's line, and the box
or its Denied line. It never hides a call that went well.
- **A chat turn's count of changes is a difference of two numstat readings, not a record of what the agent did**
(`internal/chat/changes.go`, `internal/project/lines.go`): lich reads `git diff --numstat HEAD` and the untracked
files before the message goes out and again when the turn ends, and counts the files whose numbers differ. It
Expand Down
22 changes: 15 additions & 7 deletions native/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ never makes the Latest pill show.
message to the last thing the turn did, "Worked" where nobody reported times or under a second. In a long turn
the texts on the way ("now the tests") weighed as much as the conclusion, which had to be hunted for. The
answer is the last run of the agent's texts; what folds is every other text, thought, run of calls, failed
edit and answered permission. Never folded: a message or a steer, an answer to a question, a plan, a `!`
edit and denied permission. Never folded: a message or a steer, an answer to a question, a plan, a `!`
command, a compaction and a notice; what stands between two of the first five is a stretch with its own line
and answer. A turn with nothing to fold has no line, unless it was stopped, "Stopped after 41s", or failed,
"Failed after 12s" in `Destructive`, which say so with nothing under them too. There is no closing line and no
Expand Down Expand Up @@ -616,17 +616,25 @@ never makes the Latest pill show.
from the background in 150ms ease-out, from the first frame that draws it; the one that leaves goes at once.
The chevrons, the option highlight, the Send and Stop swap, the composer's height, a tool's state, the copy
check and the footer's changes stay dry.
- **A permission** is a box on `Sidebar`, `RadiusMD`, `Space(3)` padding (see Boxes inside a screen): the tool,
its diff, and a `SizeSM` button per answer the provider offers, on one line at the right in the provider's
order (1, 2, 3), each with its digit's key cap leading it (`ButtonStyle.Keys`); the first one-time reject also
wears Esc's cap after its text (`ButtonStyle.AlsoKeys`, `chat_permit.go`). **Enter never answers it**, on the box or on an empty composer under it: an Enter meant
- **A permission** (`chat_permit.go`, `chat_permit_draw.go`) waits over the composer, where a question does and
for its reason: a box on `Sidebar`, `RadiusLG`, `Space(2)` over the composer, coming in as the question does, its
text starting where the conversation's and the composer's do (`chatComposerPadX`). Its head is a `ToneWait` dot
and who asks for what, "Claude Code asks to run a command", "to edit a file", "to use WebFetch", muted `TextXS`.
Under it is what is being approved, whole, never its first line: the command or target in mono `TextSM`, or an
edit's line over its diff per file (see An edit), with no chevron and no "Show more". Past `chatPermitShare` (0.4)
of the pane it scrolls, the bar in the box's padding, so the answers never leave the window. They are a `SizeSM`
button per answer the provider offers, on one line at the right in the provider's
order (1, 2, 3), each with its digit's key cap (`ButtonStyle.Keys`); the first one-time reject also
wears Esc's cap after its text (`ButtonStyle.AlsoKeys`). **Enter never answers it**, on the box or on an empty composer under it: an Enter meant
for a message could land as the box comes. Digits 1..9 answer the nth option and Esc takes the first one-time
reject (nothing when there is none). The filled button is the suggestion, wherever it falls in the provider's
order: the first one-time allow, never an "always"; on an ask the provider marks default-no (Claude Code's `default_to_no`) it is the first one-time
reject, no digit answers and the buttons carry no key caps, as Claude Code's own prompt takes none
reject, no digit answers and the buttons carry no digit, as Claude Code's own prompt takes none
(`docs/ceilings.md`). The keys go where the question card's do: to the box when it comes on an empty
composer, to the composer while a message is being typed, and back to the composer on a click in it.
Answered, it shrinks to a muted line naming the answer.
Several waiting are answered in the order they came, so a new one never lands under the pointer; a question goes
before them. The call it is about stays out of the conversation while it waits. Allowed, the call's own line is
all that tells it; denied, a call's line with a muted `ban` glyph and "Denied" stands in the call's place.
- **An edit** (`chat_edit.go`), a call that changed a file, is a line of its own out of the turn's fold, and so
is each file a call with no diff of its own changed (a shell command's `sed`, a script), right after that
call (`ChatToolCall.Files`, `fileRows`). Edit lines that follow one another with nothing between them are one
Expand Down
83 changes: 1 addition & 82 deletions native/cmd/lich-native/chat_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"image"
"image/color"
"path"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -102,7 +101,7 @@ func (u *window) chatRow(gtx C, th *ui.Theme, p *chatPane, sv sessionView, r cha
if it.Permission == nil {
return D{}
}
return chatPermission(gtx, th, p, it)
return chatDenied(gtx, th, &it.Permission.Tool, sv.path)
case api.ItemQuestion:
if it.Question == nil {
return D{}
Expand Down Expand Up @@ -704,86 +703,6 @@ func splitDiff(diff string) (name string, added, deleted int, body []string) {
return name, added, deleted, body
}

// permitLabel is the provider's words for a permission's answer, or, for one
// it sends by kind alone (Claude Code, Codex), lich's.
func permitLabel(o api.ChatPermitOption) string {
if o.Label != "" {
return o.Label
}
switch o.Kind {
case api.PermitAllowOnce:
return i18n.T("chat.permit.allowOnce")
case api.PermitAllowAlways:
return i18n.T("chat.permit.allowAlways")
case api.PermitRejectOnce:
return i18n.T("chat.permit.rejectOnce")
}
return o.ID
}

// chatPermission is the agent asking before a tool runs: a box with the
// tool, its diff and a button per answer the provider offers at the row's
// right, in the provider's order, each with the digit that takes it, the
// suggested one filled, and Esc in the one-time reject it takes. Answered, it
// is a muted line with the answer.
func chatPermission(gtx C, th *ui.Theme, p *chatPane, it backend.ChatItem) D {
perm := it.Permission
tool := strings.TrimSpace(perm.Tool.Name + " " + cleanLine(perm.Tool.Title))
if perm.Chosen != "" {
choice := perm.Chosen
for _, o := range perm.Options {
if o.ID == perm.Chosen {
choice = permitLabel(o)
}
}
return th.Text(ui.TextXS, i18n.T("chat.view.answered", i18n.Args{"tool": tool, "choice": choice})).Muted().Layout(gtx)
}
box := th.On(th.Sidebar)
primary := permitSuggested(perm)
reject := permitOption(perm, api.PermitRejectOnce)
buttons := []layout.FlexChild{layout.Flexed(1, func(gtx C) D { return D{Size: gtx.Constraints.Min} })}
for i, o := range perm.Options {
if i > 0 {
buttons = append(buttons, ui.Gap(1.5))
}
b := box.Button(p.answer(it.ID, o.ID), permitLabel(o))
if o.ID == reject {
b.AlsoKeys = "Esc"
}
b.Size, b.Variant = ui.SizeSM, ui.VariantOutline
if i < permitDigits(perm) {
b.Keys = strconv.Itoa(i + 1)
}
if o.ID == primary {
b.Variant = ui.VariantDefault
}
buttons = append(buttons, layout.Rigid(b.Layout))
}
return layout.Background{}.Layout(gtx,
func(gtx C) D { return ui.Fill(gtx, th.Sidebar, ui.RadiusMD) },
func(gtx C) D {
return layout.UniformInset(ui.Space(3)).Layout(gtx, func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return layout.Flex{Alignment: layout.Baseline}.Layout(gtx,
layout.Rigid(box.Text(ui.TextSM, perm.Tool.Name).Weight(font.Medium).Layout),
ui.Gap(2),
layout.Flexed(1, box.Text(ui.TextXS, cleanLine(perm.Tool.Title)).Mono().Muted().Layout),
)
}),
layout.Rigid(func(gtx C) D {
if perm.Tool.Diff == "" {
return D{}
}
return layout.Inset{Top: ui.Space(2)}.Layout(gtx, func(gtx C) D { return chatDiff(gtx, box, perm.Tool.Diff) })
}),
ui.VGap(2.5),
layout.Rigid(func(gtx C) D { return layout.Flex{Alignment: layout.Middle}.Layout(gtx, buttons...) }),
)
})
})
}

// chatVerbSep splits the catalog's list of verbs, which each language writes
// at its own length.
const chatVerbSep = "|"
Expand Down
6 changes: 3 additions & 3 deletions native/cmd/lich-native/chat_motion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ func TestAChatRowEntersByHeightAndOpacityWithoutScale(t *testing.T) {

// The live line leaving for a permission plays the entry backwards: it keeps
// its place and size, its row shrinking and its verb dimming. The live line
// keeps its slot over the permission while it goes, so the permission's
// distance from the message above is the live row's height.
// keeps its slot under the message while it goes, so the distance from the
// message to the permission's box, over the composer, is the live row's height.
func TestAChatRowLeavesByHeightAndOpacityWithoutScale(t *testing.T) {
items := []backend.ChatItem{{ID: "u1", Kind: api.ItemUser, Turn: 1, At: novDay(18, 17, 59), Text: "go"}}
u, r := lifeFrames(t, items, true)
Expand All @@ -122,7 +122,7 @@ func TestAChatRowLeavesByHeightAndOpacityWithoutScale(t *testing.T) {
Options: []api.ChatPermitOption{{ID: "yes", Label: "Allow", Kind: api.PermitAllowOnce}},
}}})
r.frame()
gap := func() int { return labelTop(t, r, "Edit") - labelTop(t, r, "go") }
gap := func() int { return int(r.at(t, "claude asks to edit a file").Y - r.at(t, "go").Y) }
r.play(1)
start := gap()
r.now = r.now.Add(into - frameStep)
Expand Down
8 changes: 6 additions & 2 deletions native/cmd/lich-native/chat_permit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ import (

"gioui.org/io/event"
"gioui.org/io/key"
"gioui.org/widget"

"github.com/lichdotdev/lich/api"
"github.com/lichdotdev/lich/native/backend"
)

// chatPermit is the keys' target while a permission waits; shown is the last
// one they were handed to.
// one they were handed to, scrolled the one list holds the scroll of.
type chatPermit struct {
shown string
shown string
scrolled string
list widget.List
motion panelMotion
}

// focusPermit hands the keys to a waiting permission when it comes, unless a
Expand Down
Loading
Loading