From 267909ba6c9aadcc82534fce605f77ad027930c1 Mon Sep 17 00:00:00 2001 From: minhn4 Date: Mon, 20 Jul 2026 18:04:58 +0700 Subject: [PATCH] feat(tui): move the editor context label to the sidebar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The prompt footer's right-side group is crowded, and the open editor file plus its selected range sit closer in kind to the sidebar's ambient session state than to the footer's keybind hints. Render them in the sidebar footer instead, above the cwd:branch line, marked with a bullet that is accented while the selection is pending and muted once it has been sent. With the sidebar hidden the label is not shown at all. The label was not derived purely from useEditorContext(): the prompt gated it on a prompt-local dismissedEditorSelectionKey signal, and that same gated selection is what the prompt attaches on submit. A sidebar reading the raw editor.selection() would advertise context in exactly the case where the prompt has dismissed it and won't send it. So the effective selection moves into the fork-only context/editor-label.tsx (selection/state/dismiss), mounted in app.tsx inside EditorContextProvider; the prompt's three remaining consumers read from it. Formatting and the view go to the fork-only sidebar/editor-context-label.tsx following the directory-label.tsx precedent — a pure function plus a presentational component, both testable without booting the app. Co-Authored-By: Claude Opus 4.8 (1M context) --- CHANGELOG.md | 7 ++ DIVERGENCES.md | 3 + packages/tui/src/app.tsx | 15 ++-- packages/tui/src/component/prompt/index.tsx | 68 +++---------------- packages/tui/src/context/editor-label.tsx | 49 +++++++++++++ .../sidebar/editor-context-label.tsx | 46 +++++++++++++ .../src/feature-plugins/sidebar/footer.tsx | 17 +++++ .../tui/test/editor-context-label.test.ts | 66 ++++++++++++++++++ .../test/sidebar-footer-editor-label.test.tsx | 43 ++++++++++++ 9 files changed, 249 insertions(+), 65 deletions(-) create mode 100644 packages/tui/src/context/editor-label.tsx create mode 100644 packages/tui/src/feature-plugins/sidebar/editor-context-label.tsx create mode 100644 packages/tui/test/editor-context-label.test.ts create mode 100644 packages/tui/test/sidebar-footer-editor-label.test.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index c11e1d5666..85c74433a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,13 @@ file is the human-readable summary of what changed and why. ### Sidebar +- **Editor context moved to the sidebar** — the open editor file and selected + line range (e.g. `footer.tsx#42-58`) no longer sit in the prompt footer's + right-side group. They render in the sidebar footer instead, just above the + `cwd:branch` line, marked with a bullet that is accented while the selection + is still pending and muted once it has been sent. With the sidebar hidden the + label is not shown at all. + - **Hidden-sidebar hint shows while busy** — the `ctrl+b N todos` hint from [#69](https://github.com/quickbeard/codev-code/pull/69) now also renders while a turn is running (next to `esc interrupt`), not just when the session is diff --git a/DIVERGENCES.md b/DIVERGENCES.md index f8c280b88c..9096aaf234 100644 --- a/DIVERGENCES.md +++ b/DIVERGENCES.md @@ -91,6 +91,7 @@ from the squash message first, or use a plain merge. | `packages/opencode/src/cli/ui.ts` | `wordmark`/`logo()` render the lowercase codev wordmark via `ansiWordmark` (bold brand teal + drop shadow on TTY) | Help banner matches the TUI home banner. | Keep our wordmark + logo(); take upstream's surrounding changes. | | `packages/tui/src/util/presentation.ts` | Local logo copy replaced by the shared `ansiWordmark` (brand teal + drop shadow) | Presentation-mode wordmark was still upstream-branded. | Keep our wordmark lines; take upstream's surrounding changes. | | `packages/tui/src/feature-plugins/sidebar/footer.tsx` | Removed the footer's brand + version line entirely (upstream's two-tone "Open"+"Code" spans, status dot, and `app.version`); the `cwd:branch` path is now the last footer item | The fork's sidebar doesn't advertise the product name/version; the path takes that bottom slot. (Supersedes the earlier single-"CoDev"-span rebrand of this line.) | Keep the line deleted; take upstream's surrounding changes. | +| `packages/tui/src/feature-plugins/sidebar/footer.tsx` | Added the editor-context label above the `cwd:branch` line: `useEditorLabel()` (fork-only `src/context/editor-label.tsx`) supplies the effective selection, an `editorFile` memo formats it via `editorContextFileLabel(...)` at a fixed width of 36 (the sidebar's 42 columns less 2 of padding a side and 2 for the bullet), and `` renders it — both from the fork-only `./editor-context-label.tsx`. | The open file + selected range belong with the sidebar's other ambient session state rather than in the prompt footer's crowded keybind-hint row; they sit next to the cwd for a single "where am I working" group. Moved out of the prompt footer, which no longer shows it at all. | Keep the `useEditorLabel` import, the `editorFile` memo, and the `` element as the box's first child; take upstream's changes to the path display below it. | | `packages/tui/src/feature-plugins/sidebar/lsp.tsx` | Whole LSP section wrapped in `` so it renders nothing when `config.lsp` is falsy; the "LSPs are disabled" placeholder text removed (empty state is only "LSPs will activate as files are read") | A disabled feature shouldn't occupy sidebar space with a permanent placeholder. | Keep our `Show` wrapper + removed placeholder; take upstream's surrounding changes. | | `packages/opencode/src/cli/cmd/*.ts` (tui, run, serve, attach, pr, upgrade, uninstall, web) | Help `describe` strings "opencode" → "codev" | `--help` is the first thing users read. | Keep our strings. | | `packages/tui/src/app.tsx` | Terminal title "OpenCode"/"OC \|" → "CoDev Code"/"CC \|"; the configure-gate effect is a stateless forced-setup invariant — while `sync.status === "complete" && !useConnected() && dialog.stack.length === 0` it (re)opens the fork's `DialogConfigure` (component/dialog-configure.tsx, new file), so escaping any gate-launched flow or a credential-only save bounces back to the gate instead of an unconfigured chat (gates on `!useConnected()`, not `provider.length === 0` — hosted Zen free models always register); added the `codev.configure` command (`/configure`) and a `CODEV_CONFIGURE=1` mount hook for `codev configure`; home screen skipped — plain startup seeds the `dummy` session route and auto-opens a new empty session (reusing a leftover default-titled empty one via `openNewSession`/`findEmptySession`), `session.new` and the current-session `session.deleted` handler open a new session instead of navigating home, and the `-c` resolver prefers non-default-titled sessions so it lands on the last real conversation; added the `app.exit.confirm` command + `EXIT_CONFIRM_WINDOW` const (double-press Ctrl+C to quit: first press shows a toast, second within 1.5 s exits) and gathered its `app_exit_confirm` binding alongside `app_exit` | Tab title branding; first-run setup is a forced gate the user can't escape into an unconfigured chat (the invariant reopens it); `codev` starts directly in the session layout instead of the home screen; a stray Ctrl+C no longer quits on the first press. | Keep our strings, the invariant gate effect, dialog swap + command block, route seed, `openNewSession`/`findEmptySession` + call sites, the `-c` default-title filter, and the `app.exit.confirm` command + binding; take upstream's surrounding changes. | @@ -116,6 +117,8 @@ from the squash message first, or use a plain merge. | `packages/tui/src/component/prompt/index.tsx` | Gated the prompt footer's model/provider indicator on `useConnected()` (the shared "a real provider is configured" predicate) | Don't advertise the free hosted Zen default (e.g. "Big Pickle · OpenCode Zen") in the footer while nothing is configured — same rationale and predicate as `app.tsx`'s startup gate and the provider/model filters. A configured gateway/real provider, or a deliberately-authenticated opencode/opencode-go, still shows its model. | Keep the extra `Show` condition; take upstream's surrounding changes. | | `packages/tui/src/component/prompt/index.tsx` | Added a `directoryLabel` memo (abbreviated cwd, `:branch` suffix when known, middle-truncated; last path segment + branch in text color, parent path muted, matching the sidebar footer) rendered as the first item of the prompt footer's right-side group, left of the editor open-file label. The memo delegates to `directoryFooterLabel(...)` and the render goes through a `