Add the /code slash command and a full-screen source viewer with syntax highlighting - #229
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.