Skip to content

feat(tui): sidebar polish, ESC navigation, syntax highlighting fix, auto-open#33

Merged
EngineerProjects merged 6 commits into
mainfrom
dev
Jun 6, 2026
Merged

feat(tui): sidebar polish, ESC navigation, syntax highlighting fix, auto-open#33
EngineerProjects merged 6 commits into
mainfrom
dev

Conversation

@EngineerProjects

Copy link
Copy Markdown
Owner

Summary

  • Sidebar overflow fixed: relayout() now sizes the chat viewport at chatW (not contentW) when the sidebar is open, so JoinHorizontal always stays within terminal bounds. Header lines and file-path labels are clamped to innerW via ansi.Truncate.
  • Sidebar mouse scroll fixed: switched from a full pointInRect check (X+Y) to X-coordinate-only detection — any wheel event with msg.X >= detailX scrolls the sidebar. The previous Y-range check was silently failing due to minor height-computation differences between Update and View cycles.
  • Auto-open sidebar: AddToolProgress sets detailOpen = true when a new auto-expand tool (write_file, edit_file, apply_patch, bash, spawn_agent) is created; the model calls relayout() immediately.
  • Soft-wrap in sidebar code view: continuation lines are indented by numColW spaces; inline preview still truncates for compact height.
  • ESC key flows: busy → cancel agent; sidebar open → close sidebar; idle + sidebar closed → return to Home page (both focus modes).
  • Syntax highlighting fix: renderCodeBody now pads hlLines to len(display) when chroma trims a trailing newline (blank last line → length mismatch → old code fell back to plain white text).
  • list_directory JSON output: FormatResult now emits JSON so the TUI can parse structured directory data.
  • Permission dialog: scrollable preview, glamour markdown, full-row diff backgrounds, fixed Deny button split-line bug.
  • Examples: add pathfinding_demo Python project and research documents.

Test plan

  • go build ./... passes
  • go test -race ./... -timeout 300s — all green
  • gofmt -l . — no unformatted files
  • go vet ./... — clean
  • golangci-lint run --timeout=5m — clean
  • Manual: sidebar scrolls with mouse wheel when content overflows
  • Manual: Write File inline preview always shows syntax colors
  • Manual: ESC cancels agent when busy; returns to Home when idle
  • Manual: sidebar auto-opens when a supported tool starts

… input

Tool inline display:
- Add syntax-highlighted code previews with line numbers (chroma, dracula theme)
- Add diff coloring (+/- lines) for edit_file, write_file, apply_patch
- Add bash inline preview: `$ cmd` + output, truncated to 10 lines
- Remove border boxes from all inline previews (no panelBox wrapper)
- Auto-expand write_file, edit_file, apply_patch, bash, spawn_agent on completion
- read_file closed by default; removed from auto-expand list
- Fix per-line truncation in renderCodeBody to prevent overflow (ansi.Truncate)
- Fix renderPlainBody/renderBashInline split-before-escape bug
- Adjust bodyWidth to account for removed border (width-4 instead of width-8)

Permission dialog:
- Redesign as wide centered overlay (60–110 cols) with yellow border
- Show tool name, working directory, file/URL/command context
- Show diff preview for edit/write/patch, code block for bash
- Remove //// fill from header
- Replace bordered buttons with simple colored [y]/[a]/[n] key labels (right-aligned)
- Add drop shadow (░ chars) for visual elevation without background color
- Propagate engine Metadata (tool_name, tool_input, working_directory) through
  PromptRequestMsg so the dialog has full context

Input auto-grow:
- Fix resizeInput() to count visual wrap lines, not just explicit newlines
- A long line that wraps due to width now correctly grows the textarea
- Input expands row by row up to maxHeight=10 then becomes scrollable
… input

Tool inline display:
- Add syntax-highlighted code previews with line numbers (chroma, dracula theme)
- Add diff coloring (+/- lines) for edit_file, write_file, apply_patch
- Add bash inline preview: `$ cmd` + output, truncated to 10 lines
- Remove border boxes from all inline previews (no panelBox wrapper)
- Auto-expand write_file, edit_file, apply_patch, bash, spawn_agent on completion
- read_file closed by default; removed from auto-expand list
- Fix per-line truncation in renderCodeBody to prevent overflow (ansi.Truncate)
- Fix renderPlainBody/renderBashInline split-before-escape bug
- Adjust bodyWidth to account for removed border (width-4 instead of width-8)

Permission dialog:
- Redesign as wide centered overlay (60–110 cols) with yellow border
- Show tool name, working directory, file/URL/command context
- Show diff preview for edit/write/patch, code block for bash
- Remove //// fill from header
- Replace bordered buttons with simple colored [y]/[a]/[n] key labels (right-aligned)
- Add drop shadow (░ chars) for visual elevation without background color
- Propagate engine Metadata (tool_name, tool_input, working_directory) through
  PromptRequestMsg so the dialog has full context

Input auto-grow:
- Fix resizeInput() to count visual wrap lines, not just explicit newlines
- A long line that wraps due to width now correctly grows the textarea
- Input expands row by row up to maxHeight=10 then becomes scrollable
Sidebar layout & overflow:
- Fix root cause of sidebar overflowing terminal width: relayout() now
  sizes the chat viewport at chatW (not contentW) when sidebar is open,
  so leftContent is exactly chatW wide and JoinHorizontal stays within
  contentW bounds
- Clamp all sidebar header lines to innerW via ansi.Truncate; truncate
  file-path labels in detailBody to prevent box expansion
- Lower innerW minimum from 24 to 10 (removes artificial floor)
- Soft-wrap code lines in the detail sidebar with continuation indent
  (numColW spaces); inline preview still truncates for compact height

Sidebar mouse scroll:
- Switch from a full pointInRect check to X-coordinate-only detection:
  any wheel event with msg.X >= detailX goes to the sidebar viewport.
  The Y-range check was unreliable due to minor height-computation
  differences between Update and View cycles

Auto-open sidebar:
- AddToolProgress opens detailOpen=true when a new auto-expand tool
  (write_file, edit_file, apply_patch, bash, spawn_agent) is created
- Model detects the state change and calls relayout() automatically so
  the chat width is immediately narrowed to match the new layout

ESC key behaviour:
- ESC while agent is busy (m.busy=true): cancel the running agent
- ESC in uiFocusMain with sidebar open: close sidebar (existing)
- ESC in uiFocusMain with sidebar closed, agent idle: go to Home page
- ESC in uiFocusEditor, agent idle: go to Home page
- Permission dialog ESC still denies the pending permission

Syntax highlighting fix:
- renderCodeBody: when chroma trims a trailing newline (last display
  line is blank → join produces trailing \n → TrimRight removes it →
  one fewer output line), pad hlLines back to len(display) with empty
  strings instead of falling back to uncolored plain text

list_directory:
- FormatResult now emits JSON instead of Go map fmt.Sprintf, so the
  TUI can parse structured directory data correctly

Permission dialog:
- Scrollable preview (↑↓/pgup/pgdn), markdown via glamour, diff with
  full-row green/red backgrounds, fixed Deny button split-line bug

examples:
- Add pathfinding_demo Python project (BFS + A* on a 20×20 grid)
- Add research documents to examples/researchs/
@EngineerProjects EngineerProjects merged commit 7a6f96b into main Jun 6, 2026
10 checks passed
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