Skip to content

Add the /code slash command and a full-screen source viewer with syntax highlighting - #229

Merged
yumosx merged 14 commits into
mainfrom
simple-code-view
Sep 22, 2026
Merged

yumosx merged 14 commits into
mainfrom
simple-code-view

Conversation

@yumosx

@yumosx yumosx commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Add the /code slash command and a full-screen source viewer with
syntax highlighting, in-file search, CJK-aware column math, and
language-server navigation (definition, references, hover, outline).
LSP servers are discovered on PATH and spawned lazily; without one
the pane stays a plain viewer.
wakeAsync was called from handleKeyLocked, which already holds p.mu.
Go's sync.Mutex is not reentrant, so the second Lock in wakeAsync
permanently froze the UI thread on every LSP query (hover/definition/
references/outline).

Fix: mirror the existing pendingCopy pattern — wakeAsync now only sets
p.pendingWake under the lock, and Handle runs p.wake() after unlocking.

Add TestHoverWakeRunsOutsideTheLock as a regression test; it deadlocks
under the old code (3s timeout) and passes with the fix.
Select lines in the code viewer (v to start, movement extends, a to
add) and they appear as a chip row above the editor, mirroring the
existing pending-skills row. On submit the selected lines are expanded
into a fenced code block prepended to the prompt text.

Changes:
- internal/components/chat/ref.go: Ref type with Label() and Block()
- internal/components/chat/chat_input.go: PendingRefs field,
  AddPendingRef/PopPendingRef/ClearPendingRefs, paintPendingRefs chip
  row, pendingRowsHeight bump, OnPendingRefsChange callback
- internal/tui/composer/pane.go: AddPendingRef/PendingRefs/ClearPendingRefs
  passthroughs
- internal/tui/submit/submitter.go: refs included in the empty-submit
  guard, buildUserDisplay shows 'Refs: path:10-25' label first,
  prompt text gets fenced blocks prepended before user text, refs
  cleared after submit
- internal/tui/codepane/pane.go: line-wise visual selection (v to
  toggle, Esc to cancel), 'a' to add selection to chat, onRef
  callback replacing the dead onSubmit, pendingRef/pendingReload
  staged-callback pattern, selecting field + selAnchor, selection
  highlighted in snapshot via codeview.Selecting/SelStart/SelEnd,
  reload() now runs outside the mutex (same fix as the wakeAsync
  deadlock class)
- internal/tui/editor/editor.go: wires onRef → composer.AddPendingRef
  + FocusChat + toast
- internal/tui/submit/submitter_test.go: stubComposer updated for
  new Input interface methods
Typing /code @scripts/deadcode-check.sh becomes
./scripts/deadcode-check.sh, enabling shell path
completion via the @ trigger.
uriToPath stripped the leading "/" from every uri on windows, so
file:///home/x round-tripped to home\x. only drive paths (file:///C:/x)
own that slash; posix paths keep theirs.
relPath now feeds titles, status rows and copied "file:line" strings
through filepath.ToSlash so they paste cleanly on any os. missing or
unreadable files report "no such file" / "permission denied" via
errors.Is instead of windows' long syscall text.
the abs fallback feeds titles and the clipboard, so it renders with
forward slashes like the relative branch; the test still expected the
os-native form.
/code stays a viewer: syntax highlight, cjk caret, v to select
lines, a to hand them to the composer. the pane reads files itself,
so it answers to the same deny list as the tool gate. panes are
single-goroutine now, so RedrawMsg and Editor.Close are gone.
server discovery, client, manager and nav have no callers since
the code pane went viewer-only.
@yumosx
yumosx merged commit 44004fe into main Sep 22, 2026
9 checks passed
@yumosx
yumosx deleted the simple-code-view branch September 26, 2026 06:32
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