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 @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- **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.
- **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
processor they took. Answers also come in more smoothly, about thirty updates a second instead of twenty.
Expand Down
27 changes: 17 additions & 10 deletions native/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ look on every page (`browser_notes_view.go`), and Windows' close button hovers i
| --- | --- |
| `Canvas` | the ground the islands float on |
| `Background` | full screens inside the stage (Settings, Pulls) and code blocks set inside a raised surface |
| `Sidebar`, `Card`, `Popover` | islands and raised parts: sidebar, dock, a code or log island and the box being written in on Pulls, menus, dialogs |
| `Sidebar`, `Card`, `Popover` | islands and raised parts: sidebar, dock, a code or log island and a thread's card on Pulls, menus, dialogs |
| `Accent` | hover and selection fill |
| `MutedForeground` | secondary text, icons at rest, paths, meta, the tree's links and neutral rings |
| `Border` | input edges and the island hairline |
Expand Down Expand Up @@ -1070,12 +1070,18 @@ right. No card, rule or zebra separates the rows; a group is a muted uppercase h
(`factLine`): branches, conflicts, checks, a reviewer with what they said, the sessions and checkout it has here.
A fact it does not have is left out, never "none". A narrow island puts the facts on top. Editing swaps the
description for its box with the text where the prose was, and the facts stay still.
- **Conversation** has no boxes around what was said: an avatar, the name and age, the text under them. A thread is
a folding line with its file over its code, the lines it is about in an edged `Sidebar` island, then its talk. A
comment's own actions are in a `⋯` under the pointer. Only the box being written in is filled (`writeBox`),
with `Textarea.Bare` inside it, so the one surface on the page is where the keyboard is.
- **Files** gives each file a header on the `Background` and its code in an edged `Sidebar` island under it, where
its threads sit between the lines. The dock's Review keeps the header inside the card.
- **Conversation** has no box around what is said to everyone: an avatar, the name and age, the text under them. What
is said about a file's lines is a card where that text starts (`talkCard`): edged, on `Sidebar`, its head the
file, the lines, the folder and the fold (folded, what the thread opens with), then the code from edge to edge and
the talk at `Space(3)`. A reply stands in by an avatar, on a line from the first comment's that turns into each one
(`replyTree`, in the sidebar tree's stroke) and ends at the last. Reply is a field at rest under the talk, not a
node of that line, with Send to session and Resolve at its right. The comments of a review not sent yet are cards
of the same shape, and so is the box for a comment on the pull request. An entry's own actions are in a `⋯` under
the pointer. A box being written in (`writeBox`) has no field in it, `Textarea.Bare`, and is filled with what it
does not stand on: `Sidebar` on the screen, `Background` in a card.
- **Files** gives each file a header on the `Background` and its code in an edged `Sidebar` island under it. Its
threads, pending comments and the box writing one are the conversation's cards between the lines, without the file
in their head. The dock's Review keeps the header inside the card.
- **Checks** are grouped Failed, Running and Passed. A finished job opens its log in the same tab (`pulls_log.go`):
the checks stay in a column at the left under All checks, and the log is an edged `Sidebar` island at the right,
its steps (GitLab's has none) folding lines with the failed one open and scrolled to its first error. The log's text is mono
Expand All @@ -1100,7 +1106,7 @@ right. No card, rule or zebra separates the rows; a group is a muted uppercase h
says nothing. A draft is muted, on a list row and in the head alike, since amber on a row is the verdict waiting on its reviewer.
- **Actions** stand at the right. In a comment, reply or edit box, Cancel then the action, which wears
Ctrl+Enter's cap (`ctrlEnterCap`, Cmd+Enter on macOS) or `↵`'s where Enter sends. A thread's are ghost `SizeXS`
after its talk: Send to session, then Resolve, which folds it away. A pending comment's Edit and Discard are the
beside its reply field: Send to session, then Resolve, which folds it away. A pending comment's Edit and Discard are the
same small neutral ghosts: what Discard drops was never sent.
- **A pull request linked by hand** (`linkpr_panel.go`): the session's card menu has Link pull request…, a
`DropdownPanel` (`Space(75)` wide) with one field for `#N` or a GitHub or GitLab URL, Cancel (ghost) and a
Expand Down Expand Up @@ -1509,8 +1515,9 @@ space, never a rule.

### Boxes inside a screen

A thread, a pending comment or a composer is a box on `Sidebar` with `RadiusMD` and `Space(3)` padding. Its
children draw on `th.On(th.Sidebar)`.
A pending comment or a composer is a box on `Sidebar` with `RadiusMD` and `Space(3)` padding. Its children draw on
`th.On(th.Sidebar)`. On Pulls they and the threads are its cards (see Pulls › Conversation), where the lines a thread
is about are a diff from edge to edge and its comments stand `Space(4)` apart.

A notice about the box's own session (the usage limit's) is a balloon in the composer's head, over the text:
`Space(2)` from the box's edge, `RadiusMD` inside the box's `RadiusLG`, filled with the box's own fill mixed toward
Expand Down
2 changes: 1 addition & 1 deletion native/cmd/lich-native/dock_comments.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (c *commentComposer) write(gtx C, th *ui.Theme, store *commentStore, target
return D{}
}
action, prompt, keys := c.words()
return writeBox{editor: &c.editor, placeholder: prompt, action: action, keys: keys, send: &c.add, cancel: &c.cancel}.layout(gtx, th)
return inlineCard(gtx, th, writeBox{editor: &c.editor, placeholder: prompt, action: action, keys: keys, send: &c.add, cancel: &c.cancel, plain: true}.layout)
}

// layout draws the box while open; it is zero-sized when closed.
Expand Down
11 changes: 2 additions & 9 deletions native/cmd/lich-native/pulls_comment_edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ func (v *pullView) comment(gtx C, th *ui.Theme, p *pullsScreen, t commentTarget,
over.read(gtx)
dims := p.withAvatar(gtx, th, who, func(gtx C) D {
children := []layout.FlexChild{layout.Rigid(func(gtx C) D {
gtx.Constraints.Min.Y = gtx.Dp(authorAvatarSize)
return layout.Flex{Alignment: layout.Middle}.Layout(gtx,
layout.Flexed(1, ui.Spanning(head)),
layout.Rigid(func(gtx C) D { return v.commentMore(gtx, th, p, t, over.over) }),
)
return entryHead(gtx, head, func(gtx C) D { return v.commentMore(gtx, th, p, t, over.over) })
})}
if content != nil {
children = append(children, ui.VGap(0.5), layout.Rigid(content))
Expand Down Expand Up @@ -133,10 +129,7 @@ func (v *pullView) commentMore(gtx C, th *ui.Theme, p *pullsScreen, t commentTar
return th.DropdownMenu(p.root, menu, entries).Layout(gtx, func(gtx C) D {
b := th.Button(clickableOf(s.moreClicks, t.key()), "")
b.Icon, b.Variant, b.Size = icPullMore, ui.VariantGhost, ui.SizeIconXS
// No taller than the name's line, which it must not move.
dims := v.withTip(gtx, th, p, "more:"+t.key(), i18n.T("pulls.reviewThread.more"), b.Layout)
dims.Size.Y = min(dims.Size.Y, gtx.Dp(authorAvatarSize))
return dims
return v.withTip(gtx, th, p, "more:"+t.key(), i18n.T("pulls.reviewThread.more"), b.Layout)
})
}

Expand Down
126 changes: 64 additions & 62 deletions native/cmd/lich-native/pulls_conversation.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -141,14 +140,19 @@ func (v *pullView) conversationRows(gtx C, th *ui.Theme, p *pullsScreen, d backe
target := commentTarget{kind: prComment, id: c.ID, body: c.Body, canEdit: c.CanEdit, canDelete: c.CanDelete}
rows = append(rows, v.talkEntry(th, p, "comment:"+c.Date+c.Author, author{c.Author, c.Avatar}, "", target, c.Date, now, act))
default:
rows = append(rows, v.threadRow(th, p, d, *it.thread, act, now, 0))
row := v.threadRow(th, p, d, *it.thread, act, now)
if len(rows) == 0 {
card := row
row = func(gtx C) D { return layout.Inset{Top: talkGap}.Layout(gtx, card) }
}
rows = append(rows, row)
}
}
if len(resolved) > 0 {
rows = append(rows, func(gtx C) D { return v.resolvedToggle(gtx, th, len(resolved)) })
if v.talk.showResolved.Value {
for _, t := range resolved {
rows = append(rows, v.threadRow(th, p, d, t, act, now, pullsTextX-pullsPadX))
rows = append(rows, v.threadRow(th, p, d, t, act, now))
}
}
}
Expand Down Expand Up @@ -208,17 +212,19 @@ func byline(gtx C, th *ui.Theme, author, verdict, date string, now time.Time) D
return layout.Flex{Alignment: layout.Baseline}.Layout(gtx, children...)
}

// resolvedToggle is the line that folds the resolved threads.
// resolvedToggle is the line that folds the resolved threads, over their cards.
func (v *pullView) resolvedToggle(gtx C, th *ui.Theme, n int) D {
s := &v.talk
label := i18n.T("pulls.pullsConversation.resolved", i18n.Args{"count": n})
gtx.Constraints.Max.X = min(gtx.Constraints.Max.X, gtx.Dp(overviewProseWidth+2*pullsPadX))
return pullsLine(gtx, th, &s.resolvedTap, false, func(gtx C, th *ui.Theme) D {
return layout.Flex{Alignment: layout.Middle}.Layout(gtx,
layout.Rigid(inNodeColumn(func(gtx C) D { return foldIcon(s.showResolved.Value).Layout(gtx, ui.Space(3.5), th.MutedForeground) })),
layout.Rigid(layout.Spacer{Width: pullsLineGap}.Layout),
layout.Rigid(th.Text(ui.TextSM, label).Muted().Layout),
)
return layout.Inset{Left: pullsTextX, Right: pullsPadX}.Layout(gtx, func(gtx C) D {
return th.NavRow(gtx, &s.resolvedTap, false, pullsLineHeight, cardPad, func(gtx C, th *ui.Theme) D {
return layout.Flex{Alignment: layout.Middle}.Layout(gtx,
layout.Rigid(inNodeColumn(func(gtx C) D { return foldIcon(s.showResolved.Value).Layout(gtx, ui.Space(3.5), th.MutedForeground) })),
layout.Rigid(layout.Spacer{Width: pullsLineGap}.Layout),
layout.Rigid(th.Text(ui.TextSM, label).Muted().Layout),
)
})
})
}

Expand All @@ -236,83 +242,79 @@ func (v *pullView) commentBox(gtx C, th *ui.Theme, act *pullsAction) D {
}
box := writeBox{editor: &s.comment, placeholder: i18n.T("pulls.pullsConversation.commentOn"), action: i18n.T("pulls.pullsConversation.comment"),
send: &s.commentSend, cancel: &s.commentDrop, busy: v.busyNow() == "comment",
resting: s.comment.Len() == 0 && !gtx.Focused(&s.comment)}
plain: true, resting: s.comment.Len() == 0 && !gtx.Focused(&s.comment)}
if box.busy {
box.action = i18n.T("pulls.commentBox.sending")
}
return talkColumn(gtx, func(gtx C) D {
return layout.Inset{Top: talkGap, Bottom: talkGap}.Layout(gtx, func(gtx C) D { return box.layout(gtx, th) })
})
return layout.Inset{Top: talkGap, Bottom: 2 * talkGap}.Layout(gtx, func(gtx C) D { return talkCardRow(gtx, th, box.layout) })
}

// pendingRows is the review being written: each line comment as an entry of
// the viewer's own, until the review is submitted.
// pendingRows is the review being written: each line comment as a card of the
// viewer's own, until the review is submitted.
func (v *pullView) pendingRows(th *ui.Theme, p *pullsScreen, r *pendingReview) []layout.Widget {
comments := r.snapshot()
rows := make([]layout.Widget, len(comments))
for i, c := range comments {
rows[i] = func(gtx C) D {
return talkColumn(gtx, func(gtx C) D { return v.pendingEntry(gtx, th, p, i, c) })
return talkCardRow(gtx, th, func(gtx C, th *ui.Theme) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D { return pendingHead(gtx, th, c) }),
layout.Rigid(func(gtx C) D {
return layout.Inset{Left: cardPad, Right: cardPad, Bottom: cardPad}.Layout(gtx, func(gtx C) D { return v.pendingEntry(gtx, th, p, i, c) })
}),
)
})
}
}
return rows
}

// pendingHead is where a pending comment is, as a thread's card names it.
func pendingHead(gtx C, th *ui.Theme, c backend.ReviewComment) D {
gtx.Constraints.Min.Y = gtx.Dp(cardHeadHeight)
return layout.Inset{Left: cardPad, Right: cardPad}.Layout(gtx, func(gtx C) D {
return layout.W.Layout(gtx, func(gtx C) D {
return layout.Flex{Alignment: layout.Middle}.Layout(gtx, append(cardFile(th, c.Path),
layout.Rigid(th.Text(ui.TextXS, lineAnchor(c.StartLine, c.Line)).Mono().Layout))...)
})
})
}

// pendingEntry is one line comment of the review being written, with Edit and
// Discard beside the line it is on, or the box rewording it.
// Discard, or the box rewording it.
func (v *pullView) pendingEntry(gtx C, th *ui.Theme, p *pullsScreen, i int, c backend.ReviewComment) D {
s := &v.talk
e := &s.pendingEdit
editing := e.open && e.index == i
you := author{login: i18n.T("pulls.pullsConversation.you")}
who := func(gtx C) D {
return byline(gtx, th, you.login, i18n.T("pulls.pullsConversation.pendingNote"), "", gtx.Now)
}
actions := func(gtx C) D {
if editing {
return D{}
}
edit := th.Button(clickableAt(s.edits, i), i18n.T("pulls.pullsConversation.edit"))
edit.Size, edit.Variant = ui.SizeXS, ui.VariantGhost
discard := th.Button(clickableAt(s.discards, i), i18n.T("pulls.pullsConversation.discard"))
discard.Size, discard.Variant = ui.SizeXS, ui.VariantGhost
return layout.Flex{}.Layout(gtx, layout.Rigid(edit.Layout), ui.Gap(1), layout.Rigid(discard.Layout))
}
body := th.Text(ui.TextSM, c.Body).Wrapped().Layout
if editing {
body = func(gtx C) D {
return writeBox{editor: &e.editor, action: i18n.T("pulls.pullsConversation.save"), send: &e.save, cancel: &e.cancel}.layout(gtx, th)
}
}
return p.withAvatar(gtx, th, you, func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
gtx.Constraints.Min.Y = gtx.Dp(authorAvatarSize)
return layout.W.Layout(gtx, func(gtx C) D {
return byline(gtx, th, you.login, i18n.T("pulls.pullsConversation.pendingNote"), "", gtx.Now)
})
}),
layout.Rigid(func(gtx C) D { return entryHead(gtx, who, actions) }),
ui.VGap(0.5),
layout.Rigid(func(gtx C) D {
return v.pendingBody(gtx, th, i, c, func(gtx C) D { return fileAnchor(gtx, th, c.Path, lineAnchor(c.StartLine, c.Line)) })
}),
layout.Rigid(body),
)
})
}

// pendingBody is a pending comment's text over where, what says where it
// stands, and its Edit and Discard; or the box rewording it.
func (v *pullView) pendingBody(gtx C, th *ui.Theme, i int, c backend.ReviewComment, where layout.Widget) D {
s := &v.talk
if e := &s.pendingEdit; e.open && e.index == i {
return writeBox{editor: &e.editor, action: i18n.T("pulls.pullsConversation.save"), send: &e.save, cancel: &e.cancel}.layout(gtx, th)
}
edit := th.Button(clickableAt(s.edits, i), i18n.T("pulls.pullsConversation.edit"))
edit.Size, edit.Variant = ui.SizeXS, ui.VariantGhost
discard := th.Button(clickableAt(s.discards, i), i18n.T("pulls.pullsConversation.discard"))
discard.Size, discard.Variant = ui.SizeXS, ui.VariantGhost
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(th.Text(ui.TextSM, c.Body).Wrapped().Layout),
ui.VGap(1),
layout.Rigid(func(gtx C) D {
return layout.Flex{Alignment: layout.Middle}.Layout(gtx,
layout.Flexed(1, ui.Spanning(where)),
ui.Gap(2), layout.Rigid(edit.Layout),
ui.Gap(1), layout.Rigid(discard.Layout),
)
}),
)
}

// fileAnchor is a file's icon and name with the lines a comment is on.
func fileAnchor(gtx C, th *ui.Theme, path, lines string) D {
return layout.Flex{Alignment: layout.Middle}.Layout(gtx,
layout.Rigid(th.FileIcon(path, ui.Space(3.5)).Layout),
ui.Gap(1.5),
layout.Rigid(th.Text(ui.TextXS, filepath.Base(path)).Weight(font.Medium).Layout),
ui.Gap(1.5),
layout.Rigid(th.Text(ui.TextXS, lines).Mono().Muted().Layout),
)
}

func (v *pullView) pendingOf(url string) *pendingReview {
r, ok := v.pending[url]
if !ok {
Expand Down
29 changes: 17 additions & 12 deletions native/cmd/lich-native/pulls_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,46 +395,51 @@ func (v *pullView) inlineThread(gtx C, id string) D {
if len(t.Comments) > 0 {
t.Comments[0].DiffHunk = ""
}
return threadSlot.Layout(gtx, func(gtx C) D { return v.threadInline(gtx, f.th.On(f.th.Sidebar), t) })
return inlineCard(gtx, f.th, func(gtx C, th *ui.Theme) D { return v.threadInline(gtx, th, t) })
}
return D{}
}

// threadSlot is the room a thread or a pending comment keeps in the diff.
var threadSlot = layout.Inset{Left: ui.Space(3), Right: ui.Space(3), Top: ui.Space(2.5), Bottom: ui.Space(2.5)}
// inlineCard is a card between the diff's lines, at the conversation's width.
func inlineCard(gtx C, th *ui.Theme, w func(gtx C, th *ui.Theme) D) D {
return layout.Inset{Left: ui.Space(3), Right: ui.Space(3), Top: ui.Space(2.5), Bottom: ui.Space(2.5)}.Layout(gtx, func(gtx C) D {
gtx.Constraints.Max.X = min(gtx.Constraints.Max.X, gtx.Dp(overviewProseWidth))
return talkCard(gtx, th, w)
})
}

// threadInline is a thread on the code's own surface: what was said, under the
// line that folds it once it is resolved or folded.
// threadInline is a thread's card in the diff: what was said, under the line
// that folds it once it is resolved or folded.
func (v *pullView) threadInline(gtx C, th *ui.Theme, t backend.PRReviewThread) D {
f := v.inline
open := v.threadOpen(gtx, t)
talk := func(gtx C) D { return v.threadTalk(gtx, th, f.p, f.d, t, f.act, f.now) }
if open && !t.IsResolved {
return talk(gtx)
return cardInset.Layout(gtx, talk)
}
fact := threadFact(f.p, t, open)
if t.IsResolved {
fact = i18n.T("pulls.reviewThread.resolved")
}
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return th.NavRow(gtx, v.talk.foldClicks[t.ID], false, pullsLineHeight, 0, func(gtx C, th *ui.Theme) D {
return threadLine(gtx, th, t, open, fact, false)
return th.NavRow(gtx, v.talk.foldClicks[t.ID], false, cardHeadHeight, cardPad, func(gtx C, th *ui.Theme) D {
return threadHead(gtx, th, t, open, fact, false)
})
}),
layout.Rigid(func(gtx C) D {
if !open {
return D{}
}
return layout.Inset{Top: ui.Space(1)}.Layout(gtx, talk)
return layout.Inset{Left: cardPad, Right: cardPad, Bottom: cardPad}.Layout(gtx, talk)
}),
)
}

// inlinePending is a comment waiting for the review to be submitted, with
// the Conversation tab's Edit and Discard: talkClicks carries them out.
func (v *pullView) inlinePending(gtx C, i int, c backend.ReviewComment) D {
th := v.inline.th.On(v.inline.th.Sidebar)
note := th.Text(ui.TextXS, i18n.T("pulls.pullsConversation.pendingNote")).In(th.ToneWait).Layout
return threadSlot.Layout(gtx, func(gtx C) D { return v.pendingBody(gtx, th, i, c, note) })
return inlineCard(gtx, v.inline.th, func(gtx C, th *ui.Theme) D {
return cardInset.Layout(gtx, func(gtx C) D { return v.pendingEntry(gtx, th, v.inline.p, i, c) })
})
}
Loading
Loading