Skip to content

feat(tui): move the editor context label to the sidebar - #110

Merged
quickbeard merged 1 commit into
mainfrom
sidebar-editor-context
Jul 21, 2026
Merged

quickbeard merged 1 commit into
mainfrom
sidebar-editor-context

Conversation

@quickbeard

Copy link
Copy Markdown
Owner

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. They now render in the sidebar footer, 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 — deliberately unlike the cwd:branch treatment in #70, which falls back to the footer.

The part that wasn't just a move

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 src/context/editor-label.tsx (selection() / state() / dismiss()), mounted in app.tsx inside EditorContextProvider. The prompt's three remaining consumers — the prompt.editor_context.clear predicate, the submit path, and the dismiss handler — read from it.

Formatting and the view go to the fork-only feature-plugins/sidebar/editor-context-label.tsx, following the directory-label.tsx precedent: a pure function plus a presentational component, both testable without booting the app. The width cap is a constant 36 — the sidebar is a fixed 42 columns.

Verification

  • bun typecheck clean in packages/tui and packages/opencode.
  • 10 new tests (editor-context-label.test.ts, sidebar-footer-editor-label.test.tsx). Full packages/tui suite: 242 pass / 1 fail — the known-flaky app.exit epilogue test, confirmed failing on a stashed clean tree too.
  • Booted the TUI in tmux and opened the sidebar. This was the real risk: the sidebar footer is a plugin slot view, so if slot content rendered in a detached Solid owner, useEditorLabel() would throw and break the sidebar. It renders fine.

Gap: the populated label is not verified end-to-end — that needs a connected VS Code/Zed pushing a real selection, which the verification environment doesn't have. The render tests cover the pending/sent/none views and the unit tests cover the formatting, but the live wire from an editor selection to those props is unverified by execution.

CHANGELOG.md has an Unreleased entry; DIVERGENCES.md has rows for all three upstream files touched (app.tsx, prompt/index.tsx, sidebar/footer.tsx). The two new files are fork-only and not tracked there.

🤖 Generated with Claude Code

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) <noreply@anthropic.com>
@quickbeard
quickbeard merged commit 6d36ce4 into main Jul 21, 2026
1 of 5 checks passed
@quickbeard
quickbeard deleted the sidebar-editor-context branch July 21, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant