From 4ee90959676298b52133f998fd082fdd67396e1e Mon Sep 17 00:00:00 2001 From: omartelo Date: Fri, 4 Dec 2026 18:03:26 -0300 Subject: [PATCH 1/2] fix(sidebar): a session in a colored folder wears the folder's color --- internal/spawn/folders.go | 5 ++- internal/spawn/folders_test.go | 14 +++++++ internal/store/folder_test.go | 41 +++++++++++++++++++ internal/store/mutations.go | 12 ++++-- native/cmd/lich-native/sidebar_blocks.go | 9 +++- native/cmd/lich-native/sidebar_blocks_test.go | 19 +++++++++ native/cmd/lich-native/sidebar_groups.go | 3 +- native/cmd/lich-native/sidebar_groups_test.go | 10 +++++ 8 files changed, 106 insertions(+), 7 deletions(-) diff --git a/internal/spawn/folders.go b/internal/spawn/folders.go index 65ec60682..31ba8f07c 100644 --- a/internal/spawn/folders.go +++ b/internal/spawn/folders.go @@ -128,14 +128,15 @@ func (s *Service) wearFolderColor(ctx context.Context, p store.Project, filed st } // sharedFolderColor is the color every session of p filed under folder but -// the one named except wears, "" when they wear different ones or none. +// the one named except wears, "" when they wear different ones or none. A pinned +// one is drawn out of the folder, so it has no say. func sharedFolderColor(p store.Project, folder, except string) string { if folder == "" { return "" } tint, seen := "", false for _, sess := range p.Sessions { - if sess.Folder != folder || sess.ID == except { + if sess.Folder != folder || sess.ID == except || sess.Pinned { continue } if seen && sess.Color != tint { diff --git a/internal/spawn/folders_test.go b/internal/spawn/folders_test.go index b11c2fd96..8b8cec96f 100644 --- a/internal/spawn/folders_test.go +++ b/internal/spawn/folders_test.go @@ -483,3 +483,17 @@ func TestFileIntoAFolderOfMixedColorsPaintsNothing(t *testing.T) { t.Errorf("painted = %v, want nothing: Apps wears no one color", sessions.painted) } } + +// A pinned card is drawn out of its folder, so its color is not the folder's. +func TestFileReadsAFoldersColorWithoutItsPinnedCards(t *testing.T) { + svc, sessions, _ := filer(t) + sessions.projects[0].Sessions[1].Color = "pink" + sessions.projects[0].Sessions[3].Color, sessions.projects[0].Sessions[3].Pinned = "blue", true + + if _, err := svc.File(t.Context(), FileOptions{From: "s1", Target: "shared-b", Folder: "Apps"}); err != nil { + t.Fatalf("File: %v", err) + } + if sessions.painted["s3"] != "pink" { + t.Errorf("painted = %v, want s3 pink like the cards Apps draws", sessions.painted) + } +} diff --git a/internal/store/folder_test.go b/internal/store/folder_test.go index 3418aaa85..c593e42cc 100644 --- a/internal/store/folder_test.go +++ b/internal/store/folder_test.go @@ -237,3 +237,44 @@ func TestAddSessionFilesTheRowItInserts(t *testing.T) { } } } + +// A folder wears the color its cards share, so a session born in one without +// it would take the color off the whole folder. +func TestASessionBornInAColoredFolderWearsItsColor(t *testing.T) { + colorOf := func(svc *Service, id string) string { + sessions, err := svc.sessionsOf("p1") + if err != nil { + t.Fatalf("sessionsOf: %v", err) + } + i := slices.IndexFunc(sessions, func(s Session) bool { return s.ID == id }) + return sessions[i].Color + } + svc := newTestStore(t) + _, _ = svc.AddProject(t.Context(), api.AddProjectOptions{ID: "p1", Name: "alpha", Path: "/tmp/alpha"}) + for _, s := range []struct{ id, folder, color string }{ + {"s1", "Apps", "teal"}, {"s2", "Apps", "teal"}, {"s3", "Mixed", "red"}, {"s4", "Mixed", "blue"}, {"s5", "", "pink"}, + } { + _, _ = svc.AddSessionInFolder(t.Context(), api.AddSessionInFolderOptions{ProjectID: "p1", SessionID: s.id, Label: s.id, Folder: s.folder}) + _, _ = svc.SetSessionColor(t.Context(), api.SessionColorOptions{SessionID: s.id, Color: s.color}) + } + // A pinned card is drawn out of its folder, so its color is not the folder's. + _, _ = svc.AddSessionInFolder(t.Context(), api.AddSessionInFolderOptions{ProjectID: "p1", SessionID: "pin", Label: "pin", Folder: "Apps"}) + _, _ = svc.SetSessionColor(t.Context(), api.SessionColorOptions{SessionID: "pin", Color: "red"}) + _, _ = svc.SetSessionPinned(t.Context(), api.SessionPinnedOptions{SessionID: "pin", Pinned: true}) + + for folder, want := range map[string]string{"Apps": "teal", "Mixed": "", "New": "", "": ""} { + id := "born-" + folder + if _, err := svc.AddSessionInFolder(t.Context(), api.AddSessionInFolderOptions{ProjectID: "p1", SessionID: id, Label: id, Folder: folder}); err != nil { + t.Fatalf("AddSessionInFolder: %v", err) + } + if got := colorOf(svc, id); got != want { + t.Errorf("born in %q: color %q, want %q", folder, got, want) + } + } + if _, err := svc.AddSessionFrom(t.Context(), api.AddSessionFromOptions{ProjectID: "p1", SessionID: "fork", Label: "fork", OriginID: "s1", Folder: "Apps"}); err != nil { + t.Fatalf("AddSessionFrom: %v", err) + } + if got := colorOf(svc, "fork"); got != "teal" { + t.Errorf("a fork born in Apps: color %q, want teal", got) + } +} diff --git a/internal/store/mutations.go b/internal/store/mutations.go index 5bf51af14..9881a8f69 100644 --- a/internal/store/mutations.go +++ b/internal/store/mutations.go @@ -24,6 +24,12 @@ var now = time.Now // order can never be decided against a stale count. const nextSessionPosition = `(SELECT COALESCE(MAX(position), -1) + 1 FROM sessions WHERE project_id = ?)` +// folderColor is the color the cards a folder draws share, "" when they differ: +// a folder has no color of its own, so a session born in one without it would +// take it off the folder. +const folderColor = `(SELECT CASE WHEN COUNT(DISTINCT color) = 1 THEN MAX(color) ELSE '' END FROM sessions + WHERE project_id = ? AND folder = ? AND folder <> '' AND is_open = 1 AND pinned = 0)` + // setActiveSessionSQL is shared by the transactional helper below and the // standalone SetActiveSession, so the two can never drift apart. const setActiveSessionSQL = `UPDATE projects SET active_session_id = ? WHERE id = ?` @@ -176,9 +182,9 @@ func (s *Service) addSession( } return s.tx(func(tx *sql.Tx) error { if _, err := tx.Exec( - `INSERT INTO sessions (id, project_id, label, kind, path, origin_session_id, origin_label, sandbox, folder, profile, model, effort, view, position) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, `+nextSessionPosition+`)`, - sessionID, projectID, label, kind, path, originID, originLabel, sandbox, folder, profile, model, effort, view, projectID, + `INSERT INTO sessions (id, project_id, label, kind, path, origin_session_id, origin_label, sandbox, folder, profile, model, effort, view, color, position) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, `+folderColor+`, `+nextSessionPosition+`)`, + sessionID, projectID, label, kind, path, originID, originLabel, sandbox, folder, profile, model, effort, view, projectID, folder, projectID, ); err != nil { return fmt.Errorf("insert session %q: %w", sessionID, err) } diff --git a/native/cmd/lich-native/sidebar_blocks.go b/native/cmd/lich-native/sidebar_blocks.go index 520fe13f8..4ccc6a142 100644 --- a/native/cmd/lich-native/sidebar_blocks.go +++ b/native/cmd/lich-native/sidebar_blocks.go @@ -149,7 +149,14 @@ func (m *model) dressBlock(p backend.Project, b sessionBlock, pending []pendingS case blockPinned: v.title = i18n.T("sidebar.sessionGroup.pinned") case blockFolder: - v.title, v.color = b.folder, sharedColor(b.sessions) + v.title, v.color = b.folder, sharedColor(slices.DeleteFunc(slices.Clone(b.sessions), func(s backend.Session) bool { return s.Folder == "" })) + // A child drawn here by her mother is not filed here, so nothing + // painted her: she wears the folder's color unless she has her own. + for i := range v.sessions { + if sv := &v.sessions[i]; sv.Color == "" && sv.Folder == "" { + sv.Color = v.color + } + } for _, path := range checkoutsOf(b.sessions) { v.checkouts = append(v.checkouts, launchCheckout{path: path, label: checkoutLabel(path, p.Path, p.ID)}) } diff --git a/native/cmd/lich-native/sidebar_blocks_test.go b/native/cmd/lich-native/sidebar_blocks_test.go index fb7aa3c18..2929f49e4 100644 --- a/native/cmd/lich-native/sidebar_blocks_test.go +++ b/native/cmd/lich-native/sidebar_blocks_test.go @@ -197,3 +197,22 @@ func TestBlockViewsCarryTheCardsLiveState(t *testing.T) { t.Fatalf("card view = %+v", sv) } } + +// A child sits in her mother's folder without being filed there, so filing +// the mother, or an agent opening a child under her, took the folder's color +// off and left the child without it. +func TestAChildWearsTheColorOfItsMothersFolder(t *testing.T) { + m, _ := sidebarModel(t, []backend.Session{ + {ID: "a", Folder: "Apps", Color: "teal"}, {ID: "mother", Folder: "Apps", Color: "teal"}, + {ID: "child", OriginSessionID: "mother"}, {ID: "own", OriginSessionID: "mother", Color: "red"}, + }) + b := m.sidebarBlocks(sidebarFilter{}).blocks[0] + if b.color != "teal" { + t.Fatalf("the folder wears %q, want teal", b.color) + } + for _, sv := range b.sessions { + if want := map[string]string{"own": "red"}[sv.ID]; want == "" && sv.Color != "teal" || want != "" && sv.Color != want { + t.Errorf("%s wears %q", sv.ID, sv.Color) + } + } +} diff --git a/native/cmd/lich-native/sidebar_groups.go b/native/cmd/lich-native/sidebar_groups.go index b5d3dce4d..9060514ea 100644 --- a/native/cmd/lich-native/sidebar_groups.go +++ b/native/cmd/lich-native/sidebar_groups.go @@ -285,12 +285,13 @@ func refile(sessions []backend.Session, picked func(backend.Session) bool, folde // folderTint is the color a folder wears (its cards' shared one) and the // sessions of ids filed into it that must take it, so it keeps wearing it: // a folder's color is its cards', and one card without it would take it off. +// A pinned card is drawn out of the folder, so it has no say. func folderTint(sessions []backend.Session, ids []string, folder string) (string, []string) { if folder == "" { return "", nil } members := slices.DeleteFunc(slices.Clone(sessions), func(s backend.Session) bool { - return s.Folder != folder || slices.Contains(ids, s.ID) + return s.Folder != folder || s.Pinned || slices.Contains(ids, s.ID) }) tint := sharedColor(members) if tint == "" { diff --git a/native/cmd/lich-native/sidebar_groups_test.go b/native/cmd/lich-native/sidebar_groups_test.go index 5773a093c..b3f16bc0e 100644 --- a/native/cmd/lich-native/sidebar_groups_test.go +++ b/native/cmd/lich-native/sidebar_groups_test.go @@ -301,3 +301,13 @@ func TestFilingIntoAColoredFolderPaintsTheCard(t *testing.T) { t.Errorf("a folder of mixed colors: tint %q repaint %v, want nothing painted", tint, repaint) } } + +// A pinned card is drawn out of its folder, so its color is not the folder's. +func TestAFoldersColorLeavesItsPinnedCardsOut(t *testing.T) { + sessions := []backend.Session{ + {ID: "a", Folder: "Releases", Color: "pink"}, {ID: "pinned", Folder: "Releases", Color: "blue", Pinned: true}, {ID: "plain"}, + } + if tint, repaint := folderTint(sessions, []string{"plain"}, "Releases"); tint != "pink" || !slices.Equal(repaint, []string{"plain"}) { + t.Errorf("tint %q repaint %v, want pink on plain", tint, repaint) + } +} From 226d776a3622902c9432dba464d9f3c3fef99563 Mon Sep 17 00:00:00 2001 From: omartelo Date: Fri, 4 Dec 2026 18:15:20 -0300 Subject: [PATCH 2/2] feat(sidebar): compact rows, a one-line foot and a tooltip that says where a session works --- CHANGELOG.md | 2 + README.es.md | 2 +- README.ja.md | 2 +- README.ko.md | 2 +- README.md | 2 +- README.pt-BR.md | 2 +- README.ru.md | 2 +- README.zh-CN.md | 2 +- docs/ceilings.md | 2 +- docs/cli.md | 2 +- native/DESIGN.md | 79 +++-- native/cmd/lich-native/model.go | 4 +- native/cmd/lich-native/prbadge.go | 3 +- native/cmd/lich-native/prbadge_test.go | 9 +- native/cmd/lich-native/services_shot.go | 8 +- native/cmd/lich-native/services_test.go | 71 ++-- native/cmd/lich-native/sessiontooltip.go | 176 ++++++---- native/cmd/lich-native/sessiontooltip_test.go | 82 +++++ native/cmd/lich-native/sidebar.go | 29 +- native/cmd/lich-native/sidebar_browser_row.go | 2 +- native/cmd/lich-native/sidebar_card.go | 27 +- native/cmd/lich-native/sidebar_card_test.go | 4 +- native/cmd/lich-native/sidebar_editor_row.go | 7 +- native/cmd/lich-native/sidebar_foot_test.go | 135 ++++++++ .../cmd/lich-native/sidebar_group_header.go | 86 ++--- native/cmd/lich-native/sidebar_header.go | 68 +++- native/cmd/lich-native/sidebar_morph.go | 8 +- .../cmd/lich-native/sidebar_profile_footer.go | 27 +- .../lich-native/sidebar_profile_panel_test.go | 2 +- native/cmd/lich-native/sidebar_rail.go | 33 +- native/cmd/lich-native/sidebar_rail_footer.go | 158 ++------- native/cmd/lich-native/sidebar_rail_test.go | 26 -- native/cmd/lich-native/sidebar_services.go | 312 +++++++----------- native/cmd/lich-native/sidebar_split.go | 8 +- native/cmd/lich-native/sidebar_tree_draw.go | 4 + native/cmd/lich-native/statusrung.go | 87 ++--- native/cmd/lich-native/toolline.go | 57 ---- native/cmd/lich-native/toolline_test.go | 41 --- native/i18n/locales/en/sidebar.json | 18 +- native/i18n/locales/en/tour.json | 2 +- native/i18n/locales/en/tourWorktrees.json | 4 +- native/i18n/locales/es/sidebar.json | 18 +- native/i18n/locales/es/tour.json | 2 +- native/i18n/locales/es/tourWorktrees.json | 4 +- native/i18n/locales/ja/sidebar.json | 15 +- native/i18n/locales/ja/tour.json | 2 +- native/i18n/locales/ja/tourWorktrees.json | 4 +- native/i18n/locales/ko/sidebar.json | 15 +- native/i18n/locales/ko/tour.json | 2 +- native/i18n/locales/ko/tourWorktrees.json | 4 +- native/i18n/locales/pt-br/sidebar.json | 18 +- native/i18n/locales/pt-br/tour.json | 2 +- native/i18n/locales/pt-br/tourWorktrees.json | 4 +- native/i18n/locales/ru/sidebar.json | 24 +- native/i18n/locales/ru/tour.json | 2 +- native/i18n/locales/ru/tourWorktrees.json | 4 +- native/i18n/locales/zh-cn/sidebar.json | 15 +- native/i18n/locales/zh-cn/tour.json | 2 +- native/i18n/locales/zh-cn/tourWorktrees.json | 4 +- 59 files changed, 833 insertions(+), 905 deletions(-) create mode 100644 native/cmd/lich-native/sidebar_foot_test.go delete mode 100644 native/cmd/lich-native/toolline.go delete mode 100644 native/cmd/lich-native/toolline_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index e9b4aa889..5390ea28e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **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. - **A command you run with `!` in the chat is one message with its output.** The command and what it printed stand together on your side of the conversation, with the time it took when it is a second or more, and in red when it fails. On Claude Code, Codex and opencode, the agents whose chat runs commands. +- **The sidebar fits more sessions, and its tooltip tells you where each one works.** Rows are shorter, a branch glyph marks a session off the main branch, and resting the pointer on a row shows its branch, worktree, changes, pull request and conflicts. Services moved to the glyph at the end of the foot, green while one runs and red when one failed; click it for the list. - **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 @@ -43,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- **A session you open in a colored folder takes the folder's color.** It used to stay without one and take the color off the whole folder, and so did the sessions an agent opened under one filed there. - **The window no longer stops for a moment at the first Chinese, Japanese or Korean text.** Its fonts are read in the background, and the text takes them a moment later. - **A chat reopened after lich restarts shows each of your messages at the time you sent it.** Every message used to read the time of the restart. Claude Code and Codex chats are fixed; an agent that gives no time for a past message, the ones over ACP, still shows the restart's. diff --git a/README.es.md b/README.es.md index c69e9822a..e144188fd 100644 --- a/README.es.md +++ b/README.es.md @@ -102,7 +102,7 @@ en [INSTALL.md](INSTALL.md). 2. **Elige tu agente.** La primera vez que lo abres, lista los agentes que encontró en tu máquina. En Ajustes › Proveedores defines el predeterminado y la ruta de cada binario. -3. **Inicia una sesión.** *Nueva sesión* abre tu agente en el proyecto como chat, +3. **Inicia una sesión.** *Nueva* abre tu agente en el proyecto como chat, o en su terminal si Ajustes › Proveedores lo indica. El `+` del encabezado de un checkout abre cualquier agente, o una terminal sin agente, en ese checkout. 4. **Dale un worktree** *(opcional)*. Créalo a partir de cualquier rama base y diff --git a/README.ja.md b/README.ja.md index 143700941..601e7eb48 100644 --- a/README.ja.md +++ b/README.ja.md @@ -100,7 +100,7 @@ Gatekeeper や SmartScreen の警告が出ます。Homebrew でインストー フォルダー選択ダイアログが出ます。git リポジトリを選んでください。 2. **使うエージェントを選びます。** 初回起動時に、マシン上で見つかったエージェントが一覧されます。 設定 › プロバイダーで、既定のエージェントと各バイナリのパスを設定できます。 -3. **セッションを開始します。** *新規セッション* で、プロジェクト内でエージェントがチャットとして開きます。 +3. **セッションを開始します。** *新規* で、プロジェクト内でエージェントがチャットとして開きます。 設定 › プロバイダーでそう指定していれば、ターミナルで開きます。 各チェックアウトのヘッダーにある `+` からは、好きなエージェントや通常のターミナルを、そのチェックアウトで開けます。 4. **ワークツリーを作ります** *(任意)*。どのベースブランチからでも作成でき、 diff --git a/README.ko.md b/README.ko.md index ac7f06da5..fd8fbdc8e 100644 --- a/README.ko.md +++ b/README.ko.md @@ -100,7 +100,7 @@ SmartScreen이 경고를 띄웁니다. Homebrew로 설치하면 Gatekeeper 경 열립니다. 여기서 git 저장소를 고르세요. 2. **에이전트를 고릅니다.** 처음 실행하면 머신에서 찾은 에이전트 목록이 나옵니다. 설정 › 프로바이더에서 기본값과 바이너리 경로를 지정할 수 있습니다. -3. **세션을 시작합니다.** *새 세션*을 누르면 프로젝트에서 에이전트가 채팅으로 열리고, 설정 › +3. **세션을 시작합니다.** *새로 만들기*를 누르면 프로젝트에서 에이전트가 채팅으로 열리고, 설정 › 프로바이더에서 터미널을 골랐다면 터미널로 열립니다. 체크아웃 헤더의 `+`로는 원하는 에이전트나 일반 터미널을 바로 그 체크아웃에서 열 수 있습니다. 4. **worktree를 만듭니다** *(선택)*. 원하는 베이스 브랜치에서 하나 만들면 lich가 그 안에 diff --git a/README.md b/README.md index 1211ac804..85356eb4f 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ upgrading from the old Homebrew formula are in [INSTALL.md](INSTALL.md). and opens a folder picker. Point it at a git repository. 2. **Pick your agent.** The first launch lists the agents it found on your machine. Settings › Providers sets the default and each binary's path. -3. **Start a session.** *New Session* opens your agent in the project as a chat, +3. **Start a session.** *New* opens your agent in the project as a chat, or in its terminal if Settings › Providers says so. The `+` on a checkout's header opens any agent, or a plain terminal, in that checkout. 4. **Give it a worktree** *(optional)*. Create one from any base branch and lich diff --git a/README.pt-BR.md b/README.pt-BR.md index f743a7332..2f2952ec5 100644 --- a/README.pt-BR.md +++ b/README.pt-BR.md @@ -102,7 +102,7 @@ estão no [INSTALL.md](INSTALL.md). 2. **Escolha o seu agente.** Na primeira execução, o lich lista os agentes que encontrou na máquina. Em Configurações › Provedores você define o padrão e o caminho de cada binário. -3. **Inicie uma sessão.** *Nova sessão* abre o seu agente no projeto como chat, +3. **Inicie uma sessão.** *Nova* abre o seu agente no projeto como chat, ou no terminal se Configurações › Provedores pedir. O `+` no cabeçalho de um checkout abre qualquer agente, ou um terminal comum, naquele checkout. 4. **Dê uma worktree para ela** *(opcional)*. Crie uma a partir de qualquer diff --git a/README.ru.md b/README.ru.md index ed9b5e05a..708d1e621 100644 --- a/README.ru.md +++ b/README.ru.md @@ -102,7 +102,7 @@ Linux, снятие флага карантина и переход со ста 2. **Выберите агента.** При первом запуске lich покажет агентов, которых нашёл на вашей машине. В разделе Настройки › Провайдеры задаются агент по умолчанию и путь к исполняемому файлу каждого. -3. **Запустите сессию.** Кнопка *Новая сессия* открывает вашего агента в проекте +3. **Запустите сессию.** Кнопка *Новая* открывает вашего агента в проекте как чат или в терминале, если так выбрано в Настройки › Провайдеры. Кнопка `+` в заголовке checkout открывает любого агента или обычный терминал именно в этом checkout. diff --git a/README.zh-CN.md b/README.zh-CN.md index dd59808fa..f1eeccd9f 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -99,7 +99,7 @@ tarball、清除隔离标记,以及从旧的 Homebrew formula 升级,见 [IN 仓库即可。 2. **选择智能体。** 首次启动会列出在你机器上找到的智能体。设置 › 提供商里可以设置默认智能体, 以及每个可执行文件的路径。 -3. **开启会话。** *新建会话*会在项目里以聊天打开你的智能体;如果设置 › 提供商里选了终端, +3. **开启会话。** *新建*会在项目里以聊天打开你的智能体;如果设置 › 提供商里选了终端, 则在终端里打开。每个检出目录标题栏上的 `+`,可以在该检出目录里打开任意智能体或普通终端。 4. **给它一个 worktree** *(可选)*。从任意基础分支创建,lich 会在其中打开一个新会话。 diff --git a/docs/ceilings.md b/docs/ceilings.md index 917f97251..063199dc7 100644 --- a/docs/ceilings.md +++ b/docs/ceilings.md @@ -2523,7 +2523,7 @@ work when nobody knows it and that the call site never shows. The mechanism and when every session is in one, which is also what a session closed there or a window reopened lands on, so the tab does not come back on the session it last showed. A layout's tab has a sidebar of its own, its sessions under their projects' names in the project sidebar's tree. That list is not the project's: it has - no New Session, filter or services, a card there offers no folder and is not dragged, a mother's children + no New or filter, a card there offers no folder and is not dragged, a mother's children cannot be folded, a checkout row has no menu, a folder is not drawn, and no card is lit, the panes showing which session has the focus. The collapsed sidebar still lists the focused pane's project. A split is refused, with a toast, when a pane would drop under 480dp (51 columns at the default 13sp, measured with diff --git a/docs/cli.md b/docs/cli.md index 86ecfe630..94db92a58 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -776,7 +776,7 @@ session on /home/you/src/revu again reopens the project with them. ### `lich service [--project ] [--name ] [--command ] [--start-with-lich[=false]] [--json] [args]` -Manages a project's services, the commands the window's Services footer runs +Manages a project's services, the commands the window's services panel runs on a console of their own. The project defaults to the caller's own; a service is named by its name in the project, matched without regard to case. Flags go before the verb. diff --git a/native/DESIGN.md b/native/DESIGN.md index 72aea4ffc..4a89775d1 100644 --- a/native/DESIGN.md +++ b/native/DESIGN.md @@ -37,8 +37,8 @@ Elements are defined by space, hover and islands, not by enclosure. island's edge and an input's edge, since a field needs one to read as editable; the code editor's gutter rule is the one line inside a view (see The editor). - **Group labels and heads count in the states' tones.** A group's label is `Text2XS`, uppercase, semibold and - muted (SERVICES, a panel's RUNNING); what it counts follows it, each part in its state's tone and - " · " between them (the services' "2 running · 1 failed", the bell's "1 waiting · 3 done", a zoomed pane's + muted (a panel's RUNNING); what it counts follows it, each part in its state's tone and + " · " between them (the bell's "1 waiting · 3 done", a zoomed pane's "· 1 waiting"), muted when no part carries a state. - **State is the glyph.** A check, a dot, a switch, a spinner or a lock says it; a word joins the glyph only where it adds something the glyph cannot (an error, an exit code, a custom path, restarting). The word stays @@ -283,7 +283,7 @@ is the card variant, `th.TooltipCard`, on the row's right side. Every island keeps its content `Space(2)` (8px) from its rounded edge, on all four sides: the sidebar (`sidebar.go`, `UniformInset(Space(2))`), the Settings nav (`settings_nav.go`) and the Pulls header strip -(`pullsToolbarPad`). Controls and rows sit flush on that edge, box first: the sidebar's New session button, +(`pullsToolbarPad`). Controls and rows sit flush on that edge, box first: the sidebar's New button, the Settings search field, a nav row, the Pulls back button and tree toggle all start at 8px, and their hover fill spans the 8px edge to edge. @@ -1577,16 +1577,22 @@ in and whatever their status: a row never moves because its session changed phas ### A row -Every row is one line, 34dp tall: `Space(1.5)` above and below a 22px node. Rows stand flush, no gap -(`cardGap` is 0). - -- **A session row**: the provider's mark, the shield and fork glyphs it earns, its name, its branch in - `TextXS` mono `MutedForeground` (at most `branchShare`, 35%, of the line, so the name keeps the room), and - the corner slot. Neither the checkout's changes nor its pull request is on the line: the row's width belongs - to the name. -- **A row's tooltip** keeps the branch on a line of its own, whole (it wraps, never cut), and under it the - pull request and then the changes. -- **A pull request** (`prBadge`, in a row's tooltip and on the chat composer's line): the forge's logo at 12px in +Every row is one line, 28dp tall (`railRow`): `treeRowPad`, 3dp, above and below a 22px node. Rows stand flush, +no gap (`cardGap` is 0). + +- **A session row**: the provider's mark, the shield and fork glyphs it earns, its name, the `git-branch` glyph + at 12px in `MutedForeground` when it works off the project's base branch (`offBase`: a worktree of its own, or + another branch), and the corner slot. The branch's name, the checkout's changes and its pull request are never + on the line: the row's width belongs to the name. +- **A row's tooltip** (`sessiontooltip.go`) is `tipWidth` wide for every session, in groups `Space(2)` apart. The + name in `TextSM` medium, with the status in a word and its age at the end of the line (Working 42s; Waiting on + you in `ToneWait`; Done in `TonePass`). Where it works: the branch in mono `Foreground`, wrapped and never cut, + with the changes at its line's end; the folder, only away from the project's own (the worktree's name, the + subfolder it went into, or the whole path outside its checkout); the pull request's glyph and number in its + tone, then how far behind the base. Then the files a merge would conflict on, the rare notes (a path the + sandbox left out, what a subagent brought, a scheduled prompt) and last the model, muted. It names no running + tool, and draws no line for what there is nothing to say about. +- **A pull request** (`prBadge`, on the chat composer's line): the forge's logo at 12px in `MutedForeground` (`Foreground` on hover where it is a link), then the state's glyph at 12px and the number in the line's text size, both in the state's tone: open `git-pull-request` in `TonePass`, draft `git-pull-request-draft` muted, merged `git-merge` in `ToneMerged`, closed `git-pull-request-closed` in `Destructive`. A merged or closed one stays while the @@ -1599,18 +1605,23 @@ Every row is one line, 34dp tall: `Space(1.5)` above and below a 22px node. Rows while it has none), the corner slot. The name is `MutedForeground` while the page is off the stage. A folded mother shows a globe on her own row instead. - **An editor row**: a file open in the stage editor for a session's checkout, one row a file in the order opened, its node the file's icon (`th.FileIcon`, as the Files tree), under the session working in - that checkout (the active one, else the first drawn), after its browser row. + that checkout (the active one, else the first drawn), after its browser row. Its name is `MutedForeground` + until it is the one on the stage. - **A session in a layout** carries the columns glyph before its corner slot in its project's sidebar. The layout's own sidebar draws none: every card there is in it. -- **A layout's sidebar**: the layout's name where New Session stands, then its sessions under each +- **A layout's sidebar**: the layout's name where New stands, then its sessions under each project's name in `TextXS` `MutedForeground`, in the same list of session, browser and editor rows, with their motion. No card there wears the active fill: the focused pane's header says which session has the keys, its name in `Foreground` and the others' in `MutedForeground`. A pane wears no frame for focus, only its 1px hairline. - **A pane's motion**: a pane new to the stage grows out of the edge it was split on in 200ms ease-out, and one that leaves shrinks back into it in 180ms ease-in, the neighbours giving and taking the room over the same time. A zoom, a divider and a change of tab move at once. -- **A group header** (a folder, the pinned block) is a row too, the same 34dp, so its hover lights as a - row's does: the glyph in the node's column, the uppercase label, its count, and space to the `⋯`. +- **A group header** (a folder, the pinned block) is a row too, the same 28dp, so its hover lights as a + row's does: the glyph in the node's column (`folder-open` over its rows, `folder` closed, the pin), the name as + typed in `TextXS` medium, its count muted, and the `⋯` in the corner slot, under the pointer as a row's is. + +The header is one row of `railHeaderRow` (32): New, its `+` in the node column and its label on the rows' names, +then the filter and collapse, each a 28px square. The corner slot (`cardSlotSize`, 22px, the mark's box) is always reserved, so nothing on the line moves when it fills: the `⋯` under the pointer or while its menu is open; at rest the session's status, else a pin on a @@ -1638,20 +1649,22 @@ folder's color at `tintRest`; a card painted the folder's color paints nothing a the tray's edges, clipped to its corners, so a lit row fills it to the end. A closed folder is its header alone, no tray. -### The Services footer +### The foot and the services + +The sidebar's foot is one line (`sidebar.foot`): the account's row, drawn on the rows' grid (the provider's mark, +the profile's name, its five-hour usage, the chevrons), and at its end the services' glyph, `server` in a 28px +square. With no account to show, the glyph keeps its place alone. A layout's sidebar has the same foot. -The project's services sit at the sidebar's foot, above the profile, in a place of their own: the sessions -scroll over them and they never move when a session opens (`sidebar_services.go`). Space parts them from the -list, then a header drawn as a folder's is (the services glyph in the node's column, turning to the fold's -chevron under the pointer, the SERVICES group label and its count in the tones, "2 running" in `TonePass` and -"1 failed" in `Destructive`, "3 stopped" muted when none does either, and space to the `⋯`), which opens -and closes the rows under it. Its `⋯` and right click hold Start all, Stop all and New service. A service is a +The glyph's ink is the services' state (`servicesInk`): `Destructive` once one failed, `TonePass` while any runs, +`MutedForeground` with none up; its tooltip counts them. A click opens them in a panel over the foot, as wide as +the line (`sidebar_services.go`): a row a service, then New service with Start all and Stop all at its end, each +there while it has something to do. A service is a row as a session is: its glyph where the mark sits, in its state's tone (`TonePass` while it is up, `Destructive` once it failed, `MutedForeground` while it is down), the name (`MutedForeground` while it is down), how long it has run at the end or its exit code in `Destructive`, and the corner slot, the `⋯` under the pointer and the souls spinner alone while it stops, with no word. No dot: the glyph is the state. No button on the row: its actions are its menu; a click shows its -console. The open list scrolls past `serviceRowsShown` rows. Adding a service and editing one happen in a dialog over the screen -(`settings_service_dialog.go`), from the footer's New service, a row's Edit or Settings › Services alike, +console. The list scrolls past `serviceRowsShown` rows. Adding a service and editing one happen in a dialog over the screen +(`settings_service_dialog.go`), from the panel's New service, a row's Edit or Settings › Services alike, whose rows open it on a click: the name in a narrow field beside the command, one line on how a command runs with the rest in a help glyph's tooltip, Start with lich as a switch, then Delete for a saved service that is down, Cancel and Save. @@ -1659,16 +1672,15 @@ down, Cancel and Save. ### The rail The collapsed sidebar is an island like the open one (`sidebar_rail.go`): `Sidebar`, `RadiusLG`, the same `Border` hairline, its content -on the 8px edge around a column as wide as a row is tall (34), so it is 50px wide and every node centres +on the 8px edge around a 34px column, so it is 50px wide and every node centres where it does in the open sidebar. Expand sits in a row of the open header's height -(36), where collapse sits in the open sidebar; new session, Services and the profile sit in its footer, so +(32), where collapse sits in the open sidebar; New, the filter, the services' glyph and the account sit in its footer, so the list starts where the open sidebar's does; blocks stand `Space(1.5)` apart as the open ones do, and every node keeps its place across the morph. The list is -the open one in one column: rows of the same 34dp, a folder or the pinned block led by its glyph, named in a +the open one in one column: rows of the same 28dp, a folder or the pinned block led by its glyph, named in a tooltip, a child's mark drawn smaller, and a folder on its tray, with no line between the nodes. A folded -block or mother keeps only its node. A session's mark is lit by a 32px square, `Accent` while active. A card drags in the rail as -in the open sidebar, and the filter is the open one's field and chips in a panel off the search button in -the footer; it outlives the panel, and the button stays lit with a dot while it narrows the tree. +block or mother keeps only its node. A session's row is lit whole, `Accent` while active. The filter's +button opens the sidebar with the keyboard in its field. ### The peek @@ -1743,4 +1755,5 @@ at once, whatever its row is still doing. only. - **Semantic color**: it carries meaning. - **Buttons do not move when pressed**; only their color changes. -- **A sidebar row is one line.** Pull request and changes stay on it; a name too long is cut, not wrapped. +- **A sidebar row is one line.** Its branch, pull request and changes are in its tooltip; a name too long is cut, + not wrapped. diff --git a/native/cmd/lich-native/model.go b/native/cmd/lich-native/model.go index 449705e5d..14aed64e8 100644 --- a/native/cmd/lich-native/model.go +++ b/native/cmd/lich-native/model.go @@ -746,7 +746,6 @@ type sessionView struct { web webView // what that browser shows, and where relay sessionRelay // Direction "" for none awaiting []string // the sessions its turn is blocked on, in one of lich's waits - tool sessionTool // Name "" outside a tool call reason string // what a waiting session is blocked on, "" for unsaid git backend.DiffStats base *backend.BaseStatus // nil without a base to stand against @@ -780,7 +779,6 @@ func (m *model) viewOf(p backend.Project, s backend.Session, now time.Time) sess shown := m.shownPath(p, s) age, aged := m.status.age(s.ID, now) idle, idled := m.status.idle(s.ID, now) - tool, _ := m.status.tool(s.ID) usage, _ := m.usage.get(s.ID) st, page := m.browsers.states[s.ID], m.pages[s.ID] web := webView{url: pageURL(st), title: pageTitle(st), headed: st.Headed, shown: page != nil, focused: page != nil && page.focused} @@ -795,7 +793,7 @@ func (m *model) viewOf(p backend.Project, s backend.Session, now time.Time) sess status: m.status.status(s.ID), unread: m.status.unread(s.ID), turn: m.status.turn(s.ID), age: age, aged: aged, idle: idle, idled: idled, agent: m.agent[s.ID], sandbox: m.sandbox[s.ID], git: m.git[shown], base: m.base[shown], pr: pr, prLink: prLink, prOthers: prOthers, branchPR: branchPR, forge: m.forges.peek(shown), - relay: m.relay[s.ID], awaiting: m.awaiting[s.ID], tool: tool, reason: m.status.reason(s.ID), browser: m.browsers.states[s.ID].Open, + relay: m.relay[s.ID], awaiting: m.awaiting[s.ID], reason: m.status.reason(s.ID), browser: m.browsers.states[s.ID].Open, profileName: m.profileNameOf(s.Kind, s.Profile), continueIn: m.continueTargets(s.Kind, s.Profile), split: split, running: usage.Model, } diff --git a/native/cmd/lich-native/prbadge.go b/native/cmd/lich-native/prbadge.go index 60d132ba2..cba1249f7 100644 --- a/native/cmd/lich-native/prbadge.go +++ b/native/cmd/lich-native/prbadge.go @@ -64,8 +64,7 @@ func prLookOf(th *ui.Theme, pr *backend.PullRequest, forge string) prLook { return l } -// prBadge draws a session's pull request in its tooltip and on its chat -// composer's line, its number in size, a link before it when it was linked by +// prBadge draws a session's pull request on its chat composer's line, its number in size, a link before it when it was linked by // hand; logo is the ink of the forge's logo and the link, which the composer // brightens on hover. func prBadge(gtx C, th *ui.Theme, sv *sessionView, logo color.NRGBA, size unit.Sp) D { diff --git a/native/cmd/lich-native/prbadge_test.go b/native/cmd/lich-native/prbadge_test.go index 88f6a2116..21ac3d931 100644 --- a/native/cmd/lich-native/prbadge_test.go +++ b/native/cmd/lich-native/prbadge_test.go @@ -97,8 +97,9 @@ func TestTheTooltipDrawsEachPRState(t *testing.T) { const longBranch = "feat/sidebar-pull-request-badge-closed-state-and-then-some-more-words-past-the-edge" -// A branch longer than the tooltip is wide wraps on a line of its own, and -// the pull request and the changes stand whole on the line under it. +// A branch longer than the tooltip is wide wraps rather than being cut, with +// the changes whole at its line's end and the pull request on the line under it +// (contract changed: the changes were on the pull request's line). func TestTheTooltipKeepsTheBranchWholeOnItsLine(t *testing.T) { width := 240 // drop is how far under the branch's first line the pull request stands @@ -108,8 +109,8 @@ func TestTheTooltipKeepsTheBranchWholeOnItsLine(t *testing.T) { r := newFrameRig(image.Pt(width, 300), func(gtx C, th *ui.Theme) { sessionTooltip(th, &sv)(gtx) }) r.frame() number, added := labelBox(t, r, "#1199"), labelBox(t, r, "+10") - if added.Min.Y != number.Min.Y || added.Min.X <= number.Min.X { - t.Errorf("%s: +10 at %v, want the changes after #1199 (%v) on its line", branch, added, number) + if name := labelBox(t, r, branch); added.Min.X <= name.Min.X || added.Min.Y >= number.Min.Y { + t.Errorf("%s: +10 at %v, want the changes after the branch (%v), over #1199 (%v)", branch, added, name, number) } if number.Min.X > width/2 { t.Errorf("%s: #1199 at %v, want it at the start of its line", branch, number) diff --git a/native/cmd/lich-native/services_shot.go b/native/cmd/lich-native/services_shot.go index 538184630..1d3a179c2 100644 --- a/native/cmd/lich-native/services_shot.go +++ b/native/cmd/lich-native/services_shot.go @@ -2,14 +2,10 @@ package main import "flag" -var ( - flagServicesOpen = flag.Bool("services-open", false, "open the sidebar's Services footer at start, for -shot") - flagServiceConsole = flag.String("service-console", "", "open this service's console (its id) at start, for -shot") -) +var flagServiceConsole = flag.String("service-console", "", "open this service's console (its id) at start, for -shot") -// servicesShot puts the Services footer and a console where the flags ask. +// servicesShot puts a console where the flag asks. func (u *window) servicesShot() { - u.sidebar.services.open = *flagServicesOpen if *flagServiceConsole != "" { u.model.openConsole(*flagServiceConsole) } diff --git a/native/cmd/lich-native/services_test.go b/native/cmd/lich-native/services_test.go index f2f9df0c0..a2788f489 100644 --- a/native/cmd/lich-native/services_test.go +++ b/native/cmd/lich-native/services_test.go @@ -1,12 +1,15 @@ package main import ( + "image" "image/color" "slices" "strings" "testing" "time" + "gioui.org/f32" + "github.com/lichdotdev/lich/api" "github.com/lichdotdev/lich/native/backend" "github.com/lichdotdev/lich/native/i18n" @@ -40,15 +43,6 @@ func TestTallyCountsUpAndFailed(t *testing.T) { if got != (servicesTally{up: 1, total: 3, failed: 1}) { t.Errorf("tally = %+v", got) } - if op := allServicesOp(servicesTally{up: 3, total: 3}); op != serviceStopAll { - t.Errorf("all up: op %d, want stop all", op) - } - if op := allServicesOp(servicesTally{up: 1, total: 3}); op != serviceStartAll { - t.Errorf("some down: op %d, want start all", op) - } - if op := allServicesOp(servicesTally{}); op != serviceStartAll { - t.Errorf("none: op %d", op) - } } func TestServiceStateTextSaysHowItRunsOrEnded(t *testing.T) { @@ -167,40 +161,57 @@ func TestGlobalServicesAreHomes(t *testing.T) { } } -func TestTheServicesHeaderOffersWhatTheTallyAllows(t *testing.T) { - labels := func(tally servicesTally) []string { - var out []string - for _, e := range servicesEntries(tally, "p", new(sidebarAction)) { - if e.Kind == ui.MenuSeparator { - out = append(out, "-") - continue - } - out = append(out, e.Label) - } - return out - } - start, stop, add := i18n.T("sidebar.services.startAll"), i18n.T("sidebar.services.stopAll"), i18n.T("sidebar.services.newService") +// The foot's glyph opens the panel (contract changed: a menu on a header of its +// own held these), which offers on all the services what they allow. +func TestTheServicesPanelOffersWhatTheTallyAllows(t *testing.T) { cases := []struct { tally servicesTally - want []string + want []serviceOp }{ - {servicesTally{}, []string{add}}, - {servicesTally{up: 0, total: 2}, []string{start, "-", add}}, - {servicesTally{up: 1, total: 2}, []string{start, stop, "-", add}}, - {servicesTally{up: 2, total: 2}, []string{stop, "-", add}}, + {servicesTally{}, nil}, + {servicesTally{up: 0, total: 2}, []serviceOp{serviceStartAll}}, + {servicesTally{up: 1, total: 2}, []serviceOp{serviceStartAll, serviceStopAll}}, + {servicesTally{up: 2, total: 2}, []serviceOp{serviceStopAll}}, } for _, c := range cases { - if got := labels(c.tally); !slices.Equal(got, c.want) { - t.Errorf("tally %+v: menu %v, want %v", c.tally, got, c.want) + if got := allServicesOps(c.tally); !slices.Equal(got, c.want) { + t.Errorf("tally %+v: offers %v, want %v", c.tally, got, c.want) } } + s := newSidebar(&ui.Root{}) var act sidebarAction - servicesEntries(servicesTally{total: 1}, "p", &act)[0].OnClick() + list := []backend.Service{svc("web", "p", api.ServiceStopped)} + r := newFrameRig(image.Pt(240, 200), func(gtx C, th *ui.Theme) { + s.services.panelContent(gtx, th, s.root, "p", list, "", &act) + }) + r.frame() + if !r.shows("web") || !r.shows(i18n.T("sidebar.services.newService")) { + t.Fatalf("the panel drew %s", r.drawn()) + } + r.click(t, r.at(t, i18n.T("sidebar.services.newService"))) + if act.service != (serviceRequest{op: serviceAdd, project: "p"}) { + t.Errorf("New service asked %+v", act.service) + } + act = sidebarAction{} + // Start all ends the row under the one service's. + r.click(t, f32.Pt(228, 42)) if act.service != (serviceRequest{op: serviceStartAll, project: "p"}) { t.Errorf("Start all asked %+v", act.service) } } +// The glyph's ink is the services' state, a failure before what still runs. +func TestTheServicesGlyphWearsTheirState(t *testing.T) { + th := &ui.Theme{Palette: ui.Dark} + for tally, want := range map[servicesTally]color.NRGBA{ + {}: th.MutedForeground, {total: 2}: th.MutedForeground, {up: 1, total: 2}: th.TonePass, {up: 1, failed: 1, total: 2}: th.Destructive, + } { + if got := servicesInk(th, tally); got != want { + t.Errorf("tally %+v: ink %v, want %v", tally, got, want) + } + } +} + func TestTheServiceDialogOpensOnTheSavedServiceOrANewOne(t *testing.T) { var s servicesStore saved := svc("a", "p1", api.ServiceStopped) diff --git a/native/cmd/lich-native/sessiontooltip.go b/native/cmd/lich-native/sessiontooltip.go index 35888ade3..0c27d57cc 100644 --- a/native/cmd/lich-native/sessiontooltip.go +++ b/native/cmd/lich-native/sessiontooltip.go @@ -26,40 +26,100 @@ var ( icBranch = icons.Lucide("git-branch") ) -// sessionTooltip is what the card's one line has no room for: the full label, -// what the turn is doing, the full path, the shield's symlinks left out, what -// a subagent card brought, the branch and its standing against the base when -// no checkout row above says them, and last the model the provider says it is running beside how long -// the status has lasted. +// tipWidth is the tooltip's content, the same for every session, so moving +// down the list never resizes it. +var tipWidth = ui.Space(64) + +// sessionTooltip is what the card's one line has no room for: the whole name +// with what the session is doing and for how long, then where it works (its +// branch and changes, its worktree's folder, its pull request and its standing +// against the base), what is out of the ordinary, and last its model. func sessionTooltip(th *ui.Theme, sv *sessionView) layout.Widget { th = th.On(th.Popover) - path := backend.IDOf(sv.shown) - if sv.host != "" { - path = unknownCwd(sv.host) - } - sections := []layout.Widget{th.Text(ui.TextXS, sv.Label).Weight(font.Medium).Layout} + head := []layout.Widget{tipTitle(th, sv)} if rung, ok := statusRung(th, sv); ok { - sections = append(sections, rung) + head = append(head, rung) } - sections = append(sections, para(th.Text(ui.TextXS, path).Muted().Mono()).Layout) + groups := []layout.Widget{ui.Stack(1, head...)} + add := func(widgets ...layout.Widget) { + if len(widgets) > 0 { + groups = append(groups, ui.Stack(1, widgets...)) + } + } + add(placeSections(th, sv)...) + add(conflictSections(th, sv.base)...) + var notes []layout.Widget if len(sv.sandbox.SkippedLinks) > 0 { - sections = append(sections, sandboxSection(th, sv.sandbox)) + notes = append(notes, sandboxSection(th, sv.sandbox)) } if len(sv.Brought) > 0 { - sections = append(sections, para(th.Text(ui.TextXS, broughtLine(sv.Brought)).Muted()).Layout) + notes = append(notes, para(th.Text(ui.TextXS, broughtLine(sv.Brought)).Muted()).Layout) } - if sv.git.Branch != "" { - sections = append(sections, branchSection(th, sv)) - if line, ok := prChangesSection(th, sv); ok { - sections = append(sections, line) + add(append(notes, scheduleTipSections(th, sv, time.Now())...)...) + if sv.running != "" { + add(modelSection(th, sv.Model, sv.running)) + } + return func(gtx C) D { + width := min(gtx.Dp(tipWidth), gtx.Constraints.Max.X) + gtx.Constraints.Min.X, gtx.Constraints.Max.X = width, width + return layout.Inset{Top: ui.Space(1), Bottom: ui.Space(1)}.Layout(gtx, ui.Stack(2, groups...)) + } +} + +// tipTitle is the tooltip's first line: the name, wrapped rather than cut, and +// the status in the corner. The tooltip is redrawn when its age changes. +func tipTitle(th *ui.Theme, sv *sessionView) layout.Widget { + return func(gtx C) D { + children := []layout.FlexChild{layout.Flexed(1, para(th.Text(ui.TextSM, sv.Label).Weight(font.Medium)).Layout)} + word, ink, age, aged := statusWord(th, sv) + if word != "" { + children = append(children, ui.Gap(2), layout.Rigid(th.Text(ui.TextXS, word).In(ink).Layout)) + } + if word != "" && aged { + children = append(children, ui.Gap(1.5), layout.Rigid(th.Text(ui.TextXS, formatAge(age)).Muted().Mono().Layout)) + gtx.Execute(op.InvalidateCmd{At: gtx.Now.Add(nextAgeChange(age))}) } + return layout.Flex{Alignment: layout.Baseline}.Layout(gtx, children...) } - sections = append(sections, baseSections(th, sv.base)...) - sections = append(sections, scheduleTipSections(th, sv, time.Now())...) - if sv.running != "" || sv.aged { - sections = append(sections, footLine(th, sv)) +} + +// placeSections are the lines of where the session works. +func placeSections(th *ui.Theme, sv *sessionView) []layout.Widget { + var out []layout.Widget + if sv.git.Branch != "" { + out = append(out, branchSection(th, sv)) + } + if folder := tipFolder(sv); folder != "" { + line := para(th.Text(ui.TextXS, folder).Muted().Mono()) + out = append(out, func(gtx C) D { + return ui.IconLine(gtx, icGroupFolder, th.MutedForeground, layout.Flexed(1, line.Layout)) + }) } - return func(gtx C) D { return ui.Stack(1.5, sections...)(gtx) } + if line, ok := prBaseSection(th, sv); ok { + out = append(out, line) + } + return out +} + +// tipFolder is the folder to name: the worktree's own, the subfolder the +// session went into, or the whole path once it left its checkout. "" for a +// session at the root of the project, which the tab already names. +func tipFolder(sv *sessionView) string { + root := "" + if sv.Path != "" { + root = baseName(sv.path) + } + switch { + case sv.host != "": + return unknownCwd(sv.host) + case sv.shown == "" || sv.shown == sv.path: + return root + } + sub, inside := strings.CutPrefix(sv.shown, sv.path) + if !inside || sv.path == "" || !strings.ContainsAny(sub[:1], `/\`) { + return backend.IDOf(sv.shown) + } + return strings.TrimLeft(root+sub, `/\`) } // broughtLine names what a subagent card brought of the user's setup, by @@ -86,24 +146,6 @@ func para(l ui.LabelStyle) ui.LabelStyle { return l } -// footLine is the tooltip's last line: the model the provider runs and, in -// the corner, how long the status has lasted while it has a clock. The -// tooltip is redrawn when that reading changes. -func footLine(th *ui.Theme, sv *sessionView) layout.Widget { - return func(gtx C) D { - model := func(gtx C) D { return D{Size: gtx.Constraints.Min} } - if sv.running != "" { - model = modelSection(th, sv.Model, sv.running) - } - children := []layout.FlexChild{layout.Flexed(1, model)} - if sv.aged { - children = append(children, ui.Gap(1.5), layout.Rigid(th.Text(ui.TextXS, formatAge(sv.age)).Muted().Layout)) - gtx.Execute(op.InvalidateCmd{At: gtx.Now.Add(nextAgeChange(sv.age))}) - } - return layout.Flex{Alignment: layout.Middle}.Layout(gtx, children...) - } -} - // sandboxSection names what a confined session's sandbox left out of its home // for being a symlink. func sandboxSection(th *ui.Theme, s sandboxEvent) layout.Widget { @@ -111,24 +153,31 @@ func sandboxSection(th *ui.Theme, s sandboxEvent) layout.Widget { return func(gtx C) D { return ui.IconLine(gtx, icSandboxed, line.Color, layout.Flexed(1, para(line).Layout)) } } -// branchSection is the branch alone on its line, wrapped rather than cut. +// branchSection is the branch, wrapped rather than cut, and the checkout's +// changes at its line's end. func branchSection(th *ui.Theme, sv *sessionView) layout.Widget { - muted := para(th.Text(ui.TextXS, sv.git.Branch).Muted()) - return func(gtx C) D { return ui.IconLine(gtx, icBranch, muted.Color, layout.Rigid(muted.Layout)) } + children := []layout.FlexChild{layout.Flexed(1, para(th.Text(ui.TextXS, sv.git.Branch).Mono()).Layout)} + if sv.git.Files > 0 { + children = append(children, ui.Gap(2), layout.Rigid(th.DiffStat(sv.git.Added, sv.git.Deleted).Layout)) + } + return func(gtx C) D { return ui.IconLine(gtx, icBranch, th.MutedForeground, children...) } } -// prChangesSection is the line under the branch: its pull request, then the -// checkout's changes. ok is false when there is neither. -func prChangesSection(th *ui.Theme, sv *sessionView) (layout.Widget, bool) { +// prBaseSection is the session's pull request, then how far its branch is +// behind the base. ok is false when there is neither. +func prBaseSection(th *ui.Theme, sv *sessionView) (layout.Widget, bool) { var children []layout.FlexChild - if sv.pr != nil && sv.prForge() != "" { - children = append(children, layout.Rigid(func(gtx C) D { return prBadge(gtx, th, sv, th.MutedForeground, ui.TextXS) })) + if sv.git.Branch != "" && sv.pr != nil && sv.prForge() != "" { + l := prLookOf(th, sv.pr, sv.prForge()) + children = append(children, layout.Rigid(func(gtx C) D { return l.glyph.Layout(gtx, 12, l.tone) }), ui.Gap(1.5), + layout.Rigid(th.Text(ui.TextXS, l.number).In(l.tone).Layout)) } - if sv.git.Files > 0 { + if b := sv.base; b != nil && b.Behind > 0 { if len(children) > 0 { children = append(children, ui.Gap(2)) } - children = append(children, layout.Rigid(func(gtx C) D { return th.DiffStat(sv.git.Added, sv.git.Deleted).Layout(gtx) })) + behind := para(th.Text(ui.TextXS, i18n.T("git.baseStatus.behind", i18n.Args{"count": b.Behind, "base": b.Base})).Muted()) + children = append(children, layout.Flexed(1, behind.Layout)) } if len(children) == 0 { return nil, false @@ -136,24 +185,17 @@ func prChangesSection(th *ui.Theme, sv *sessionView) (layout.Widget, bool) { return func(gtx C) D { return layout.Flex{Alignment: layout.Middle}.Layout(gtx, children...) }, true } -// baseSections spell out the base readout: commits behind the -// named base, then the conflict, then the first files it is in. -func baseSections(th *ui.Theme, b *backend.BaseStatus) []layout.Widget { - if b == nil { +// conflictSections are the files a merge of the base would collide on now: how +// many, then the first of them. +func conflictSections(th *ui.Theme, b *backend.BaseStatus) []layout.Widget { + if b == nil || len(b.Conflicts) == 0 { return nil } - var out []layout.Widget - if b.Behind > 0 { - out = append(out, para(th.Text(ui.TextXS, i18n.T("git.baseStatus.behind", i18n.Args{"count": b.Behind, "base": b.Base})).Muted()).Layout) - } - if n := len(b.Conflicts); n > 0 { - line := th.Text(ui.TextXS, i18n.T("git.baseStatus.conflict", i18n.Args{"count": n})).In(th.ToneWait) - out = append(out, - func(gtx C) D { return ui.IconLine(gtx, icConflict, line.Color, layout.Flexed(1, line.Layout)) }, - conflictPaths(th, b.Conflicts), - ) + line := th.Text(ui.TextXS, i18n.T("git.baseStatus.conflict", i18n.Args{"count": len(b.Conflicts)})).In(th.ToneWait) + return []layout.Widget{ + func(gtx C) D { return ui.IconLine(gtx, icConflict, line.Color, layout.Flexed(1, line.Layout)) }, + conflictPaths(th, b.Conflicts), } - return out } // modelRun is a stretch of the model line; name marks a model name set inside @@ -222,7 +264,7 @@ func conflictPaths(th *ui.Theme, paths []string) layout.Widget { rows = append(rows, th.Text(ui.TextXS, i18n.T("sidebar.sessionTooltip.morePaths", i18n.Args{"count": more})).Muted().Layout) } return func(gtx C) D { - return layout.Inset{Left: ui.Space(4)}.Layout(gtx, func(gtx C) D { return ui.Stack(0.5, rows...)(gtx) }) + return layout.Inset{Left: ui.Space(4.5)}.Layout(gtx, ui.Stack(0.5, rows...)) } } diff --git a/native/cmd/lich-native/sessiontooltip_test.go b/native/cmd/lich-native/sessiontooltip_test.go index ec94cf7da..1389e89af 100644 --- a/native/cmd/lich-native/sessiontooltip_test.go +++ b/native/cmd/lich-native/sessiontooltip_test.go @@ -1,8 +1,13 @@ package main import ( + "image" "reflect" "testing" + "time" + + "github.com/lichdotdev/lich/native/backend" + "github.com/lichdotdev/lich/native/ui" ) func TestModelRuns(t *testing.T) { @@ -29,3 +34,80 @@ func TestModelRuns(t *testing.T) { } } } + +func TestTheTooltipNamesTheFolderOnlyAwayFromTheProjectsOwn(t *testing.T) { + at := func(stored, shown string) sessionView { + sv := sessionView{path: "/src/app", shown: shown} + if stored != "" { + sv.Path, sv.path = stored, stored + } + return sv + } + for _, c := range []struct { + sv sessionView + want string + }{ + {at("", "/src/app"), ""}, + {at("", "/src/app/internal/api"), "internal/api"}, + {at("", "/src/app-two"), "/src/app-two"}, + {at("", "/tmp"), "/tmp"}, + {at("/wt/queue", "/wt/queue"), "queue"}, + {at("/wt/queue", "/wt/queue/native"), "queue/native"}, + {at(`C:\wt\queue`, `C:\wt\queue\native`), `queue\native`}, + } { + if got := tipFolder(&c.sv); got != c.want { + t.Errorf("stored %q shown %q: folder %q, want %q", c.sv.Path, c.sv.shown, got, c.want) + } + } +} + +func TestTheTooltipSaysWhatTheSessionIsDoing(t *testing.T) { + th := &ui.Theme{Palette: ui.Dark} + shell := sessionView{Kind: "shell"} + for _, c := range []struct { + sv sessionView + word string + age time.Duration + }{ + {sessionView{status: statusBusy, age: 42 * time.Second, aged: true}, "Working", 42 * time.Second}, + {sessionView{status: statusWaiting, age: 3 * time.Minute, aged: true}, "Waiting on you", 3 * time.Minute}, + {sessionView{status: statusDone, unread: true, idle: time.Minute, idled: true}, "Done", time.Minute}, + {sessionView{status: statusDone, idle: 2 * time.Hour, idled: true}, "Idle", 2 * time.Hour}, + {sessionView{}, "Idle", 0}, + {shell, "", 0}, + } { + word, _, age, aged := statusWord(th, &c.sv) + if word != c.word || age != c.age || aged != (c.age > 0) { + t.Errorf("%q: says %q for %v (%v), want %q for %v", c.sv.status, word, age, aged, c.word, c.age) + } + } +} + +// The row marks a session off the project's base branch with a glyph, and the +// branch's name is the tooltip's alone. +func TestTheRowMarksASessionOffTheBaseBranch(t *testing.T) { + base := &backend.BaseStatus{Base: "origin/main"} + worktree := backend.Session{Path: "/wt/queue"} + for _, c := range []struct { + name string + sv sessionView + want bool + }{ + {"on main", sessionView{git: backend.DiffStats{Branch: "main"}, base: base}, false}, + {"another branch", sessionView{git: backend.DiffStats{Branch: "feat"}, base: base}, true}, + {"no remote to tell", sessionView{git: backend.DiffStats{Branch: "feat"}}, false}, + {"a worktree", sessionView{Session: worktree, git: backend.DiffStats{Branch: "feat"}}, true}, + {"no repository", sessionView{Session: worktree}, false}, + } { + if got := c.sv.offBase(); got != c.want { + t.Errorf("%s: off the base %v, want %v", c.name, got, c.want) + } + s := newSidebar(&ui.Root{}) + c.sv.Label = "Docs" + r := newFrameRig(image.Pt(300, 40), func(gtx C, th *ui.Theme) { s.cardBody(gtx, th, &c.sv, nil, false) }) + r.frame() + if b := c.sv.git.Branch; b != "" && r.shows(b) { + t.Errorf("%s: the row drew the branch's name", c.name) + } + } +} diff --git a/native/cmd/lich-native/sidebar.go b/native/cmd/lich-native/sidebar.go index 14b5efaf1..e1c312006 100644 --- a/native/cmd/lich-native/sidebar.go +++ b/native/cmd/lich-native/sidebar.go @@ -342,14 +342,8 @@ func (s *sidebar) panel(gtx C, th *ui.Theme, m *model, active string) (D, sideba } return s.blockList(gtx, on, view, active, &act) })) - if p, ok := m.project(); ok && !split { - list, console := m.services.of(p.ID), m.consoleShown() - children = append(children, ui.VGap(2), layout.Rigid(func(gtx C) D { - return s.services.layout(gtx, on, s.root, p.ID, list, console, &act) - })) - } - if a, ok := s.profile.account(m); ok { - children = append(children, ui.VGap(2), layout.Rigid(func(gtx C) D { return s.profile.layout(gtx, on, s.root, m, a, &act) })) + if p, ok := m.project(); ok { + children = append(children, ui.VGap(2), layout.Rigid(func(gtx C) D { return s.foot(gtx, on, m, p.ID, &act) })) } return layout.Flex{Axis: layout.Vertical}.Layout(gtx, children...) }) @@ -358,6 +352,25 @@ func (s *sidebar) panel(gtx C, th *ui.Theme, m *model, active string) (D, sideba return D{Size: size}, act } +// foot is the panel's last line: the account's row and, at its end, the +// services' glyph, each with a panel as wide as the line. +func (s *sidebar) foot(gtx C, th *ui.Theme, m *model, projectID string, act *sidebarAction) D { + width := gtx.Metric.PxToDp(gtx.Constraints.Max.X) + over := func(p ui.DropdownPanelStyle) ui.DropdownPanelStyle { + p.AlignEnd = true + return p.Above() + } + account := func(gtx C) D { return D{Size: image.Pt(gtx.Constraints.Min.X, 0)} } + if a, ok := s.profile.account(m); ok { + account = func(gtx C) D { return s.profile.layout(gtx, th, s.root, m, a, act, width) } + } + return layout.Flex{Alignment: layout.Middle}.Layout(gtx, + layout.Flexed(1, account), + ui.Gap(1), + layout.Rigid(func(gtx C) D { return s.services.button(gtx, th, s, m, projectID, ui.SideTop, width, over, act) }), + ) +} + // resizeHandle lays the resize strip out in the gap between the panel and // the stage. func (s *sidebar) resizeHandle(gtx C, panel image.Point) { diff --git a/native/cmd/lich-native/sidebar_browser_row.go b/native/cmd/lich-native/sidebar_browser_row.go index daa403c4a..1e08bad9f 100644 --- a/native/cmd/lich-native/sidebar_browser_row.go +++ b/native/cmd/lich-native/sidebar_browser_row.go @@ -136,7 +136,7 @@ func (s *sidebar) browserRow(gtx C, th *ui.Theme, r sessionRow, b blockView, act }) }), ) - return layout.Inset{Top: ui.Space(1.5), Bottom: ui.Space(1.5), Left: rowInset, Right: ui.Space(1)}.Layout(gtx, func(gtx C) D { + return treeRowInset.Layout(gtx, func(gtx C) D { return layout.Flex{Alignment: layout.Middle}.Layout(gtx, row...) }) } diff --git a/native/cmd/lich-native/sidebar_card.go b/native/cmd/lich-native/sidebar_card.go index 12832acdc..594d67d0c 100644 --- a/native/cmd/lich-native/sidebar_card.go +++ b/native/cmd/lich-native/sidebar_card.go @@ -183,8 +183,8 @@ func (s *sidebar) renaming(id string) bool { } // cardBody is the card's one line: its place in the tree, the title row, a -// folded mother's count and the checkout's changes -// unless a checkout row above shows them, then the corner slot. +// folded mother's count, the branch glyph of a session off the project's base +// branch, whose name is the tooltip's, then the corner slot. func (s *sidebar) cardBody(gtx C, th *ui.Theme, sv *sessionView, more layout.Widget, hovered bool) D { gtx.Constraints.Min.X = gtx.Constraints.Max.X sv.place.hot = hovered && sv.place.kids > 0 @@ -193,12 +193,8 @@ func (s *sidebar) cardBody(gtx C, th *ui.Theme, sv *sessionView, more layout.Wid row = append(row, ui.Gap(1.5)) row = append(row, foldedCount(th, sv.place.kids, sv.place.mark)...) } - if b := sv.git.Branch; b != "" && !sv.place.branchSaid { - most := gtx.Constraints.Max.X * branchShare / 100 - row = append(row, ui.Gap(1.5), layout.Rigid(func(gtx C) D { - gtx.Constraints.Max.X = min(gtx.Constraints.Max.X, most) - return th.Text(ui.TextXS, b).Muted().Mono().Layout(gtx) - })) + if sv.offBase() && !sv.place.branchSaid { + row = append(row, ui.Gap(1.5), layout.Rigid(func(gtx C) D { return icBranch.Layout(gtx, 12, th.MutedForeground) })) } if sv.idled { row = append(row, ui.Gap(1.5), layout.Rigid(func(gtx C) D { @@ -216,7 +212,7 @@ func (s *sidebar) cardLine(gtx C, th *ui.Theme, sv *sessionView, more layout.Wid row = append(row, ui.Gap(1.5), layout.Rigid(func(gtx C) D { return icSplit.Layout(gtx, 12, th.MutedForeground) })) } row = append(row, ui.Gap(1), layout.Rigid(func(gtx C) D { return s.cardSlot(gtx, th, sv, more, hovered) })) - return layout.Inset{Top: ui.Space(1.5), Bottom: ui.Space(1.5), Left: rowInset, Right: ui.Space(1)}.Layout(gtx, func(gtx C) D { + return treeRowInset.Layout(gtx, func(gtx C) D { return layout.Flex{Alignment: layout.Middle}.Layout(gtx, row...) }) } @@ -253,6 +249,15 @@ func (s *sidebar) titleRow(th *ui.Theme, sv *sessionView) []layout.FlexChild { return append(row, layout.Flexed(1, th.Text(ui.TextSM, sv.Label).Weight(font.Medium).Layout)) } +// offBase is a session in a worktree of its own, or whose checkout is on +// another branch than the one the project merges into. +func (sv *sessionView) offBase() bool { + if sv.git.Branch == "" { + return false + } + return sv.Path != "" || sv.base != nil && sv.git.Branch != strings.TrimPrefix(sv.base.Base, "origin/") +} + // renameField is the label as a field while the card is being renamed. func (s *sidebar) renameField(gtx C, th *ui.Theme, id string, rename *ui.InlineEdit) D { field := th.InlineEdit(rename, ui.TextSM).Weight(font.Medium) @@ -289,10 +294,6 @@ func (s *sidebar) cardSlot(gtx C, th *ui.Theme, sv *sessionView, more layout.Wid // spinner it holds while the session works stays clear of the branch. var cardSlotSize = 2 * sessionTreeRingR -// branchShare is the most of a row's width, in percent, its branch takes: the -// label is what the row is scanned for. -const branchShare = 35 - // statusRing is SessionStatusIcon: the provider mark (the agent live in the // PTY, else the session's kind) in a ring that spins while busy, is amber // when waiting on the user and emerald when done, faded once that turn is diff --git a/native/cmd/lich-native/sidebar_card_test.go b/native/cmd/lich-native/sidebar_card_test.go index 8b6193a25..be6a610ad 100644 --- a/native/cmd/lich-native/sidebar_card_test.go +++ b/native/cmd/lich-native/sidebar_card_test.go @@ -26,7 +26,7 @@ func TestCardIsOneLineInEveryState(t *testing.T) { idle := sessionView{ID: "s1", Label: "Docs", shown: "/home/me/repo", git: backend.DiffStats{Branch: "main"}} rest := cardBodyHeight(idle, false) busy := idle - busy.status, busy.tool = statusBusy, sessionTool{Name: "Bash", Detail: "go test ./..."} + busy.status = statusBusy waiting := idle waiting.status = statusWaiting pinned := idle @@ -38,7 +38,7 @@ func TestCardIsOneLineInEveryState(t *testing.T) { sv sessionView hovered bool }{ - "tool": {busy, false}, "waiting": {waiting, false}, "pinned": {pinned, true}, "hovered": {idle, true}, "pr and diff": {git, false}, + "busy": {busy, false}, "waiting": {waiting, false}, "pinned": {pinned, true}, "hovered": {idle, true}, "pr and diff": {git, false}, } for name, c := range cases { if got := cardBodyHeight(c.sv, c.hovered); got != rest { diff --git a/native/cmd/lich-native/sidebar_editor_row.go b/native/cmd/lich-native/sidebar_editor_row.go index e787660e3..c5e9cc025 100644 --- a/native/cmd/lich-native/sidebar_editor_row.go +++ b/native/cmd/lich-native/sidebar_editor_row.go @@ -78,7 +78,10 @@ func (s *sidebar) editorRow(gtx C, th *ui.Theme, r sessionRow, b blockView, act layout.Flexed(1, func(gtx C) D { return layout.Flex{Alignment: layout.Middle}.Layout(gtx, layout.Flexed(1, func(gtx C) D { - l := th.Text(ui.TextSM, n.name()).Mono() + l := th.Text(ui.TextSM, n.name()) + if !n.shown { + l = l.Muted() + } l.MaxLines = 1 return l.Layout(gtx) }), @@ -96,7 +99,7 @@ func (s *sidebar) editorRow(gtx C, th *ui.Theme, r sessionRow, b blockView, act return D{Size: image.Pt(size, size)} }), ) - return layout.Inset{Top: ui.Space(1.5), Bottom: ui.Space(1.5), Left: rowInset, Right: ui.Space(1)}.Layout(gtx, func(gtx C) D { + return treeRowInset.Layout(gtx, func(gtx C) D { return layout.Flex{Alignment: layout.Middle}.Layout(gtx, row...) }) } diff --git a/native/cmd/lich-native/sidebar_foot_test.go b/native/cmd/lich-native/sidebar_foot_test.go new file mode 100644 index 000000000..af0c876ee --- /dev/null +++ b/native/cmd/lich-native/sidebar_foot_test.go @@ -0,0 +1,135 @@ +package main + +import ( + "image" + "testing" + "time" + + "gioui.org/f32" + + "github.com/lichdotdev/lich/api" + "github.com/lichdotdev/lich/native/backend" + "github.com/lichdotdev/lich/native/ui" +) + +// fullSidebar is the open sidebar of a project with sessions in and out of +// folders, its services and an account, on a 600px window. +func fullSidebar(t *testing.T) (*sidebar, *model, *frameRig, *sidebarAction) { + t.Helper() + _, m, _ := profileFooterRig(t) + child := backend.Session{ID: "child", Label: "Review the queue", Kind: codexKind, Path: "/wt/queue", OriginSessionID: "queue"} + m.mu.Lock() + m.projects[0].Path = "/src/lich" + m.projects[0].Sessions = []backend.Session{ + {ID: "pin", Label: "Plan the release", Kind: claudeKind, Pinned: true}, + {ID: "lsp", Label: "Fix the LSP hover", Kind: claudeKind, Path: "/wt/lsp-hover"}, + {ID: "queue", Label: "Queue messages", Kind: claudeKind, Path: "/wt/queue"}, child, + {ID: "docs", Label: "Docs", Kind: "opencode"}, + {ID: "log", Label: "Changelog", Kind: "kiro", Folder: "Release", Color: "green", Path: "/wt/log"}, + {ID: "tr", Label: "Translate", Kind: "antigravity", Folder: "Release", Color: "green"}, + {ID: "later", Label: "Later on", Kind: claudeKind, Folder: "Later"}, + } + m.active = "lsp" + m.folds[foldKey("p", folderKey("Later"))] = true + now := time.Now() + m.git["/wt/lsp-hover"] = backend.DiffStats{Branch: "fix/lsp", Files: 2, Added: 7, Deleted: 1} + m.git["/wt/queue"] = backend.DiffStats{Branch: "feat/queue", Files: 3, Added: 120, Deleted: 14} + m.git["/wt/log"] = backend.DiffStats{Branch: "feat/changelog"} + m.git["/src/lich"] = backend.DiffStats{Branch: "main"} + m.base["/wt/lsp-hover"] = &backend.BaseStatus{Base: "origin/main", Behind: 4, Conflicts: []string{"CHANGELOG.md", "native/DESIGN.md"}} + m.mu.Unlock() + reportStatus(m, "lsp", statusWaiting) + reportStatus(m, "queue", statusBusy) + m.services.set("", []backend.Service{ + {ID: "web", ProjectID: "p", Name: "web", State: api.ServiceRunning, StartedAt: now.Add(-12 * time.Minute).UnixMilli()}, + {ID: "worker", ProjectID: "p", Name: "worker", State: api.ServiceStopped}, + }) + root := new(ui.Root) + s := newSidebar(root) + m.quota.seed(profileQuotaKey(m.profiles.provider, personalProfile), []backend.QuotaPlan{quotaPlan(backend.QuotaWindow{Label: "Session", Seconds: 5 * hour, Percent: 72})}) + s.open, s.widthRem = true, 15 + act := new(sidebarAction) + r := newFrameRig(image.Pt(600, 640), func(gtx C, th *ui.Theme) { + s.morph.advance(gtx) + root.Layout(gtx, func(gtx C) D { + if _, a := s.layout(gtx, th, m, "lsp"); a.service.op != serviceNone { + *act = a + } + return D{Size: gtx.Constraints.Max} + }) + s.morph.capture(gtx.Ops) + }) + r.now = now + drawFrames(r) + return s, m, r, act +} + +// drawFrames draws a few frames: a working session's spinner never goes still, +// so settle would wait for ever. +func drawFrames(r *frameRig) { + for range 4 { + r.now = r.now.Add(200 * time.Millisecond) + r.frame() + } +} + +// The services are one glyph at the end of the foot, and their panel stands +// over the line, as wide as it. +func TestTheSidebarsFootOpensTheServices(t *testing.T) { + s, _, r, act := fullSidebar(t) + writeShot(t, r, "sidebar.png") + if r.shows("web") { + t.Fatal("a service's row shows with the panel shut") + } + r.click(t, f32.Pt(218, 615)) + r.now = r.now.Add(time.Second) + drawFrames(r) + writeShot(t, r, "sidebar-services.png") + if !s.services.panel.Opened() || !r.shows("web") || !r.shows("worker") { + t.Fatalf("a click on the glyph opened no services: %s", r.drawn()) + } + if box := s.services.panel.Box(); box.Min.X != 8 || box.Max.X != 232 || box.Max.Y > 601 { + t.Errorf("the panel stands at %v, want it over the foot from 8 to 232", box) + } + r.click(t, r.at(t, "web")) + if act.service != (serviceRequest{op: serviceShow, id: "web"}) || s.services.panel.Opened() { + t.Errorf("a click on web asked %+v, panel open %v", act.service, s.services.panel.Opened()) + } +} + +// The rail's filter opens the sidebar with the keyboard in the field. +func TestTheRailsFilterOpensTheSidebarOnIt(t *testing.T) { + s, _, r, _ := fullSidebar(t) + s.open = false + drawFrames(r) + writeShot(t, r, "sidebar-rail.png") + r.click(t, f32.Pt(25, 562)) + r.now = r.now.Add(time.Second) + drawFrames(r) + if !s.open || !s.header.open || !r.router.Source().Focused(&s.header.query) { + t.Errorf("open %v, filter %v, focused %v: want all", s.open, s.header.open, r.router.Source().Focused(&s.header.query)) + } + writeShot(t, r, "sidebar-filter.png") +} + +// A card's tooltip says where the session works once the pointer rests on it. +func TestACardsTooltipSaysWhereItWorks(t *testing.T) { + _, _, r, _ := fullSidebar(t) + for _, c := range []struct { + card, shot string + says []string + }{ + {"Fix the LSP hover", "sidebar-tip-conflict.png", []string{"Waiting on you", "fix/lsp", "lsp-hover", "+7", "4 commits behind origin/main", "CHANGELOG.md"}}, + {"Queue messages", "sidebar-tip.png", []string{"Working", "feat/queue", "queue", "+120"}}, + } { + r.hover(r.at(t, c.card)) + r.now = r.now.Add(2 * time.Second) + drawFrames(r) + for _, want := range c.says { + if !r.shows(want) { + t.Errorf("%s: the tooltip leaves out %q", c.card, want) + } + } + writeShot(t, r, c.shot) + } +} diff --git a/native/cmd/lich-native/sidebar_group_header.go b/native/cmd/lich-native/sidebar_group_header.go index 0ebaada3c..2ecd668a9 100644 --- a/native/cmd/lich-native/sidebar_group_header.go +++ b/native/cmd/lich-native/sidebar_group_header.go @@ -9,6 +9,7 @@ import ( "gioui.org/font" "gioui.org/layout" + "gioui.org/op/paint" "gioui.org/unit" "github.com/lichdotdev/lich/native/i18n" "github.com/lichdotdev/lich/native/ui" @@ -18,11 +19,10 @@ import ( // ui.Text2XS sets no line height, so a 16px line is taken for the row. const text2XSLeading unit.Sp = 16 -// The header's tints: the title's opacity, a folder's name's, the count's, -// the drop target's fill and a refusing header's opacity. +// The header's tints: its glyph's opacity, its name's, the drop target's fill +// and a refusing header's opacity. const ( headerTitleOpacity = 0.7 - headerCountOpacity = 0.6 folderTitleOpacity = 0.85 headerDropFill = 0.15 headerRefuseOpacity = 0.45 @@ -44,10 +44,19 @@ func aroundValue(key, placeholder string, rest ...i18n.Args) (before, after stri } var ( - icGroupFolder = icons.Lucide("folder") - icGroupMore = icons.Lucide("ellipsis") + icGroupFolder = icons.Lucide("folder") + icGroupFolderOpen = icons.Lucide("folder-open") + icGroupMore = icons.Lucide("ellipsis") ) +// folderGlyph is a folder's glyph, open over its rows and closed without them. +func folderGlyph(b blockView) *icons.Icon { + if b.collapsed { + return icGroupFolder + } + return icGroupFolderOpen +} + // groupHeader is a block's header: the title (or the folder's rename field) and the …, // and under them the note a rename onto another folder earns. While a card is // carried, a header whose block refuses it fades. @@ -89,20 +98,21 @@ func (s *sidebar) headerLine(gtx C, th *ui.Theme, b blockView, st *blockState, f return s.sort.Item(gtx, b.key, w, nil) } // The line is a row's height, so its hover lights as a row's does. - rowHeight := gtx.Dp(2*sessionTreeRingR) + 2*gtx.Dp(ui.Space(1.5)) + rowHeight := gtx.Dp(railRow) children := []layout.FlexChild{layout.Flexed(1, func(gtx C) D { gtx.Constraints.Min.Y = rowHeight return title(gtx) })} hooks := blockMenuHooks{rename: func() { st.rename.Start(b.folder) }, newFolder: s.askFolderName} entries := headerEntries(b, f, s.launchProviders, hooks) + // The whole line lights under the pointer, as a row does, the … included. + lit := st.toggle.Hovered() || st.more.Hovered() || st.options.Opened() || st.context.Opened() if entries != nil { children = append(children, ui.Gap(1), layout.Rigid(func(gtx C) D { - return s.headerMenu(gtx, th, &st.options, &st.more, icGroupMore, i18n.T("sidebar.sessionGroupHeader.optionsFor", i18n.Args{"name": b.title}), entries) + return s.headerMenu(gtx, th, st, i18n.T("sidebar.sessionGroupHeader.optionsFor", i18n.Args{"name": b.title}), entries, lit) })) } - // The whole line lights under the pointer, as a row does, the … included. - fill := cardLayer(th, "", false, st.toggle.Hovered() || st.more.Hovered() || st.options.Opened() || st.context.Opened()) + fill := cardLayer(th, "", false, lit) if s.carry.Over() == b.key { // The card in the air lights the whole line it would drop on. fill = th.Over(ui.Alpha(th.TonePass, headerDropFill)) @@ -137,20 +147,25 @@ func headerEntries(b blockView, f blockFrame, providers []launchProvider, hooks return append(entries, blockOptions(b, f.view.folders, f.filtering, f.act, hooks)...) } -// headerMenu is a ghost icon-xs trigger under its Hint, opening entries. -func (s *sidebar) headerMenu(gtx C, th *ui.Theme, state *ui.MenuState, click *ui.Clickable, ic *icons.Icon, hint string, entries []ui.MenuEntry) D { - return th.DropdownMenu(s.root, state, entries).Layout(gtx, func(gtx C) D { - return th.Tooltip(s.root, s.hint(hint), hint).Layout(gtx, func(gtx C) D { - btn := th.Button(click, "") - btn.Icon, btn.Variant, btn.Size = ic, ui.VariantGhost, ui.SizeIconXS - return btn.Layout(gtx) +// headerMenu is the line's corner slot, as a card's: the … that opens entries, +// seen while the line is lit. It stays laid out unseen, so the pointer coming +// straight onto it lights the line. +func (s *sidebar) headerMenu(gtx C, th *ui.Theme, st *blockState, hint string, entries []ui.MenuEntry, lit bool) D { + size := gtx.Dp(cardSlotSize) + gtx.Constraints = layout.Exact(image.Pt(size, size)) + if !lit { + defer paint.PushOpacity(gtx.Ops, 0).Pop() + } + return layout.Center.Layout(gtx, func(gtx C) D { + return th.DropdownMenu(s.root, &st.options, entries).Layout(gtx, func(gtx C) D { + return th.Tooltip(s.root, s.hint(hint), hint).Layout(gtx, th.CornerButton(&st.more, icGroupMore, st.options.Opened()).Layout) }) }) } -// titleButton is the header's title button: the chevron, a folder's glyph, -// name and count, the folded block's mark, then, past the pinned block's -// title, the rule to the row's end. +// titleButton is the header's title button: the block's glyph, which is the +// fold's chevron under the pointer, its name and count and the folded block's +// mark. func (s *sidebar) titleButton(gtx C, th *ui.Theme, b blockView, st *blockState, refuses bool) D { hint := i18n.T("sidebar.sessionGroupHeader.collapse", i18n.Args{"name": b.title}) if b.collapsed { @@ -179,7 +194,7 @@ func (s *sidebar) titleContent(gtx C, th *ui.Theme, b blockView, hovered, refuse // under the pointer, as a tree node does. glyph, tint := icMenuPin, "" if b.kind == blockFolder { - glyph, tint = icGroupFolder, b.color + glyph, tint = folderGlyph(b), b.color } glyphColor := fade(headGlyphTone(th, tint)) if hovered { @@ -200,29 +215,24 @@ func (s *sidebar) titleContent(gtx C, th *ui.Theme, b blockView, hovered, refuse }) }) }), ui.Gap(1.5)} - kids = append(kids, headerWords(th, b, hovered, fg, fade)...) + kids = append(kids, headerWords(th, b, hovered, fade)...) // The line is a row's height already (headerLine); the content centres in it. return layout.Inset{Left: rowInset, Right: ui.Space(1)}.Layout(gtx, func(gtx C) D { return layout.Flex{Alignment: layout.Middle}.Layout(gtx, kids...) }) } -// headerWords follow the header's glyph: a folder's name as typed and its -// count, or the pinned block's title in capitals, then the folded block's -// mark. A folder's tray already marks where it runs, so only the pinned -// block's title draws a rule after it. -func headerWords(th *ui.Theme, b blockView, hovered bool, fg color.NRGBA, fade func(color.NRGBA, float32) color.NRGBA) []layout.FlexChild { - var words []layout.FlexChild - if b.kind == blockFolder { - name := fade(th.Foreground, folderTitleOpacity) - if hovered { - name = fade(th.Foreground, 1) - } - words = append(words, layout.Rigid(th.Text(ui.TextXS, b.title).In(name).Weight(font.Medium).Layout)) - count := th.Text(ui.Text2XS, strconv.Itoa(rootCount(b.sessions))).Leading(text2XSLeading).In(fade(th.MutedForeground, headerCountOpacity)).Weight(font.Medium) - words = append(words, ui.Gap(1.5), layout.Rigid(count.Layout)) - } else { - words = append(words, layout.Rigid(th.Text(ui.Text2XS, strings.ToUpper(b.title)).Leading(text2XSLeading).In(fg).Weight(font.SemiBold).Layout)) +// headerWords follow the header's glyph: the folder's name as typed, or +// Pinned, its count, then the folded block's mark. +func headerWords(th *ui.Theme, b blockView, hovered bool, fade func(color.NRGBA, float32) color.NRGBA) []layout.FlexChild { + name := fade(th.Foreground, folderTitleOpacity) + if hovered { + name = fade(th.Foreground, 1) + } + words := []layout.FlexChild{ + layout.Rigid(th.Text(ui.TextXS, b.title).In(name).Weight(font.Medium).Layout), + ui.Gap(1.5), + layout.Rigid(th.Text(ui.TextXS, strconv.Itoa(rootCount(b.sessions))).In(fade(th.MutedForeground, 1)).Layout), } if dot, ok := markColor(th, b); ok { words = append(words, ui.Gap(1.5), layout.Rigid(func(gtx C) D { return ui.MarkDot(gtx, fade(dot, 1)) })) @@ -250,7 +260,7 @@ func markColor(th *ui.Theme, b blockView) (color.NRGBA, bool) { func (s *sidebar) folderRenameField(gtx C, th *ui.Theme, b blockView, st *blockState, act *sidebarAction) D { return layout.Inset{Left: -ui.Space(1)}.Layout(gtx, func(gtx C) D { return layout.Inset{Left: ui.Space(1), Right: ui.Space(1), Top: ui.Space(0.5), Bottom: ui.Space(0.5)}.Layout(gtx, func(gtx C) D { - d, res := th.InlineEdit(&st.rename, ui.Text2XS).Weight(font.SemiBold).Layout(gtx) + d, res := th.InlineEdit(&st.rename, ui.TextXS).Weight(font.Medium).Layout(gtx) if res.Outcome == ui.InlineEditCommitted { act.folder = folderRename{from: b.folder, to: res.Value} } diff --git a/native/cmd/lich-native/sidebar_header.go b/native/cmd/lich-native/sidebar_header.go index 7625da73b..52ce309e9 100644 --- a/native/cmd/lich-native/sidebar_header.go +++ b/native/cmd/lich-native/sidebar_header.go @@ -4,6 +4,7 @@ import ( "image" "image/color" + "gioui.org/font" "gioui.org/io/event" "gioui.org/io/key" "gioui.org/io/pointer" @@ -72,6 +73,15 @@ func (h *sidebarHeader) toggle() { h.focusQuery = h.open } +// seek opens the filter with the keyboard in its field, as it stands when it +// is open already. +func (h *sidebarHeader) seek() { + if !h.open { + h.toggle() + } + h.focusQuery = true +} + // escape is the field's Escape: with text it clears the query and keeps the // field; on an empty field it closes it, which hands the keyboard back to the // terminal. @@ -136,13 +146,11 @@ func pressed(gtx C, tag event.Tag) bool { } } -// headerRow is New Session, the filter toggle and the collapse button. +// headerRow is New, the filter toggle and the collapse button. func (s *sidebar) headerRow(gtx C, th *ui.Theme, m *model, act *sidebarAction) D { h := &s.header toggle, toggleLabel := s.collapseToggle(gtx, act) - entries := append(launchEntries(s.launchProviders, i18n.T("sidebar.sessionLaunchMenuItems.terminal"), func(kind string) { act.launch = launchRequest{kind: kind} }), - ui.MenuEntry{Label: i18n.T("sidebar.sessionLaunchMenuItems.worktree"), Icon: icWtBranch, OnClick: func() { act.worktree = true }, - Spot: func(gtx C, row layout.Widget) D { return s.tour.Anchor(gtx, worktreesItem, row) }}) + entries := s.newEntries(act) trigger := func(gtx C) D { gtx.Constraints.Min.X = gtx.Constraints.Max.X tip := th.Tooltip(s.root, s.hint("new"), i18n.T("sidebar.sessionSidebar.newSession")) @@ -167,6 +175,13 @@ func (s *sidebar) headerRow(gtx C, th *ui.Theme, m *model, act *sidebarAction) D ) } +// newEntries is New's menu: a session of each agent, a terminal, a worktree. +func (s *sidebar) newEntries(act *sidebarAction) []ui.MenuEntry { + return append(launchEntries(s.launchProviders, i18n.T("sidebar.sessionLaunchMenuItems.terminal"), func(kind string) { act.launch = launchRequest{kind: kind} }), + ui.MenuEntry{Label: i18n.T("sidebar.sessionLaunchMenuItems.worktree"), Icon: icWtBranch, OnClick: func() { act.worktree = true }, + Spot: func(gtx C, row layout.Widget) D { return s.tour.Anchor(gtx, worktreesItem, row) }}) +} + // filterRow is the SearchInput, then the phase chips. func (s *sidebar) filterRow(gtx C, th *ui.Theme, view sidebarView) D { h := &s.header @@ -179,7 +194,8 @@ func (s *sidebar) filterRow(gtx C, th *ui.Theme, view sidebarView) D { h.escape() } } - if h.focusQuery { + // The morph's capture frame lays the field out disabled, and would drop it. + if h.focusQuery && gtx.Enabled() { gtx.Execute(key.FocusCmd{Tag: &h.query}) h.focusQuery = false } @@ -221,9 +237,8 @@ func (s *sidebar) phaseChips(gtx C, th *ui.Theme, counts map[sessionPhase]int) D // keeps the variant's dark:hover:bg-muted/50, which wins in the dark theme: // so the header hovers like the kit's ghost, while on (aria-pressed or // aria-expanded) is bg-accent. The rail hovers bg-accent/60. A labelled -// one is SessionSidebar's New Session, `h-9 justify-start gap-2 px-2.5`, its -// text foreground and its icon muted; a square one is `size-8`, muted until -// hovered or on. +// one is the header's New, its icon in the rows' node column and its label on +// their names; a square one is a row tall, muted until hovered or on. type sideButton struct { click *ui.Clickable icon *icons.Icon @@ -256,16 +271,47 @@ func (b sideButton) layout(th *ui.Theme) layout.Widget { fg = th.Foreground } if b.label == "" { - return ui.SquareFace(gtx, bg, b.iconWidget(fg)) + return sideFace(gtx, gtx.Dp(railRow), bg, b.iconWidget(fg)) } face := th.On(opaqueOr(bg, th)) - return face.LabelFace(gtx, bg, b.iconWidget(face.MutedForeground), b.label) + return sideLabel(gtx, face, bg, b.iconWidget(face.MutedForeground), b.label) }) } } +// sideGlyph is the size of the icons of the header and the rail's buttons. +var sideGlyph = ui.Space(3.5) + +// sideFace is icon centred on a row-tall box of bg, width wide. +func sideFace(gtx C, width int, bg color.NRGBA, icon layout.Widget) D { + gtx.Constraints = layout.Exact(image.Pt(width, gtx.Dp(railRow))) + return layout.Background{}.Layout(gtx, + func(gtx C) D { return ui.Fill(gtx, bg, ui.RadiusMD) }, + func(gtx C) D { return layout.Center.Layout(gtx, icon) }, + ) +} + +// sideLabel is icon and label on bg, a header row tall. +func sideLabel(gtx C, th *ui.Theme, bg color.NRGBA, icon layout.Widget, label string) D { + h := gtx.Dp(railHeaderRow) + gtx.Constraints.Min.Y, gtx.Constraints.Max.Y = h, h + return layout.Background{}.Layout(gtx, + func(gtx C) D { return ui.Fill(gtx, bg, ui.RadiusMD) }, + func(gtx C) D { + return layout.Inset{Left: rowInset, Right: rowInset}.Layout(gtx, func(gtx C) D { + gtx.Constraints.Min.Y = h + return layout.Flex{Alignment: layout.Middle}.Layout(gtx, + layout.Rigid(inNodeColumn(icon)), + ui.Gap(1.5), + layout.Flexed(1, th.Text(ui.TextSM, label).Weight(font.Medium).Layout), + ) + }) + }, + ) +} + func (b sideButton) iconWidget(fg color.NRGBA) layout.Widget { - icon := func(gtx C) D { return b.icon.Layout(gtx, ui.Space(4), fg) } + icon := func(gtx C) D { return b.icon.Layout(gtx, sideGlyph, fg) } if b.glyph == "" { return icon } diff --git a/native/cmd/lich-native/sidebar_morph.go b/native/cmd/lich-native/sidebar_morph.go index 60452a175..3defa4f2e 100644 --- a/native/cmd/lich-native/sidebar_morph.go +++ b/native/cmd/lich-native/sidebar_morph.go @@ -289,7 +289,7 @@ func nodeGlyphs(th *ui.Theme, blocks []blockView) map[string]layout.Widget { for _, b := range blocks { switch { case b.kind == blockFolder: - nodes[glyphNode+b.key] = headGlyph(th, icGroupFolder, b.color) + nodes[glyphNode+b.key] = headGlyph(th, folderGlyph(b), b.color) case b.kind == blockPinned: nodes[glyphNode+b.key] = headGlyph(th, icMenuPin, "") } @@ -310,11 +310,11 @@ func (s *sidebar) flyingGlyph(gtx C, th *ui.Theme, name string, side morphSide, panel := (side == sideTo) == s.wide() switch { case name == glyphToggle && panel: - icCollapse.Layout(gtx, ui.Space(4), th.MutedForeground) + icCollapse.Layout(gtx, sideGlyph, th.MutedForeground) case name == glyphToggle: - icExpand.Layout(gtx, ui.Space(4), th.MutedForeground) + icExpand.Layout(gtx, sideGlyph, th.MutedForeground) case name == glyphNew: - icPlus.Layout(gtx, ui.Space(4), th.MutedForeground) + icPlus.Layout(gtx, sideGlyph, th.MutedForeground) case strings.HasPrefix(name, glyphNode): if w := nodes[name]; w != nil { w(gtx) diff --git a/native/cmd/lich-native/sidebar_profile_footer.go b/native/cmd/lich-native/sidebar_profile_footer.go index 46743db77..ad6db6a71 100644 --- a/native/cmd/lich-native/sidebar_profile_footer.go +++ b/native/cmd/lich-native/sidebar_profile_footer.go @@ -3,6 +3,7 @@ package main import ( "time" + "gioui.org/font" "gioui.org/layout" "gioui.org/unit" @@ -159,10 +160,10 @@ func (m *model) footerEntries(th *ui.Theme, f profileFocus, act *sidebarAction) ui.MenuEntry{Kind: ui.MenuSubTrigger, Label: i18n.T("sidebar.sidebarProfile.otherProviders"), Sub: sub}) } -// layout is the account row: the provider's glyph, the profile's avatar and -// name (the provider's name with no profiles), its five-hour usage, and the -// chevrons of the panel. -func (pf *profileFooter) layout(gtx C, th *ui.Theme, root *ui.Root, m *model, a sidebarAccount, act *sidebarAction) D { +// layout is the account row: the provider's mark in the rows' node column, the +// profile's name (the provider's with no profiles), its five-hour usage, and +// the chevrons of the panel, width wide. +func (pf *profileFooter) layout(gtx C, th *ui.Theme, root *ui.Root, m *model, a sidebarAccount, act *sidebarAction, width unit.Dp) D { f := a.profile name := a.plan.Name if f.book != nil { @@ -181,30 +182,22 @@ func (pf *profileFooter) layout(gtx C, th *ui.Theme, root *ui.Root, m *model, a } on := th.On(bg) children := []layout.FlexChild{ - layout.Rigid(func(gtx C) D { return providerIcon(a.kind).Layout(gtx, 14, on.MutedForeground) }), - ui.Gap(2), + layout.Rigid(func(gtx C) D { return providerGlyph(gtx, on, a.kind, 2*sessionTreeRingR, markPixel) }), + ui.Gap(1.5), + layout.Flexed(1, on.Text(ui.TextSM, name).Weight(font.Medium).Truncated().Layout), } - if f.book != nil { - children = append(children, - layout.Rigid(func(gtx C) D { return profileAvatar(gtx, on, f.book.look(f.choice.shown), ui.Space(4)) }), - ui.Gap(2)) - } - children = append(children, layout.Flexed(1, on.Text(ui.TextSM, name).Truncated().Layout)) if a.loaded && hasUsage { t := on.Text(ui.TextXS, usage.Text).Mono().In(toneColor(on, usage.Tone)) children = append(children, ui.Gap(2), layout.Rigid(t.Layout)) } children = append(children, ui.Gap(1), layout.Rigid(func(gtx C) D { return icProfileFooter.Layout(gtx, 14, on.MutedForeground) })) - return layout.Inset{Left: ui.Space(2), Right: ui.Space(2)}.Layout(gtx, func(gtx C) D { + return layout.Inset{Left: rowInset, Right: rowInset}.Layout(gtx, func(gtx C) D { gtx.Constraints.Min.Y = h return layout.Flex{Alignment: layout.Middle}.Layout(gtx, children...) }) }) } - return layout.Flex{Axis: layout.Vertical}.Layout(gtx, - ui.VGap(2), - layout.Rigid(func(gtx C) D { return pf.dropdown(th, root, m, a, act, 0).Above().Spanning().Layout(gtx, row) }), - ) + return pf.dropdown(th, root, m, a, act, width).Above().Layout(gtx, row) } // dropdown is the account's panel, width wide: the row's, or the rail's diff --git a/native/cmd/lich-native/sidebar_profile_panel_test.go b/native/cmd/lich-native/sidebar_profile_panel_test.go index ac23f9224..ebfe7988c 100644 --- a/native/cmd/lich-native/sidebar_profile_panel_test.go +++ b/native/cmd/lich-native/sidebar_profile_panel_test.go @@ -29,7 +29,7 @@ func TestTheAccountPanelIsAsWideAsTheSidebarsRow(t *testing.T) { root.Layout(gtx, func(gtx C) D { defer op.Offset(image.Pt(inset, 0)).Push(gtx.Ops).Pop() gtx.Constraints.Max.X = row - pf.layout(gtx, th, &root, m, a, &act) + pf.layout(gtx, th, &root, m, a, &act, gtx.Metric.PxToDp(row)) return D{Size: gtx.Constraints.Max} }) } diff --git a/native/cmd/lich-native/sidebar_rail.go b/native/cmd/lich-native/sidebar_rail.go index fddda1054..be5f41e1c 100644 --- a/native/cmd/lich-native/sidebar_rail.go +++ b/native/cmd/lich-native/sidebar_rail.go @@ -85,13 +85,13 @@ func (r *sidebarRail) button(th *ui.Theme, s *sidebar, click *ui.Clickable, ic * // railRow is a rail row's height, a tree row's: its node and the row's // padding, so a ring sits where it sits in the open sidebar. var ( - // railWidth is the rail's island: a column as wide as a tree row is tall - // inside the island's 8px edge, so its nodes centre where the open - // sidebar's do (rowInset + sessionTreeRingR from the edge). - railWidth = railRow + 2*ui.Space(2) - // railHeaderRow is the open sidebar's header row (LabelFace). - railHeaderRow = ui.Space(9) - railRow = 2*sessionTreeRingR + 2*ui.Space(1.5) + // railWidth is the rail's island: a column inside the island's 8px + // edge whose nodes centre where the open sidebar's do (rowInset + + // sessionTreeRingR from the edge). + railWidth = 2*(sessionTreeRingR+rowInset) + 2*ui.Space(2) + // railHeaderRow is the open sidebar's header row (sideLabel). + railHeaderRow = ui.Space(8) + railRow = 2 * (sessionTreeRingR + treeRowPad) railChildR = unit.Dp(8) // a child's node: smaller, on its mother's line railBlockGap = ui.Space(1.5) // the gap between blocks, blockList's ) @@ -148,7 +148,7 @@ func railItems(blocks []blockView) []railItem { first := len(items) switch { case folder: - items = append(items, railItem{kind: railHead, id: "head:" + b.key, key: b.key, glyph: icGroupFolder, tint: b.color, title: b.title}) + items = append(items, railItem{kind: railHead, id: "head:" + b.key, key: b.key, glyph: folderGlyph(b), tint: b.color, title: b.title}) case b.kind == blockPinned: items = append(items, railItem{kind: railHead, id: "head:" + b.key, key: b.key, glyph: icMenuPin, title: b.title}) } @@ -316,8 +316,8 @@ func railSmall(gtx C, small bool, w layout.Widget) D { return w(gtx) } -// session is RailSession: `size-8 rounded-md` around the card's provider -// mark, lit while active, with the card's status (railBadge) on its corner. +// session is RailSession: a row-tall face around the card's provider mark, +// lit while active, with the card's status (railBadge) on its corner. // A child's mark is a child's size. func (r *sidebarRail) session(gtx C, th *ui.Theme, s *sidebar, it railItem, active string) D { sv := it.sv @@ -328,10 +328,11 @@ func (r *sidebarRail) session(gtx C, th *ui.Theme, s *sidebar, it railItem, acti if sv.ID == active { ground = th.Over(th.Accent) } - return layout.Center.Layout(gtx, func(gtx C) D { + return sideFace(gtx, gtx.Constraints.Max.X, ground, func(gtx C) D { return layout.Stack{}.Layout(gtx, layout.Stacked(func(gtx C) D { - return ui.SquareFace(gtx, ground, func(gtx C) D { + gtx.Constraints = layout.Exact(gtx.Constraints.Max) + return layout.Center.Layout(gtx, func(gtx C) D { if it.small { return railSmall(gtx, true, func(gtx C) D { return s.statusGlyph(gtx, th, sv) }) } @@ -350,11 +351,9 @@ func (r *sidebarRail) editorNode(gtx C, th *ui.Theme, it railItem) D { if it.editor.shown { bg = th.Over(th.Accent) } - return layout.Center.Layout(gtx, func(gtx C) D { - return ui.SquareFace(gtx, bg, func(gtx C) D { - return railSmall(gtx, it.small, func(gtx C) D { - return editorFileNode(gtx, onGround(th, railGround(th, it)), it.editor.rel, it.entry()) - }) + return sideFace(gtx, gtx.Constraints.Max.X, bg, func(gtx C) D { + return railSmall(gtx, it.small, func(gtx C) D { + return editorFileNode(gtx, onGround(th, railGround(th, it)), it.editor.rel, it.entry()) }) }) } diff --git a/native/cmd/lich-native/sidebar_rail_footer.go b/native/cmd/lich-native/sidebar_rail_footer.go index f25f5c0f8..0c9cde39b 100644 --- a/native/cmd/lich-native/sidebar_rail_footer.go +++ b/native/cmd/lich-native/sidebar_rail_footer.go @@ -1,19 +1,11 @@ package main import ( - "image" "image/color" - "strconv" - "strings" - "gioui.org/font" "gioui.org/layout" - "gioui.org/op" - "gioui.org/op/clip" - "gioui.org/op/paint" "gioui.org/unit" - "github.com/lichdotdev/lich/native/backend" "github.com/lichdotdev/lich/native/i18n" "github.com/lichdotdev/lich/native/ui" ) @@ -22,111 +14,51 @@ import ( // a row reads the same in both. const railPanelWidth unit.Dp = 256 -// railFooter is the rail's last two buttons, what the open panel's footer -// shows: the project's services, as a panel of the same rows, and the -// account, as the same panel. +// railFooter is the rail's last buttons: New and the filter, which the open +// sidebar's header holds, then its foot's, the services and the account, with +// the same panels. type railFooter struct { - services ui.Clickable - servicesPanel ui.DropdownPanelState - profile ui.Clickable + newMenu ui.MenuState + add ui.Clickable // New's hover; the menu takes the press + search ui.Clickable + profile ui.Clickable } func (r *sidebarRail) holdsKeys() bool { - return r.foot.servicesPanel.Opened() + return r.foot.newMenu.Opened() } -// footer lays the rail's footer out with a project on screen: a hairline, -// Services, and the account when the open footer shows its row. +// footer lays the rail's footer out with a project on screen, the account +// when the open foot shows its row. func (r *sidebarRail) footer(gtx C, th *ui.Theme, s *sidebar, m *model, act *sidebarAction) D { p, ok := m.project() if !ok { return D{} } - list, console := m.services.of(p.ID), m.consoleShown() + if r.foot.search.Clicked(gtx) { + s.setOpen(gtx, true, act) + s.header.seek() + } + s.launchProviders = m.launchProviders() children := []layout.FlexChild{ ui.VGap(2), - layout.Rigid(func(gtx C) D { return r.servicesButton(gtx, th, s, p.ID, list, console, act) }), + layout.Rigid(func(gtx C) D { + return th.DropdownMenu(s.root, &r.foot.newMenu, s.newEntries(act)).Layout(gtx, func(gtx C) D { + return r.button(th, s, &r.foot.add, icPlus, i18n.T("sidebar.sessionSidebar.newSession"), "")(gtx) + }) + }), + layout.Rigid(r.button(th, s, &r.foot.search, icSearch, i18n.T("sidebar.sessionSidebar.filter"), "")), + layout.Rigid(func(gtx C) D { + beside := func(p ui.DropdownPanelStyle) ui.DropdownPanelStyle { return p } + return s.services.button(gtx, th, s, m, p.ID, ui.SideRight, railPanelWidth, beside, act) + }), } if a, ok := s.profile.account(m); ok { - children = append(children, ui.VGap(1), layout.Rigid(func(gtx C) D { return r.profileButton(gtx, th, s, m, a, act) })) + children = append(children, layout.Rigid(func(gtx C) D { return r.profileButton(gtx, th, s, m, a, act) })) } return layout.Flex{Axis: layout.Vertical, Alignment: layout.Middle}.Layout(gtx, children...) } -func (r *sidebarRail) servicesButton(gtx C, th *ui.Theme, s *sidebar, projectID string, list []backend.Service, console string, act *sidebarAction) D { - t := tallyServices(list) - tip := th.Tooltip(s.root, s.hint("rail:services"), railServicesHint(t)) - tip.Side = ui.SideRight - panel := th.DropdownPanel(s.root, &r.foot.servicesPanel, railPanelWidth, func(gtx C, th *ui.Theme) D { - d := s.services.panelContent(gtx, th, s.root, projectID, list, console, act) - if act.service.op != serviceNone { - r.foot.servicesPanel.Close() - } - return d - }) - return tip.Layout(gtx, func(gtx C) D { - return panel.Layout(gtx, func(gtx C) D { - return r.foot.services.Layout(gtx, func(gtx C) D { - bg := railFill(th, r.foot.servicesPanel.Opened(), r.foot.services.Hovered()) - fg := th.MutedForeground - if t.total == 0 { - fg = th.Over(ui.Alpha(fg, 0.55)) - } - return ui.SquareFace(gtx, bg, func(gtx C) D { - return layout.Stack{}.Layout(gtx, - layout.Stacked(func(gtx C) D { return icServices.Layout(gtx, ui.Space(4), fg) }), - layout.Expanded(func(gtx C) D { return railServicesBadge(gtx, th.On(bg), t) }), - ) - }) - }) - }) - }) -} - -// railServicesHint is the Services button's tooltip: the count the closed -// footer row shows, in words. -func railServicesHint(t servicesTally) string { - if t.total == 0 { - return i18n.T("sidebar.services.title") - } - return i18n.T("sidebar.services.railHint", i18n.Args{"up": strconv.Itoa(t.up), "total": strconv.Itoa(t.total)}) -} - -// railServicesBadge is the open footer's count, up/total, on the icon's -// bottom right: red when one failed, the running tone while one runs, muted -// otherwise, none with no service. Its plate keeps the count readable against -// the button. -func railServicesBadge(gtx C, th *ui.Theme, t servicesTally) D { - box := gtx.Constraints.Min - if t.total == 0 { - return D{Size: box} - } - c := th.MutedForeground - switch { - case t.failed > 0: - c = th.Destructive - case t.up > 0: - c = th.TonePass - } - label := th.Text(ui.Text2XS, strconv.Itoa(t.up)+"/"+strconv.Itoa(t.total)).Mono().In(c).Weight(font.SemiBold) - lgtx := gtx - lgtx.Constraints = layout.Constraints{Max: image.Pt(gtx.Dp(ui.Space(8)), gtx.Dp(ui.Space(4)))} - m := op.Record(gtx.Ops) - d := label.Layout(lgtx) - call := m.Stop() - pad := gtx.Dp(railCountPad) - plate := d.Size.Add(image.Pt(2*pad, 0)) - at := box.Sub(plate) - defer op.Offset(at).Push(gtx.Ops).Pop() - paint.FillShape(gtx.Ops, th.Surface, clip.UniformRRect(image.Rectangle{Max: plate}, gtx.Dp(ui.RadiusSM)).Op(gtx.Ops)) - defer op.Offset(image.Pt(pad, 0)).Push(gtx.Ops).Pop() - call.Add(gtx.Ops) - return D{Size: box} -} - -// railCountPad is the plate's room on either side of the count. -const railCountPad = unit.Dp(2) - // railFill is a rail button's fill: accent while its popup is open, the // rail's hover while hovered. func railFill(th *ui.Theme, open, hovered bool) color.NRGBA { @@ -155,7 +87,7 @@ func (r *sidebarRail) profileButton(gtx C, th *ui.Theme, s *sidebar, m *model, a return r.foot.profile.Layout(gtx, func(gtx C) D { bg := railFill(th, s.profile.panel.Opened(), r.foot.profile.Hovered()) on := th.On(bg) - return ui.SquareFace(gtx, bg, func(gtx C) D { + return sideFace(gtx, gtx.Dp(railRow), bg, func(gtx C) D { if f.book == nil { return providerIcon(a.kind).Layout(gtx, ui.Space(4), on.MutedForeground) } @@ -165,39 +97,3 @@ func (r *sidebarRail) profileButton(gtx C, th *ui.Theme, s *sidebar, m *model, a }) }) } - -// panelContent is the open footer's list as the rail's panel draws it: a -// header with the count and the all button, the rows, and New service. -func (f *servicesFooter) panelContent(gtx C, th *ui.Theme, root *ui.Root, projectID string, list []backend.Service, console string, act *sidebarAction) D { - if f.add.Clicked(gtx) { - act.service = serviceRequest{op: serviceAdd, project: projectID} - } - t := tallyServices(list) - if f.all.Clicked(gtx) { - act.service = serviceRequest{op: allServicesOp(t), project: projectID} - } - gtx.Constraints.Min.X = gtx.Constraints.Max.X - return layout.Flex{Axis: layout.Vertical}.Layout(gtx, - layout.Rigid(func(gtx C) D { return f.panelHeader(gtx, th, root, t) }), - layout.Rigid(func(gtx C) D { return f.rowList(gtx, th, root, list, console, act) }), - layout.Rigid(func(gtx C) D { return f.addRow(gtx, th) }), - ) -} - -func (f *servicesFooter) panelHeader(gtx C, th *ui.Theme, root *ui.Root, t servicesTally) D { - h := gtx.Dp(ui.Space(8)) - gtx.Constraints.Min.Y, gtx.Constraints.Max.Y = h, h - children := []layout.FlexChild{ - layout.Rigid(th.Text(ui.Text2XS, strings.ToUpper(i18n.T("sidebar.services.title"))).Leading(text2XSLeading).Muted().Weight(font.SemiBold).Layout), - ui.Gap(1.5), - layout.Rigid(servicesTallyLine(th, t)), - layout.Flexed(1, func(gtx C) D { return D{Size: gtx.Constraints.Min} }), - } - if t.total > 0 { - children = append(children, layout.Rigid(func(gtx C) D { return f.allButton(gtx, th, root, t) })) - } - return layout.Inset{Left: ui.Space(2), Right: ui.Space(1)}.Layout(gtx, func(gtx C) D { - gtx.Constraints.Min.Y = h - return layout.Flex{Alignment: layout.Middle}.Layout(gtx, children...) - }) -} diff --git a/native/cmd/lich-native/sidebar_rail_test.go b/native/cmd/lich-native/sidebar_rail_test.go index 314713195..9aa457530 100644 --- a/native/cmd/lich-native/sidebar_rail_test.go +++ b/native/cmd/lich-native/sidebar_rail_test.go @@ -131,29 +131,3 @@ func TestTheRailBadgeKeepsTheCardsCornerAndDropsItAtRest(t *testing.T) { t.Errorf("a read session's badge still draws or keeps its corner, want none") } } - -func TestTheRailServicesBadgeCountsOnlyAProjectWithServices(t *testing.T) { - draw := func(tally servicesTally) string { - r := newFrameRig(image.Pt(32, 32), func(gtx C, th *ui.Theme) { - var click ui.Clickable - click.Layout(gtx, func(gtx C) D { - return ui.SquareFace(gtx, th.Surface, func(gtx C) D { - return layout.Stack{}.Layout(gtx, - layout.Stacked(func(gtx C) D { return icServices.Layout(gtx, ui.Space(4), th.MutedForeground) }), - layout.Expanded(func(gtx C) D { return railServicesBadge(gtx, th, tally) }), - ) - }) - }) - }) - drawn, _ := r.frame() - return drawn - } - none, idle, up := draw(servicesTally{}), draw(servicesTally{total: 3}), draw(servicesTally{up: 2, total: 3}) - empty := draw(servicesTally{}) - if none != empty { - t.Fatal("drawing nothing differs frame to frame") - } - if idle == none || up == idle { - t.Errorf("badges for 0/3 and 2/3 look the same as no services or as each other, want a count each") - } -} diff --git a/native/cmd/lich-native/sidebar_services.go b/native/cmd/lich-native/sidebar_services.go index e8c37b5ca..5ff0de507 100644 --- a/native/cmd/lich-native/sidebar_services.go +++ b/native/cmd/lich-native/sidebar_services.go @@ -5,13 +5,11 @@ import ( "image" "image/color" "strconv" - "strings" "time" - "gioui.org/font" - "gioui.org/layout" "gioui.org/op" + "gioui.org/unit" "gioui.org/widget" "gioui.org/widget/material" @@ -31,8 +29,8 @@ var ( icServiceDelete = icons.Lucide("trash-2") ) -// serviceRowsShown is how many service rows the open footer shows before it -// scrolls, so a project with many services keeps room for its sessions. +// serviceRowsShown is how many service rows the panel shows before it +// scrolls. const serviceRowsShown = 8 // serviceOp is what a click asked of a service. @@ -60,36 +58,34 @@ type serviceRequest struct { project string } -// servicesFooter is the Services block above the profile: a group header -// that opens and closes it, and the project's services under it. +// servicesFooter is the project's services: one glyph in the sidebar's foot, +// or the rail's, inked as they stand, and the panel of them it opens. type servicesFooter struct { - open bool - header ui.Clickable - more ui.Clickable - headerMenu ui.MenuState // the header's … - headerCtx ui.MenuState // the header's right click - all ui.Clickable - allTip ui.Tooltip - add ui.Clickable - list widget.List - rows map[string]*ui.Clickable - mores map[string]*ui.Clickable - menus map[string]*ui.MenuState // a row's right click - moreMenus map[string]*ui.MenuState // a row's … + panel ui.DropdownPanelState + click ui.Clickable + all map[serviceOp]*ui.IconActionState // Start all, Stop all + add ui.Clickable + list widget.List + rows map[string]*ui.Clickable + mores map[string]*ui.Clickable + menus map[string]*ui.MenuState // a row's right click + moreMenus map[string]*ui.MenuState // a row's … } func newServicesFooter() servicesFooter { f := servicesFooter{ rows: map[string]*ui.Clickable{}, mores: map[string]*ui.Clickable{}, + all: map[serviceOp]*ui.IconActionState{serviceStartAll: {}, serviceStopAll: {}}, menus: map[string]*ui.MenuState{}, moreMenus: map[string]*ui.MenuState{}, } f.list.Axis = layout.Vertical return f } -// holdsKeys is whether one of the block's menus is open, which takes the keys. +// holdsKeys is whether the panel or one of its menus is open, which takes the +// keys. func (f *servicesFooter) holdsKeys() bool { - if f.headerMenu.Opened() || f.headerCtx.Opened() { + if f.panel.Opened() { return true } for _, states := range []map[string]*ui.MenuState{f.menus, f.moreMenus} { @@ -111,145 +107,104 @@ func menuOf(states map[string]*ui.MenuState, id string) *ui.MenuState { return m } -// layout is the footer's Services block: the hairline that parts it from -// the sessions, the header that opens and closes it, then the open list, or -// New service while there is none. console is the service whose console is -// on screen. -func (f *servicesFooter) layout(gtx C, th *ui.Theme, root *ui.Root, projectID string, list []backend.Service, console string, act *sidebarAction) D { - if f.header.Clicked(gtx) { - f.open = !f.open - } - if f.add.Clicked(gtx) { - act.service = serviceRequest{op: serviceAdd, project: projectID} - } - tally := tallyServices(list) - children := []layout.FlexChild{ - ui.VGap(2), - layout.Rigid(func(gtx C) D { return f.headerRow(gtx, th, root, projectID, tally, act) }), - } - switch { - case f.open && len(list) == 0: - children = append(children, layout.Rigid(func(gtx C) D { return f.addRow(gtx, th) })) - case f.open: - children = append(children, layout.Rigid(func(gtx C) D { return f.rowList(gtx, th, root, list, console, act) })) - } - return layout.Flex{Axis: layout.Vertical}.Layout(gtx, children...) -} - -// rowHeight is a sidebar row's height: the node's box and its inset above and -// below. -func rowHeight(gtx C) int { return gtx.Dp(2*sessionTreeRingR) + 2*gtx.Dp(ui.Space(1.5)) } - -// headerRow is the block's header as a folder's is drawn: the glyph in the -// node's column, turning to the fold's chevron under the pointer, SERVICES, -// how many run of how many, a rule to the …, whose entries the right click -// opens too. -func (f *servicesFooter) headerRow(gtx C, th *ui.Theme, root *ui.Root, projectID string, t servicesTally, act *sidebarAction) D { - entries := func() []ui.MenuEntry { return servicesEntries(t, projectID, act) } - h := rowHeight(gtx) - lit := f.header.Hovered() || f.more.Hovered() || f.headerMenu.Opened() || f.headerCtx.Opened() - fill := cardLayer(th, "", false, lit) - return th.ContextMenuLazy(root, &f.headerCtx, entries).Layout(gtx, func(gtx C) D { - return layout.Background{}.Layout(gtx, - func(gtx C) D { return ui.Fill(gtx, fill, ui.RadiusMD) }, - func(gtx C) D { - return layout.Inset{Right: ui.Space(1)}.Layout(gtx, func(gtx C) D { - gtx.Constraints.Min.Y = h - return layout.Flex{Alignment: layout.Middle}.Layout(gtx, - layout.Flexed(1, func(gtx C) D { - gtx.Constraints.Min.Y = h - return f.header.Layout(gtx, func(gtx C) D { - gtx.Constraints.Min.X = gtx.Constraints.Max.X - return servicesTitle(gtx, th, t, f.open, f.header.Hovered()) - }) - }), - ui.Gap(1), - layout.Rigid(func(gtx C) D { - return th.DropdownMenu(root, &f.headerMenu, entries()).Layout(gtx, func(gtx C) D { - btn := th.Button(&f.more, "") - btn.Icon, btn.Variant, btn.Size = icGroupMore, ui.VariantGhost, ui.SizeIconXS - return btn.Layout(gtx) - }) - }), - ) - }) - }, - ) +// button is the services' glyph, its ink their state, and a click opens them in +// a panel width wide that place puts off it. +func (f *servicesFooter) button(gtx C, th *ui.Theme, s *sidebar, m *model, projectID string, side ui.Side, width unit.Dp, place func(ui.DropdownPanelStyle) ui.DropdownPanelStyle, act *sidebarAction) D { + list, console := m.services.of(projectID), m.consoleShown() + t := tallyServices(list) + tip := th.Tooltip(s.root, s.hint("services"), servicesHint(t)) + tip.Side = side + panel := place(th.DropdownPanel(s.root, &f.panel, width, func(gtx C, th *ui.Theme) D { + d := f.panelContent(gtx, th, s.root, projectID, list, console, act) + if act.service.op != serviceNone { + f.panel.Close() + } + return d + })) + return tip.Layout(gtx, func(gtx C) D { + return panel.Layout(gtx, func(gtx C) D { + return f.click.Layout(gtx, func(gtx C) D { + bg := railFill(th, f.panel.Opened(), f.click.Hovered()) + return sideFace(gtx, gtx.Dp(railRow), bg, func(gtx C) D { return icServices.Layout(gtx, sideGlyph, servicesInk(th.On(bg), t)) }) + }) + }) }) } -// servicesTitle is the header's line: the glyph, SERVICES and how many run -// and failed, in their tones. -func servicesTitle(gtx C, th *ui.Theme, t servicesTally, open, hovered bool) D { - fg := th.Over(ui.Alpha(th.MutedForeground, headerTitleOpacity)) - glyph := icServices - if hovered { - fg, glyph = th.MutedForeground, foldIcon(open) +// servicesInk is the glyph's ink: Destructive once one failed, TonePass while +// any runs, muted with none up. +func servicesInk(th *ui.Theme, t servicesTally) color.NRGBA { + switch { + case t.failed > 0: + return th.Destructive + case t.up > 0: + return th.TonePass } - - return layout.Inset{Left: rowInset, Right: ui.Space(1)}.Layout(gtx, func(gtx C) D { - return layout.Flex{Alignment: layout.Middle}.Layout(gtx, - layout.Rigid(func(gtx C) D { - gtx.Constraints = layout.Exact(image.Pt(gtx.Dp(sessionTreeRingR)*2, gtx.Dp(ui.Space(3)))) - return ui.CenteredIcon(gtx, glyph, ui.Space(3), fg) - }), - ui.Gap(1.5), - layout.Rigid(th.Text(ui.Text2XS, strings.ToUpper(i18n.T("sidebar.services.title"))).Leading(text2XSLeading).In(fg).Weight(font.SemiBold).Layout), - ui.Gap(1.5), - layout.Flexed(1, servicesTallyLine(th, t)), - ) - }) + return th.MutedForeground } -// servicesTallyLine is how many services run, in TonePass, and failed, in -// Destructive; "stopped" muted when none does either, Add when there are none. -func servicesTallyLine(th *ui.Theme, t servicesTally) layout.Widget { - muted := th.Over(ui.Alpha(th.MutedForeground, headerCountOpacity)) - var parts []toned - if t.up > 0 { - parts = append(parts, toned{text: i18n.T("sidebar.services.runningCount", i18n.Args{"count": t.up}), ink: th.TonePass}) - } - if t.failed > 0 { - parts = append(parts, toned{text: i18n.T("sidebar.services.failedCount", i18n.Args{"count": t.failed}), ink: th.Destructive}) - } - switch { - case t.total == 0: - parts = []toned{{text: i18n.T("sidebar.services.add"), ink: muted}} - case len(parts) == 0: - parts = []toned{{text: i18n.T("sidebar.services.stoppedCount", i18n.Args{"count": t.total}), ink: muted}} - } - return func(gtx C) D { - row := make([]layout.FlexChild, 0, 2*len(parts)) - for i, p := range parts { - text := p.text - if i > 0 { - text = " · " + text - } - row = append(row, layout.Rigid(th.Text(ui.Text2XS, text).Leading(text2XSLeading).In(p.ink).Weight(font.Medium).Layout)) - } - return layout.Flex{Alignment: layout.Middle}.Layout(gtx, row...) +// servicesHint is the glyph's tooltip: how many run of how many. +func servicesHint(t servicesTally) string { + if t.total == 0 { + return i18n.T("sidebar.services.title") } + return i18n.T("sidebar.services.railHint", i18n.Args{"up": strconv.Itoa(t.up), "total": strconv.Itoa(t.total)}) } -// servicesEntries is the header's menu: start what is down, stop what runs, -// and add a service. -func servicesEntries(t servicesTally, projectID string, act *sidebarAction) []ui.MenuEntry { - do := func(op serviceOp) func() { return func() { act.service = serviceRequest{op: op, project: projectID} } } - var entries []ui.MenuEntry - if t.up < t.total { - entries = append(entries, ui.MenuEntry{Label: i18n.T("sidebar.services.startAll"), Icon: icServiceStart, OnClick: do(serviceStartAll)}) - } - if t.up > 0 { - entries = append(entries, ui.MenuEntry{Label: i18n.T("sidebar.services.stopAll"), Icon: icServiceStop, OnClick: do(serviceStopAll)}) +// panelContent is the panel: a row for each service, then New service and +// the actions on all of them. +func (f *servicesFooter) panelContent(gtx C, th *ui.Theme, root *ui.Root, projectID string, list []backend.Service, console string, act *sidebarAction) D { + if f.add.Clicked(gtx) { + act.service = serviceRequest{op: serviceAdd, project: projectID} } - if len(entries) > 0 { - entries = append(entries, ui.MenuEntry{Kind: ui.MenuSeparator}) + t := tallyServices(list) + gtx.Constraints.Min.X = gtx.Constraints.Max.X + return layout.Flex{Axis: layout.Vertical}.Layout(gtx, + layout.Rigid(func(gtx C) D { return f.rowList(gtx, th, root, list, console, act) }), + layout.Rigid(func(gtx C) D { return f.addRow(gtx, th, root, projectID, t, act) }), + ) +} + +// addRow is the panel's last row: New service, then Start all and Stop all as +// allServicesOps has them. +func (f *servicesFooter) addRow(gtx C, th *ui.Theme, root *ui.Root, projectID string, t servicesTally, act *sidebarAction) D { + row := []layout.FlexChild{layout.Flexed(1, func(gtx C) D { + return f.add.Layout(gtx, func(gtx C) D { + gtx.Constraints.Min.X = gtx.Constraints.Max.X + return layout.Background{}.Layout(gtx, + func(gtx C) D { return ui.Fill(gtx, cardLayer(th, "", false, f.add.Hovered()), ui.RadiusMD) }, + func(gtx C) D { + return treeRowInset.Layout(gtx, func(gtx C) D { + return layout.Flex{Alignment: layout.Middle}.Layout(gtx, + // The node's box, which holds the row to a service's height. + layout.Rigid(layout.Spacer{Height: 2 * sessionTreeRingR}.Layout), + layout.Rigid(inNodeColumn(func(gtx C) D { return icPlus.Layout(gtx, 13, th.MutedForeground) })), + ui.Gap(1.5), + layout.Flexed(1, th.Text(ui.TextSM, i18n.T("sidebar.services.newService")).Muted().Layout), + ) + }) + }, + ) + }) + })} + for _, op := range allServicesOps(t) { + ic, hint := icServiceStart, i18n.T("sidebar.services.startAll") + if op == serviceStopAll { + ic, hint = icServiceStop, i18n.T("sidebar.services.stopAll") + } + state := f.all[op] + if state.Click.Clicked(gtx) { + act.service = serviceRequest{op: op, project: projectID} + } + row = append(row, ui.Gap(0.5), layout.Rigid(func(gtx C) D { + return th.IconAction(root, state, ic, hint, false).Layout(gtx) + })) } - return append(entries, ui.MenuEntry{Label: i18n.T("sidebar.services.newService"), Icon: icPlus, OnClick: do(serviceAdd)}) + return layout.Flex{Alignment: layout.Middle}.Layout(gtx, row...) } func (f *servicesFooter) rowList(gtx C, th *ui.Theme, root *ui.Root, list []backend.Service, console string, act *sidebarAction) D { - gtx.Constraints.Max.Y = min(gtx.Constraints.Max.Y, rowHeight(gtx)*serviceRowsShown) + gtx.Constraints.Max.Y = min(gtx.Constraints.Max.Y, gtx.Dp(railRow)*serviceRowsShown) // The thumb floats over the rows, as the rail's does: a reserved gutter // would end every row short of the cards above it. rows := th.ScrollArea(&f.list) @@ -284,7 +239,7 @@ func (f *servicesFooter) row(gtx C, th *ui.Theme, root *ui.Root, v backend.Servi if !serviceUp(v) && v.State != api.ServiceFailed { name = name.Muted() } - return layout.Inset{Top: ui.Space(1.5), Bottom: ui.Space(1.5), Left: rowInset, Right: ui.Space(1)}.Layout(gtx, func(gtx C) D { + return treeRowInset.Layout(gtx, func(gtx C) D { return layout.Flex{Alignment: layout.Middle}.Layout(gtx, layout.Rigid(func(gtx C) D { side := gtx.Dp(2 * sessionTreeRingR) @@ -350,39 +305,17 @@ func serviceReadout(gtx C, th *ui.Theme, v backend.Service) D { return l.Layout(gtx) } -// allServicesOp is what the header's all button does: start what is down, -// or stop everything once all of it runs. -func allServicesOp(t servicesTally) serviceOp { - if t.total > 0 && t.up == t.total { - return serviceStopAll - } - return serviceStartAll -} - -// allButton starts every service that is down, or stops them all once all -// of them run: the icon of what it does, the words in its tooltip. -func (f *servicesFooter) allButton(gtx C, th *ui.Theme, root *ui.Root, t servicesTally) D { - ic, hint := icServiceStart, i18n.T("sidebar.services.startAll") - if allServicesOp(t) == serviceStopAll { - ic, hint = icServiceStop, i18n.T("sidebar.services.stopAll") - } - tip := th.Tooltip(root, &f.allTip, hint) - return tip.Layout(gtx, func(gtx C) D { return th.CornerButton(&f.all, ic, false).Layout(gtx) }) -} - -// servicesCount is the closed row's readout: up/total, in the running tone -// while something runs, and Add for a project with none. -func servicesCount(gtx C, th *ui.Theme, t servicesTally) D { - if t.total == 0 { - return th.Text(ui.TextXS, i18n.T("sidebar.services.add")).Muted().Layout(gtx) +// allServicesOps is what the panel offers on all the services at once: start +// what is down, stop what runs. +func allServicesOps(t servicesTally) []serviceOp { + var ops []serviceOp + if t.up < t.total { + ops = append(ops, serviceStartAll) } - l := th.Text(ui.TextXS, strconv.Itoa(t.up)+"/"+strconv.Itoa(t.total)).Mono() if t.up > 0 { - l.Color = th.TonePass - } else { - l = l.Muted() + ops = append(ops, serviceStopAll) } - return l.Layout(gtx) + return ops } // stateDot is a service state as a 14dp glyph. @@ -439,26 +372,3 @@ func serviceMenu(v backend.Service, act *sidebarAction) []ui.MenuEntry { ) return entries } - -// addRow is the open list's last row: New service, into Settings. -func (f *servicesFooter) addRow(gtx C, th *ui.Theme) D { - gtx.Constraints.Min.X = gtx.Constraints.Max.X - return f.add.Layout(gtx, func(gtx C) D { - h := gtx.Dp(ui.Space(6.5)) - gtx.Constraints.Min.Y, gtx.Constraints.Max.Y = h, h - bg := th.Surface - if f.add.Hovered() { - bg = th.Over(ui.Alpha(th.Muted, ghostHoverFill)) - ui.Fill(gtx, bg, ui.RadiusMD) - } - on := th.On(bg) - return layout.Inset{Left: ui.Space(2), Right: ui.Space(2)}.Layout(gtx, func(gtx C) D { - gtx.Constraints.Min.Y = h - return layout.Flex{Alignment: layout.Middle}.Layout(gtx, - layout.Rigid(func(gtx C) D { return icPlus.Layout(gtx, 14, on.MutedForeground) }), - ui.Gap(2), - layout.Rigid(on.Text(ui.TextSM, i18n.T("sidebar.services.newService")).Muted().Layout), - ) - }) - }) -} diff --git a/native/cmd/lich-native/sidebar_split.go b/native/cmd/lich-native/sidebar_split.go index fb2537923..41a2431b4 100644 --- a/native/cmd/lich-native/sidebar_split.go +++ b/native/cmd/lich-native/sidebar_split.go @@ -10,8 +10,8 @@ import ( ) // A layout's tab has a sidebar of its own: the layout's sessions and no -// others, under the project each belongs to. New Session, the filter and the -// services are a project's, so they stay on its tab. +// others, under the project each belongs to. New and the filter are a +// project's, so they stay on its tab. const splitGroupPrefix = "__layout__:" @@ -92,6 +92,8 @@ func (s *sidebar) splitHeader(gtx C, th *ui.Theme, name string, act *sidebarActi h := &s.header toggle, toggleLabel := s.collapseToggle(gtx, act) return layout.Flex{Alignment: layout.Middle}.Layout(gtx, + // The row is as tall as a project's, whose New sets it. + layout.Rigid(layout.Spacer{Height: railHeaderRow}.Layout), layout.Flexed(1, func(gtx C) D { return layout.Inset{Left: rowInset}.Layout(gtx, th.Text(ui.TextSM, name).Weight(font.Medium).Layout) }), @@ -119,7 +121,7 @@ func (s *sidebar) splitList(gtx C, th *ui.Theme, layoutID string, groups []split } rows = append(rows, layout.Rigid(func(gtx C) D { - return layout.Inset{Top: ui.Space(1.5), Bottom: ui.Space(1.5), Left: rowInset}.Layout(gtx, th.Text(ui.TextXS, group.project).Muted().Layout) + return layout.Inset{Top: ui.Space(1), Bottom: ui.Space(1), Left: rowInset}.Layout(gtx, th.Text(ui.TextXS, group.project).Muted().Layout) }), layout.Rigid(func(gtx C) D { st := s.blockState(group.block) diff --git a/native/cmd/lich-native/sidebar_tree_draw.go b/native/cmd/lich-native/sidebar_tree_draw.go index b2ef5bba4..65cbd5a3f 100644 --- a/native/cmd/lich-native/sidebar_tree_draw.go +++ b/native/cmd/lich-native/sidebar_tree_draw.go @@ -79,6 +79,10 @@ var ( // treeLinkAlpha is how strongly the muted foreground draws the links. treeLinkAlpha float32 = 0.45 rowInset = ui.Space(1.5) + // treeRowPad is a row's room over and under its node, and treeRowInset + // all of a row's. + treeRowPad = ui.Space(0.75) + treeRowInset = layout.Inset{Top: treeRowPad, Bottom: treeRowPad, Left: rowInset, Right: ui.Space(1)} ) // treeColumn is the x of the ring centre at level k. diff --git a/native/cmd/lich-native/statusrung.go b/native/cmd/lich-native/statusrung.go index cd9fd05e6..b034a74eb 100644 --- a/native/cmd/lich-native/statusrung.go +++ b/native/cmd/lich-native/statusrung.go @@ -1,6 +1,9 @@ package main import ( + "image/color" + "time" + "gioui.org/font" "gioui.org/layout" @@ -9,51 +12,39 @@ import ( "github.com/lichdotdev/lich/native/ui/icons" ) -// toolGlyphs is the glyph a tool family wears, -// keyed by the names the harnesses report. An unknown name draws none. -var toolGlyphs = map[string]*icons.Icon{ - "Bash": icons.Lucide("terminal"), - "Read": icons.Lucide("file-text"), - "Edit": icons.Lucide("pencil"), - "Write": icons.Lucide("pencil"), - "NotebookEdit": icons.Lucide("pencil"), - "apply_patch": icons.Lucide("pencil"), - "Grep": icons.Lucide("search"), - "Glob": icons.Lucide("search"), - "WebFetch": icons.Lucide("globe"), - "WebSearch": icons.Lucide("globe"), - "TodoWrite": icons.Lucide("list-todo"), -} - var ( icRelayOut = icons.Lucide("arrow-right") icRelayIn = icons.Lucide("arrow-left") - icWaiting = icons.Lucide("circle-question-mark") icCompacting = icons.Lucide("fold-vertical") ) -// minDetail is the width under which the tool's detail is not drawn at all, -// so its separator never dangles after a truncated name. -const minDetail = 24 +// statusWord is what the session is doing in a word or two, in its ink, and for +// how long when that is known; "" for a terminal no agent reported from. +func statusWord(th *ui.Theme, sv *sessionView) (word string, ink color.NRGBA, age time.Duration, aged bool) { + switch { + case sv.status == statusWaiting: + return i18n.T("sidebar.sessionStatusRung.waitingOnYou"), th.ToneWait, sv.age, sv.aged + case sv.status == statusCompacting: + return i18n.T("sidebar.sessionStatusRung.compacting"), th.MutedForeground, sv.age, sv.aged + case sv.status == statusBusy: + return i18n.T("sidebar.sessionTooltip.working"), th.MutedForeground, sv.age, sv.aged + case sv.unread: + return i18n.T("sidebar.sessionTooltip.done"), th.TonePass, sv.idle, sv.idled + case sv.Kind == "shell" && sv.status == "": + return "", th.MutedForeground, 0, false + } + return i18n.T("sidebar.sessionTooltip.idle"), th.MutedForeground, sv.idle, sv.idled +} -// statusRung is SessionStatusRung, cut to the rungs this window keeps: an -// open request with another session, a block on the user, a compaction, and -// the tool the turn is running, the first that holds. It reports false when -// none does, and the card shows its path on that line. +// statusRung is what the word leaves out: the session on the other end of an +// open request, or what a waiting session is blocked on. It reports false when +// there is neither. func statusRung(th *ui.Theme, sv *sessionView) (layout.Widget, bool) { switch { case sv.relay.Direction != "": return relayRung(th, sv.relay), true - case sv.status == statusWaiting: - reason := sv.reason - if reason == "" { - reason = i18n.T("sidebar.sessionStatusRung.waitingOnYou") - } - return ui.IconLabel(icWaiting, th.ToneWait, th.Text(ui.TextXS, reason).In(th.ToneWait).Weight(font.Medium)).Layout, true - case sv.status == statusCompacting: - return ui.IconLabel(icCompacting, th.MutedForeground, th.Text(ui.TextXS, i18n.T("sidebar.sessionStatusRung.compacting")).Weight(font.Medium)).Layout, true - case sv.tool.Name != "": - return toolRung(th, sv), true + case sv.status == statusWaiting && sv.reason != "": + return para(th.Text(ui.TextXS, sv.reason).Muted()).Layout, true } return nil, false } @@ -69,31 +60,3 @@ func relayRung(th *ui.Theme, r sessionRelay) layout.Widget { } return ui.IconLabel(ic, th.MutedForeground, peer).Layout } - -// toolRung is the tool's glyph, its label and the detail the harness sent. -// The detail gives its width up first, and the label only once the detail -// has none left to give. -func toolRung(th *ui.Theme, sv *sessionView) layout.Widget { - label, detail := toolLine(sv.tool, sv.MCPServers) - return func(gtx C) D { - var children []layout.FlexChild - if ic, ok := toolGlyphs[sv.tool.Name]; ok { - children = append(children, layout.Rigid(func(gtx C) D { return ic.Layout(gtx, 12, th.MutedForeground) }), ui.Gap(1)) - } - children = append(children, layout.Rigid(th.Text(ui.TextXS, label).Weight(font.Medium).Layout)) - if detail != "" { - children = append(children, layout.Flexed(1, func(gtx C) D { - if gtx.Constraints.Max.X < gtx.Dp(minDetail) { - return D{} - } - return layout.Flex{Alignment: layout.Middle}.Layout(gtx, - ui.Gap(1), - layout.Rigid(th.Text(ui.TextXS, "·").In(th.Over(ui.Alpha(th.MutedForeground, 0.5))).Layout), - ui.Gap(1), - layout.Flexed(1, th.Text(ui.TextXS, detail).Muted().Mono().Layout), - ) - })) - } - return layout.Flex{Alignment: layout.Middle}.Layout(gtx, children...) - } -} diff --git a/native/cmd/lich-native/toolline.go b/native/cmd/lich-native/toolline.go deleted file mode 100644 index a912001fe..000000000 --- a/native/cmd/lich-native/toolline.go +++ /dev/null @@ -1,57 +0,0 @@ -package main - -import ( - "regexp" - "strings" -) - -// The harnesses spell an MCP tool three ways: -// mcp____ (Claude Code, Codex), mcp___ -// (oh-my-pi) and _ (opencode). Antigravity runs every MCP call -// as the one step call_mcp_tool, naming / in the detail. -var ( - mcpDouble = regexp.MustCompile(`^mcp__(.+?)__(.+)$`) - mcpStepDetail = regexp.MustCompile(`^([^/]+)/(.+)$`) -) - -const ( - mcpPrefix = "mcp__" - mcpStep = "call_mcp_tool" -) - -// toolLine is the label a card draws for the tool a -// turn runs, an MCP tool as " · ", and the detail beside it. -func toolLine(tool sessionTool, servers []string) (label, detail string) { - if tool.Name == mcpStep { - if step := mcpStepDetail.FindStringSubmatch(tool.Detail); step != nil { - return step[1] + " · " + step[2], "" - } - } - return toolLabel(tool.Name, servers), tool.Detail -} - -// toolLabel splits the doubled form on the string alone; the single -// underscore forms only against the servers the session's spawn found, -// longest first. A name matching none keeps what survives the prefix. -func toolLabel(name string, servers []string) string { - if parts := mcpDouble.FindStringSubmatch(name); parts != nil { - return parts[1] + " · " + parts[2] - } - rest := strings.TrimPrefix(name, mcpPrefix) - if server := longestServer(rest, servers); server != "" { - return server + " · " + rest[len(server)+1:] - } - return rest -} - -// longestServer is the longest server rest spells as "_" with a tool -// after it, "" for none. -func longestServer(rest string, servers []string) string { - found := "" - for _, server := range servers { - if len(server) > len(found) && len(rest) > len(server)+1 && strings.HasPrefix(rest, server+"_") { - found = server - } - } - return found -} diff --git a/native/cmd/lich-native/toolline_test.go b/native/cmd/lich-native/toolline_test.go deleted file mode 100644 index 2c1c57722..000000000 --- a/native/cmd/lich-native/toolline_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import "testing" - -func TestToolLine(t *testing.T) { - servers := []string{"lich", "ai-memory"} - cases := []struct { - name, detail string - servers []string - label, wantDetail string - }{ - {"mcp__ai-memory__memory_write_page", "", nil, "ai-memory · memory_write_page", ""}, - {"mcp__lich__open_session", "", nil, "lich · open_session", ""}, - {"mcp__srv__do__the__thing", "", nil, "srv · do__the__thing", ""}, - {"mcp__lich_list_sessions", "", servers, "lich · list_sessions", ""}, - {"mcp__ai-memory_memory_query", "", servers, "ai-memory · memory_query", ""}, - {"lich_open_session", "", servers, "lich · open_session", ""}, - {"lich_relay_send", "", []string{"lich", "lich_relay"}, "lich_relay · send", ""}, - {"lichen_pick", "", servers, "lichen_pick", ""}, - {"lichprobe_list_sessions", "", servers, "lichprobe_list_sessions", ""}, - {"mcp__other_list_sessions", "", servers, "other_list_sessions", ""}, - {"mcp__lich_list_sessions", "", nil, "lich_list_sessions", ""}, - {"Bash", "", servers, "Bash", ""}, - {"apply_patch", "", servers, "apply_patch", ""}, - {"", "", servers, "", ""}, - {"mcp__lich", "", servers, "lich", ""}, - {"mcp____tool", "", servers, "__tool", ""}, - {"lich_", "", servers, "lich_", ""}, - {"Bash", "pnpm test", servers, "Bash", "pnpm test"}, - {"call_mcp_tool", "lich/open_session", servers, "lich · open_session", ""}, - {"call_mcp_tool", "", servers, "call_mcp_tool", ""}, - {"call_mcp_tool", "open_session", servers, "call_mcp_tool", "open_session"}, - {"call_mcp_tool", "lich/", servers, "call_mcp_tool", "lich/"}, - } - for _, c := range cases { - label, detail := toolLine(sessionTool{Name: c.name, Detail: c.detail}, c.servers) - if label != c.label || detail != c.wantDetail { - t.Errorf("toolLine(%q, %q) = %q, %q; want %q, %q", c.name, c.detail, label, detail, c.label, c.wantDetail) - } - } -} diff --git a/native/i18n/locales/en/sidebar.json b/native/i18n/locales/en/sidebar.json index fc08deb3f..d3e18004f 100644 --- a/native/i18n/locales/en/sidebar.json +++ b/native/i18n/locales/en/sidebar.json @@ -66,7 +66,7 @@ }, "sessionSidebar": { "newSession": "New session", - "newSessionButton": "New Session", + "newSessionButton": "New", "filter": "Filter sessions", "collapse": "Collapse sidebar" }, @@ -140,6 +140,9 @@ "runConfined": "Run confined" }, "sessionTooltip": { + "working": "Working", + "done": "Done", + "idle": "Idle", "notMounted": "Not mounted (symlinks): {paths}", "morePaths": "+{count} more", "modelChanged": "Opened on {requested}, running {running}", @@ -211,7 +214,6 @@ }, "services": { "title": "Services", - "add": "Add", "startAll": "Start all", "stopAll": "Stop all", "stopping": "stopping…", @@ -235,18 +237,6 @@ "failedCode": "Failed · exit {code}", "never": "Not started yet", "stoppedAt": "Stopped · {time}" - }, - "runningCount": { - "one": "{count} running", - "other": "{count} running" - }, - "failedCount": { - "one": "{count} failed", - "other": "{count} failed" - }, - "stoppedCount": { - "one": "{count} stopped", - "other": "{count} stopped" } }, "checkoutRow": { diff --git a/native/i18n/locales/en/tour.json b/native/i18n/locales/en/tour.json index 3eea528c6..b453372dc 100644 --- a/native/i18n/locales/en/tour.json +++ b/native/i18n/locales/en/tour.json @@ -29,7 +29,7 @@ }, "worktree": { "title": "One task, one worktree", - "body": "To work on two things at once, open New Session and pick Worktree. Each one gets its own checkout, so two agents never touch the same files." + "body": "To work on two things at once, open New and pick Worktree. Each one gets its own checkout, so two agents never touch the same files." }, "menu": { "title": "Come back any time", diff --git a/native/i18n/locales/en/tourWorktrees.json b/native/i18n/locales/en/tourWorktrees.json index 5f1472b20..844af58a9 100644 --- a/native/i18n/locales/en/tourWorktrees.json +++ b/native/i18n/locales/en/tourWorktrees.json @@ -4,7 +4,7 @@ "open": { "title": "Start a task in a worktree", "body": "A worktree gives a task its own checkout and branch, so its agent never touches your main checkout's files.", - "hint": "Open New Session to continue" + "hint": "Open New to continue" }, "pick": { "title": "Pick Worktree", @@ -26,7 +26,7 @@ }, "card": { "title": "A checkout of its own", - "body": "The new session sits in its own checkout block, with its branch on the header. Its agent works there without touching your main checkout's files." + "body": "The branch mark on its row says it works in a checkout of its own; rest the pointer on it to see which. Its agent never touches your main checkout's files." }, "branch": { "title": "The branch on screen", diff --git a/native/i18n/locales/es/sidebar.json b/native/i18n/locales/es/sidebar.json index cf019c65c..1fb5ebcb3 100644 --- a/native/i18n/locales/es/sidebar.json +++ b/native/i18n/locales/es/sidebar.json @@ -66,7 +66,7 @@ }, "sessionSidebar": { "newSession": "Nueva sesión", - "newSessionButton": "Nueva sesión", + "newSessionButton": "Nueva", "filter": "Filtrar sesiones", "collapse": "Contraer la barra lateral" }, @@ -140,6 +140,9 @@ "runConfined": "Ejecutar confinado" }, "sessionTooltip": { + "working": "Trabajando", + "done": "Lista", + "idle": "Inactiva", "notMounted": "No montado (enlaces simbólicos): {paths}", "morePaths": "+{count} más", "modelChanged": "Abierta con {requested}, se ejecuta con {running}", @@ -211,7 +214,6 @@ }, "services": { "title": "Servicios", - "add": "Añadir", "startAll": "Iniciar todos", "stopAll": "Detener todos", "stopping": "deteniendo…", @@ -235,18 +237,6 @@ "failedCode": "Falló · salida {code}", "never": "Aún sin iniciar", "stoppedAt": "Detenido · {time}" - }, - "runningCount": { - "one": "{count} en marcha", - "other": "{count} en marcha" - }, - "failedCount": { - "one": "{count} falló", - "other": "{count} fallaron" - }, - "stoppedCount": { - "one": "{count} detenido", - "other": "{count} detenidos" } }, "checkoutRow": { diff --git a/native/i18n/locales/es/tour.json b/native/i18n/locales/es/tour.json index 8328ebf22..b13ce7be4 100644 --- a/native/i18n/locales/es/tour.json +++ b/native/i18n/locales/es/tour.json @@ -29,7 +29,7 @@ }, "worktree": { "title": "Una tarea, una worktree", - "body": "Para trabajar en dos cosas a la vez, abre Nueva sesión y elige Worktree. Cada una tiene su propio checkout, así que dos agentes nunca tocan los mismos archivos." + "body": "Para trabajar en dos cosas a la vez, abre Nueva y elige Worktree. Cada una tiene su propio checkout, así que dos agentes nunca tocan los mismos archivos." }, "menu": { "title": "Vuelve cuando quieras", diff --git a/native/i18n/locales/es/tourWorktrees.json b/native/i18n/locales/es/tourWorktrees.json index 7df8551ec..ce60ad309 100644 --- a/native/i18n/locales/es/tourWorktrees.json +++ b/native/i18n/locales/es/tourWorktrees.json @@ -4,7 +4,7 @@ "open": { "title": "Empieza una tarea en una worktree", "body": "Una worktree da a una tarea su propio checkout y su rama, así que su agente nunca toca los archivos de tu checkout principal.", - "hint": "Abre Nueva sesión para continuar" + "hint": "Abre Nueva para continuar" }, "pick": { "title": "Elige Worktree", @@ -26,7 +26,7 @@ }, "card": { "title": "Un checkout propio", - "body": "La nueva sesión queda en su propio bloque de checkout, con su rama en la cabecera. Su agente trabaja ahí sin tocar los archivos de tu checkout principal." + "body": "La marca de rama en su fila indica que trabaja en un checkout propio; deja el puntero encima para ver cuál. Su agente nunca toca los archivos de tu checkout principal." }, "branch": { "title": "La rama en pantalla", diff --git a/native/i18n/locales/ja/sidebar.json b/native/i18n/locales/ja/sidebar.json index 39bcbbc37..6dc7a1344 100644 --- a/native/i18n/locales/ja/sidebar.json +++ b/native/i18n/locales/ja/sidebar.json @@ -66,7 +66,7 @@ }, "sessionSidebar": { "newSession": "新しいセッション", - "newSessionButton": "新規セッション", + "newSessionButton": "新規", "filter": "セッションを絞り込む", "collapse": "サイドバーを折りたたむ" }, @@ -140,6 +140,9 @@ "runConfined": "隔離して実行" }, "sessionTooltip": { + "working": "作業中", + "done": "完了", + "idle": "アイドル", "notMounted": "マウントされていません(シンボリックリンク): {paths}", "morePaths": "ほか {count} 件", "modelChanged": "{requested} で開始、{running} で実行中", @@ -211,7 +214,6 @@ }, "services": { "title": "サービス", - "add": "追加", "startAll": "すべて開始", "stopAll": "すべて停止", "stopping": "停止中…", @@ -235,15 +237,6 @@ "failedCode": "失敗 · 終了コード {code}", "never": "まだ開始していません", "stoppedAt": "停止 · {time}" - }, - "runningCount": { - "other": "{count} 件実行中" - }, - "failedCount": { - "other": "{count} 件失敗" - }, - "stoppedCount": { - "other": "{count} 件停止" } }, "checkoutRow": { diff --git a/native/i18n/locales/ja/tour.json b/native/i18n/locales/ja/tour.json index ebab1504d..c1794b7cc 100644 --- a/native/i18n/locales/ja/tour.json +++ b/native/i18n/locales/ja/tour.json @@ -29,7 +29,7 @@ }, "worktree": { "title": "1 つの作業に 1 つのワークツリー", - "body": "2 つのことを同時に進めるには、「新規セッション」を開いて「ワークツリー」を選びます。それぞれ専用のチェックアウトを持つので、2 つのエージェントが同じファイルに触れることはありません。" + "body": "2 つのことを同時に進めるには、「新規」を開いて「ワークツリー」を選びます。それぞれ専用のチェックアウトを持つので、2 つのエージェントが同じファイルに触れることはありません。" }, "menu": { "title": "いつでも戻ってこられます", diff --git a/native/i18n/locales/ja/tourWorktrees.json b/native/i18n/locales/ja/tourWorktrees.json index 60350c7bd..379663ac8 100644 --- a/native/i18n/locales/ja/tourWorktrees.json +++ b/native/i18n/locales/ja/tourWorktrees.json @@ -4,7 +4,7 @@ "open": { "title": "ワークツリーで作業を始める", "body": "ワークツリーは作業ごとに専用のチェックアウトとブランチを用意するので、エージェントがメインのチェックアウトのファイルに触れることはありません。", - "hint": "「新規セッション」を開いて続ける" + "hint": "「新規」を開いて続ける" }, "pick": { "title": "「ワークツリー」を選ぶ", @@ -26,7 +26,7 @@ }, "card": { "title": "専用のチェックアウト", - "body": "新しいセッションは専用のチェックアウトのブロックに入り、ヘッダーにブランチ名が出ます。エージェントはそこで作業し、メインのチェックアウトのファイルには触れません。" + "body": "行のブランチのマークは、専用のチェックアウトで作業していることを示します。ポインターを重ねるとブランチ名が出ます。エージェントがメインのチェックアウトのファイルに触れることはありません。" }, "branch": { "title": "表示中のブランチ", diff --git a/native/i18n/locales/ko/sidebar.json b/native/i18n/locales/ko/sidebar.json index 7d9676738..89f507867 100644 --- a/native/i18n/locales/ko/sidebar.json +++ b/native/i18n/locales/ko/sidebar.json @@ -65,7 +65,7 @@ }, "sessionSidebar": { "newSession": "새 세션", - "newSessionButton": "새 세션", + "newSessionButton": "새로 만들기", "filter": "세션 필터", "collapse": "사이드바 접기" }, @@ -138,6 +138,9 @@ "runConfined": "격리 실행" }, "sessionTooltip": { + "working": "작업 중", + "done": "완료", + "idle": "유휴", "notMounted": "마운트되지 않음(심볼릭 링크): {paths}", "morePaths": "+{count}개 더", "modelChanged": "{requested} 모델로 시작, 지금은 {running} 실행 중", @@ -207,7 +210,6 @@ }, "services": { "title": "서비스", - "add": "추가", "startAll": "모두 시작", "stopAll": "모두 중지", "stopping": "중지하는 중…", @@ -231,15 +233,6 @@ "failedCode": "실패 · 종료 코드 {code}", "never": "아직 시작하지 않음", "stoppedAt": "중지됨 · {time}" - }, - "runningCount": { - "other": "{count}개 실행 중" - }, - "failedCount": { - "other": "{count}개 실패" - }, - "stoppedCount": { - "other": "{count}개 중지됨" } }, "checkoutRow": { diff --git a/native/i18n/locales/ko/tour.json b/native/i18n/locales/ko/tour.json index eb311cbbe..44354e140 100644 --- a/native/i18n/locales/ko/tour.json +++ b/native/i18n/locales/ko/tour.json @@ -29,7 +29,7 @@ }, "worktree": { "title": "작업 하나, worktree 하나", - "body": "두 가지 일을 동시에 하려면 새 세션을 열고 Worktree를 고르세요. 각자 자기 체크아웃을 가지므로 두 에이전트가 같은 파일을 건드리지 않습니다." + "body": "두 가지 일을 동시에 하려면 새로 만들기를 열고 Worktree를 고르세요. 각자 자기 체크아웃을 가지므로 두 에이전트가 같은 파일을 건드리지 않습니다." }, "menu": { "title": "언제든 다시 볼 수 있습니다", diff --git a/native/i18n/locales/ko/tourWorktrees.json b/native/i18n/locales/ko/tourWorktrees.json index 5532de10f..56a5c589a 100644 --- a/native/i18n/locales/ko/tourWorktrees.json +++ b/native/i18n/locales/ko/tourWorktrees.json @@ -4,7 +4,7 @@ "open": { "title": "worktree에서 작업 시작하기", "body": "worktree는 작업마다 자기 체크아웃과 브랜치를 주므로, 에이전트가 메인 체크아웃의 파일을 건드리지 않습니다.", - "hint": "계속하려면 새 세션을 여세요" + "hint": "계속하려면 새로 만들기를 여세요" }, "pick": { "title": "Worktree 고르기", @@ -26,7 +26,7 @@ }, "card": { "title": "자기만의 체크아웃", - "body": "새 세션은 자기 체크아웃 블록에 들어가고, 헤더에 브랜치 이름이 표시됩니다. 에이전트는 그곳에서 일하며 메인 체크아웃의 파일은 건드리지 않습니다." + "body": "행의 브랜치 표시는 자기 체크아웃에서 일한다는 뜻입니다. 포인터를 올리면 어느 브랜치인지 보입니다. 에이전트는 메인 체크아웃의 파일을 건드리지 않습니다." }, "branch": { "title": "화면의 브랜치", diff --git a/native/i18n/locales/pt-br/sidebar.json b/native/i18n/locales/pt-br/sidebar.json index a82a4ff46..8b1ba0bfb 100644 --- a/native/i18n/locales/pt-br/sidebar.json +++ b/native/i18n/locales/pt-br/sidebar.json @@ -66,7 +66,7 @@ }, "sessionSidebar": { "newSession": "Nova sessão", - "newSessionButton": "Nova sessão", + "newSessionButton": "Nova", "filter": "Filtrar sessões", "collapse": "Recolher barra lateral" }, @@ -140,6 +140,9 @@ "runConfined": "Rodar confinado" }, "sessionTooltip": { + "working": "Trabalhando", + "done": "Concluída", + "idle": "Ociosa", "notMounted": "Não montados (symlinks): {paths}", "morePaths": "+{count} a mais", "modelChanged": "Aberta com {requested}, rodando {running}", @@ -211,7 +214,6 @@ }, "services": { "title": "Serviços", - "add": "Adicionar", "startAll": "Iniciar todos", "stopAll": "Parar todos", "stopping": "parando…", @@ -235,18 +237,6 @@ "failedCode": "Falhou · saída {code}", "never": "Ainda não iniciado", "stoppedAt": "Parado · {time}" - }, - "runningCount": { - "one": "{count} rodando", - "other": "{count} rodando" - }, - "failedCount": { - "one": "{count} falhou", - "other": "{count} falharam" - }, - "stoppedCount": { - "one": "{count} parado", - "other": "{count} parados" } }, "checkoutRow": { diff --git a/native/i18n/locales/pt-br/tour.json b/native/i18n/locales/pt-br/tour.json index ce21b4a18..db0170cc8 100644 --- a/native/i18n/locales/pt-br/tour.json +++ b/native/i18n/locales/pt-br/tour.json @@ -29,7 +29,7 @@ }, "worktree": { "title": "Uma tarefa, uma worktree", - "body": "Para trabalhar em duas coisas ao mesmo tempo, abra Nova sessão e escolha Worktree. Cada uma ganha o próprio checkout, então dois agentes nunca mexem nos mesmos arquivos." + "body": "Para trabalhar em duas coisas ao mesmo tempo, abra Nova e escolha Worktree. Cada uma ganha o próprio checkout, então dois agentes nunca mexem nos mesmos arquivos." }, "menu": { "title": "Volte quando quiser", diff --git a/native/i18n/locales/pt-br/tourWorktrees.json b/native/i18n/locales/pt-br/tourWorktrees.json index 6f2934c31..c95154231 100644 --- a/native/i18n/locales/pt-br/tourWorktrees.json +++ b/native/i18n/locales/pt-br/tourWorktrees.json @@ -4,7 +4,7 @@ "open": { "title": "Comece uma tarefa numa worktree", "body": "Uma worktree dá à tarefa o próprio checkout e a própria branch, então o agente nunca mexe nos arquivos do seu checkout principal.", - "hint": "Abra Nova sessão para continuar" + "hint": "Abra Nova para continuar" }, "pick": { "title": "Escolha Worktree", @@ -26,7 +26,7 @@ }, "card": { "title": "Um checkout só dela", - "body": "A nova sessão fica no próprio bloco de checkout, com a branch no cabeçalho. O agente dela trabalha ali sem mexer nos arquivos do seu checkout principal." + "body": "A marca de branch na linha diz que ela trabalha num checkout próprio; pare o mouse nela para ver qual. O agente nunca mexe nos arquivos do seu checkout principal." }, "branch": { "title": "A branch na tela", diff --git a/native/i18n/locales/ru/sidebar.json b/native/i18n/locales/ru/sidebar.json index 840d77901..485e0eb12 100644 --- a/native/i18n/locales/ru/sidebar.json +++ b/native/i18n/locales/ru/sidebar.json @@ -68,7 +68,7 @@ }, "sessionSidebar": { "newSession": "Новая сессия", - "newSessionButton": "Новая сессия", + "newSessionButton": "Новая", "filter": "Фильтр сессий", "collapse": "Свернуть боковую панель" }, @@ -144,6 +144,9 @@ "runConfined": "Запуск в песочнице" }, "sessionTooltip": { + "working": "Работает", + "done": "Готово", + "idle": "Простаивает", "notMounted": "Не смонтировано (симлинки): {paths}", "morePaths": "+ещё {count}", "modelChanged": "Открыта на {requested}, работает на {running}", @@ -219,7 +222,6 @@ }, "services": { "title": "Сервисы", - "add": "Добавить", "startAll": "Запустить все", "stopAll": "Остановить все", "stopping": "останавливается…", @@ -243,24 +245,6 @@ "failedCode": "Сбой · код {code}", "never": "Ещё не запускался", "stoppedAt": "Остановлен · {time}" - }, - "runningCount": { - "one": "{count} работает", - "few": "{count} работают", - "many": "{count} работают", - "other": "{count} работают" - }, - "failedCount": { - "one": "{count} с ошибкой", - "few": "{count} с ошибкой", - "many": "{count} с ошибкой", - "other": "{count} с ошибкой" - }, - "stoppedCount": { - "one": "{count} остановлен", - "few": "{count} остановлены", - "many": "{count} остановлено", - "other": "{count} остановлено" } }, "checkoutRow": { diff --git a/native/i18n/locales/ru/tour.json b/native/i18n/locales/ru/tour.json index f0257e2c8..2924cabe4 100644 --- a/native/i18n/locales/ru/tour.json +++ b/native/i18n/locales/ru/tour.json @@ -29,7 +29,7 @@ }, "worktree": { "title": "Одна задача, один worktree", - "body": "Чтобы работать над двумя задачами сразу, откройте «Новая сессия» и выберите «Worktree». У каждого worktree своя рабочая копия, поэтому два агента никогда не правят одни и те же файлы." + "body": "Чтобы работать над двумя задачами сразу, откройте «Новая» и выберите «Worktree». У каждого worktree своя рабочая копия, поэтому два агента никогда не правят одни и те же файлы." }, "menu": { "title": "Возвращайтесь в любой момент", diff --git a/native/i18n/locales/ru/tourWorktrees.json b/native/i18n/locales/ru/tourWorktrees.json index 3e3102f93..70e8f325c 100644 --- a/native/i18n/locales/ru/tourWorktrees.json +++ b/native/i18n/locales/ru/tourWorktrees.json @@ -4,7 +4,7 @@ "open": { "title": "Начните задачу в worktree", "body": "Worktree даёт задаче свою рабочую копию и ветку, поэтому агент не трогает файлы вашей основной рабочей копии.", - "hint": "Откройте «Новая сессия», чтобы продолжить" + "hint": "Откройте «Новая», чтобы продолжить" }, "pick": { "title": "Выберите «Worktree»", @@ -26,7 +26,7 @@ }, "card": { "title": "Своя рабочая копия", - "body": "Новая сессия попадает в собственный блок рабочей копии, а ветка видна в заголовке. Агент работает там и не трогает файлы основной рабочей копии." + "body": "Значок ветки в строке говорит, что сессия работает в своей рабочей копии; наведите указатель, чтобы увидеть, в какой. Агент не трогает файлы основной рабочей копии." }, "branch": { "title": "Ветка на экране", diff --git a/native/i18n/locales/zh-cn/sidebar.json b/native/i18n/locales/zh-cn/sidebar.json index 5fe89b813..ba95358b5 100644 --- a/native/i18n/locales/zh-cn/sidebar.json +++ b/native/i18n/locales/zh-cn/sidebar.json @@ -66,7 +66,7 @@ }, "sessionSidebar": { "newSession": "新建会话", - "newSessionButton": "新建会话", + "newSessionButton": "新建", "filter": "筛选会话", "collapse": "折叠侧边栏" }, @@ -140,6 +140,9 @@ "runConfined": "受限运行" }, "sessionTooltip": { + "working": "工作中", + "done": "已完成", + "idle": "空闲", "notMounted": "未挂载(符号链接):{paths}", "morePaths": "另外 {count} 项", "modelChanged": "启动时为 {requested},当前运行 {running}", @@ -211,7 +214,6 @@ }, "services": { "title": "服务", - "add": "添加", "startAll": "全部启动", "stopAll": "全部停止", "stopping": "正在停止…", @@ -235,15 +237,6 @@ "failedCode": "失败 · 退出码 {code}", "never": "尚未启动", "stoppedAt": "已停止 · {time}" - }, - "runningCount": { - "other": "{count} 个运行中" - }, - "failedCount": { - "other": "{count} 个失败" - }, - "stoppedCount": { - "other": "{count} 个已停止" } }, "checkoutRow": { diff --git a/native/i18n/locales/zh-cn/tour.json b/native/i18n/locales/zh-cn/tour.json index feb3a8455..822071a23 100644 --- a/native/i18n/locales/zh-cn/tour.json +++ b/native/i18n/locales/zh-cn/tour.json @@ -29,7 +29,7 @@ }, "worktree": { "title": "一个任务,一个工作树", - "body": "想同时做两件事,就打开“新建会话”并选择“工作树”。每个工作树都有自己的检出,所以两个智能体不会改到同一批文件。" + "body": "想同时做两件事,就打开“新建”并选择“工作树”。每个工作树都有自己的检出,所以两个智能体不会改到同一批文件。" }, "menu": { "title": "随时回来查看", diff --git a/native/i18n/locales/zh-cn/tourWorktrees.json b/native/i18n/locales/zh-cn/tourWorktrees.json index fe99f15b6..7892fb68f 100644 --- a/native/i18n/locales/zh-cn/tourWorktrees.json +++ b/native/i18n/locales/zh-cn/tourWorktrees.json @@ -4,7 +4,7 @@ "open": { "title": "在工作树中开始任务", "body": "工作树给每个任务独立的检出和分支,所以它的智能体永远不会改动你主检出里的文件。", - "hint": "打开“新建会话”以继续" + "hint": "打开“新建”以继续" }, "pick": { "title": "选择“工作树”", @@ -26,7 +26,7 @@ }, "card": { "title": "独立的检出", - "body": "新会话有自己的检出区块,标题栏显示分支名。智能体在那里工作,不会改动主检出中的文件。" + "body": "行上的分支标记表示它在独立的检出中工作;把指针停在上面即可看到是哪个分支。它的智能体不会改动主检出中的文件。" }, "branch": { "title": "当前会话的分支",