Commit Graph

422 Commits

Author SHA1 Message Date
Levi Neely 183f30ca23 Add integrated chat minimap 2026-08-16 14:43:14 +02:00
Levi Neely b0e46fdfbc Add chat scroll-to-bottom button 2026-08-16 13:08:38 +02:00
Levi Neely 57c95e3192 Scroll chat to bottom on startup 2026-08-16 13:07:10 +02:00
Levi Neely b28330b5d5 Simplify chat pane scrolling 2026-08-16 13:02:46 +02:00
Levi Neely 8103d80df2 Load chat history when chat pane starts 2026-08-16 12:59:36 +02:00
Levi Neely 541ef48bb7 Refactor GUI into session tree and chat pane components 2026-08-16 12:56:49 +02:00
Levi Neely 0e163f6ee6 gui: fix focus stealing from dialogs during session tree rebuild
buildSessionTree() and updateSessionTree() now save/restore
Window.activeFocusItem instead of only promptInput.activeFocus.
This prevents sessionTreeModel.clear() from pulling focus out of
open modal dialogs (NewSessionDialog, NewAgentDialog).

Also add forceActiveFocus() on dialog open so the first field is
immediately focused.
2026-08-14 14:27:37 +02:00
Levi Neely f136c3e534 revert: scroll fix caused issues, restore positionViewAtEnd 2026-08-13 22:37:12 +02:00
Levi Neely 5057b1a3dd gui: fix scroll jitter — use contentY instead of positionViewAtEnd, increase timer interval 2026-08-13 22:30:59 +02:00
Levi Neely 18b36c09cd Add ollie:// KIO worker for Dolphin
Implements a KIO worker that maps ollie:///path to the Ollie 9P
namespace. Supports listing, reading, writing, mkdir, delete, and
rename — all operations Dolphin needs for full file manager integration.

Works with both KF5 (RealWorkerFactory) and KF6 (WorkerFactory).
Type ollie:/// in Dolphin's location bar to browse sessions and agents.
2026-08-13 12:26:15 +02:00
Levi Neely 739fba2462 fix: ollie-session-here uses default session, agent named by directory 2026-08-12 16:21:05 +02:00
Levi Neely 08cd2b6eac fix: remove unnecessary session creation from ollie-ask
generate endpoint doesn't require a session
2026-08-12 16:19:26 +02:00
Levi Neely 3f73f09688 fix: update dolphin scripts for session/agent model
- ollie-session-here: pass cwd= when creating agent
- ollie-ask: create default session and agent before generate
2026-08-12 16:18:54 +02:00
Levi Neely b6a7d93d0e gui: fix prose-after-fence overwriting finalized code segment
In incrementalAppend(), when a prose line follows a closed code fence,
the code checked only whether the last segment was type Text (which code
fences also are) and then tried to append. Since the finalized fence HTML
ends in </pre> not </div>, it fell into the 'shouldn't happen' branch and
overwrote the segment with escapeForHtml(proseLines) — destroying the
rendered tool output.

Tool blocks are always shaped:
  ```
  <output>
  ```
  <blank>
  <blank>

so the trailing blank lines triggered this on every tool call, leaving
only <div>\n</div> in renderedHtml.

Fix: gate extension on the segment actually being an in-progress prose
segment (trailing </div>). Otherwise start a new prose segment.

Verified: tool blocks now render 'hi\nexit: 0', file_glob results, and
syntax-highlighted diffs correctly.
2026-08-09 12:14:04 +02:00
Levi Neely ed74d421c3 gui: fix tool block rendering — use blockRenderedHtml directly
The Repeater-over-segments approach was failing to display tool output.
When a complete block arrives in one streaming chunk, QML's Repeater
with a var-typed model doesn't reliably re-render delegates on property
changes.

Fix: use a single TextEdit bound to blockRenderedHtml for all non-diagram
blocks. The Repeater path is retained only for blocks containing diagrams
(which need the Loader/component switching). This is simpler, more
reliable, and avoids the Repeater delegate lifecycle issues.
2026-08-09 12:09:42 +02:00
Levi Neely 59e1992f37 gui: emit dataChanged on block close for segment updates
When a complete block arrives in a single streaming chunk, the QML
Repeater may not pick up intermediate segment updates because the
event loop hasn't run. Emit an explicit dataChanged with SegmentsRole
when [[[end]]] closes a block, ensuring the delegate shows the final
rendered content.
2026-08-09 11:57:49 +02:00
Levi Neely c6da563109 gui: update slash command hints to match ctl surface
The agent now routes all /commands to ctl. Update the autocomplete
hint list to reflect current ctl commands.
2026-08-09 03:17:21 +02:00
Levi Neely 26076b0ae9 gui: read chat.raw for block-structured stream
The 'chat' file now serves filtered text (no markers/fences).
GUIs that parse block structure need chat.raw.
2026-08-09 01:43:19 +02:00
Levi Neely eed4a1089e gui: restore scroll-follow with debounced Timer
Use a 16ms Timer restarted from onContentHeightChanged and
onCountChanged. The timer fires after the polish pass completes,
avoiding the recursive layout loop that the old synchronous
positionViewAtEnd() caused.
2026-08-09 00:16:46 +02:00
Levi Neely 3525637d60 gui: chat stream always-on while agent is selected
Change m_chat from Oneshot to Guarded with the same guard as
m_state (daemon connected + session + agent selected). The fd
stays open continuously; it closes on agent switch or program exit.

Removes the demand-driven start/stop logic from handleEvent() and
submit() — no longer needed since streaming doesn't cause layout
thrash after the earlier fixes.
2026-08-09 00:14:32 +02:00
Levi Neely 93eba4442d gui: incremental rendering for chat blocks (O(n) → O(1) per line)
Previously, every streamed line triggered a full rebuild of the
block's HTML: reparsing all content, re-running syntax highlighting
on every code fence from the start. For a block with n lines this
was O(n) per line = O(n²) total.

Now appendContent() uses incrementalAppend() which:
- Prose: escapes only the new line and appends to the segment HTML
- Code fences: saves KSyntaxHighlighting::State between lines and
  only highlights the new line (O(1) per line)
- Fence close: finalizes segment, requests diagrams as before
- Partial line display: uses cached state, no full re-highlight

Full rebuildBlockHtml() is retained only for diagram reply callbacks
where the entire segment needs reconstruction.

Also adds BlockRenderState to ChatBlock for tracking incremental
parse position, highlight state, and accumulated HTML.
2026-08-09 00:12:22 +02:00
Levi Neely 022980bc40 gui: fix infinite layout loop in chat ListView
The delegate used a ColumnLayout root with parent-dependent width
fallbacks (: 0, : 100) causing two-pass layouts. Combined with
onContentHeightChanged -> positionViewAtEnd(), this created a
feedback loop: height change -> scroll -> refill -> new delegates ->
height change -> ... burning 100% CPU on the main thread.

Fixes:
- Replace onContentHeightChanged with onCountChanged + Qt.callLater
- Replace ColumnLayout root with plain Column
- Bind all child widths to root.width (top-down, no fallbacks)
- Create context Menu lazily on first right-click
- Add reuseItems: true to the ListView
- Standardize bin path to ~/.local/bin
2026-08-09 00:03:37 +02:00
Levi Neely 51b2013ac3 gui: fix deadlock — demand-driven chat streaming
The chat stream (ollie-9p read .../chat) blocks forever waiting for
data. Starting it on agent switch meant stopStreams() would block the
main thread trying to kill a hung process.

Fix: stream chat only while the agent is active.
- submit() starts the chat stream (agent is about to become active)
- Event handler stops chat on idle transition, starts on non-idle
- switchAgent() only starts chat if agent is already non-idle
- NativeStreamer::stop() uses SIGTERM+200ms then SIGKILL+100ms
  instead of immediate SIGKILL+1000ms
2026-08-08 23:20:03 +02:00
Levi Neely 66aecc8315 Revert "gui: fix freeze on agent switch — bulk load chat blocks"
This reverts commit a3826f2ce8.
2026-08-08 23:15:48 +02:00
Levi Neely a3826f2ce8 gui: fix freeze on agent switch — bulk load chat blocks
appendContent was calling rebuildBlockHtml (full syntax highlighting)
on every single line during initial log load. For a 1000-line chat,
that's O(n²) highlighting passes.

Add beginBulkLoad()/endBulkLoad() — skips per-line rebuilds during
bulk, then rebuilds all blocks once at the end. QML load sites now
wrap appendData(log) with bulk mode.
2026-08-08 23:14:55 +02:00
Levi Neely e24d332d50 gui: auto-switch to newly created agent, remove remote field from agent dialog
createAgent now returns the new agent ID so the dialog can immediately
switch to it. Previously the first agent created required a GUI restart
to select.

Also removes the Remote field from NewAgentDialog — remote belongs to
the session, not the agent.
2026-08-08 14:02:10 +02:00
Levi Neely 70390097b0 fix KF6 auto-detect on distros without monolithic KF6Config.cmake 2026-08-07 18:58:42 +02:00
Levi Neely a4c6802430 gui: add scroll-to-bottom button
Shows when user has scrolled up (followTail=false). Clicking scrolls
to bottom and re-enables follow mode.
2026-08-07 18:53:32 +02:00
Levi Neely 4b21deec14 gui: fix scrolling to follow content
Use onContentHeightChanged with a re-entry guard to scroll as content
renders. Works for both initial log load and streaming responses.

- followTail tracks user preference (updated on scroll end)
- scrollingNow prevents recursive positionViewAtEnd calls
2026-08-07 18:51:20 +02:00
Levi Neely cde0284bad gui: fix scrolling - use contentHeight not timer
Replace timer-based scroll hack with event-driven approach:
- onContentHeightChanged triggers scroll when content grows
- onMovementEnded detects when user scrolled away from bottom

Scrolling is now driven by actual content changes, not arbitrary delays.
2026-08-07 18:14:09 +02:00
Levi Neely e10912de08 gui: remove dead code (ninepconnection, streamfsm)
These were replaced by NativeStreamer which uses ollie-9p subprocess
for streaming reads.
2026-08-07 18:07:16 +02:00
Levi Neely 6fda37ae96 nativestreamer: use subprocess instead of blocking thread
Go blocking reads can't be interrupted by closing the fid from another
thread. Revert to subprocess-based streaming using ollie-9p, which can
be killed cleanly.

Native library is still used for all request/response operations.
Only streaming (chat, statewait, eventwait) uses subprocess.
2026-08-07 18:05:53 +02:00
Levi Neely 16883248f0 nativestreamer: fix thread cleanup race
- Disconnect finished signal before waiting in stop() to prevent
  onThreadFinished from running after thread is deleted
- Use deleteLater() in onThreadFinished for safe cleanup during restart
- Remove redundant quit() call (QThread::create threads have no event loop)
2026-08-07 18:03:43 +02:00
Levi Neely ca4dc2d412 gui: eliminate all subprocess calls, use native 9P streaming
Replace StreamFsm and NinePConnection (QProcess-based) with NativeStreamer
which uses the new libollie9p streaming API (open/read_fid/close_fid).

All 9P operations now go through the native library:
- Chat, statewait, eventwait streams use threaded NativeStreamer
- Request/response operations use Lib9pClient directly
- No more subprocess spawning for any 9P operation

Remove ninepBin, ollie9pBin, serverAddr, run9p helper functions.
Remove streamfsm.cpp/h, ninepconnection.cpp/h from build.
2026-08-07 18:02:45 +02:00
Levi Neely 350d74866a gui: use native 9P client instead of subprocess calls
Convert most operations from spawning plan9port 9p subprocess to using
the persistent Lib9pClient connection. This eliminates process spawn
overhead for common operations like submit, interrupt, kill, pause,
resume, rename, and create.

Streaming operations (chat, statewait) still use subprocess because
they need continuous tailing which the native lib doesn't support.

Reduces code by ~70 lines and removes synchronous QProcess waits.
2026-08-07 17:53:15 +02:00
Levi Neely 073cc2158b qml: fix binding loop in ChatBlockDelegate
Rename 'chatView' property to 'parentListView' to avoid name collision
with the ListView id, which caused QML binding loop warnings.
2026-08-07 17:49:26 +02:00
Levi Neely 60c273e94a cmake: auto-detect KF5/KF6, fall back to KF5 if KF6 not found 2026-08-07 17:41:54 +02:00
Levi Neely 2d6e0ed787 gui: extract dialogs and chat delegate into components
Phase 1 of GUI cleanup - component extraction:
- SettingsDialog.qml: theme and font settings (118 lines)
- NewSessionDialog.qml: session creation form (79 lines)
- NewAgentDialog.qml: agent creation form (174 lines)
- ChatBlockDelegate.qml: chat block with text/diagram segments (322 lines)

main.qml reduced from 1685 to 1030 lines (39% reduction).
Updated CMakeLists.txt for both Qt6 and KF5 builds.
2026-08-07 17:40:09 +02:00
Levi Neely bdad2b740f remove scroll-to-bottom button 2026-08-07 17:17:14 +02:00
Levi Neely b77667fbfb Fix QML performance and stability issues
- Fix TypeError by using explicit id instead of parent.parent chains
- Remove onContentHeightChanged handler that caused layout thrashing
- Add active guard on Loader to prevent null modelData access
- Simplify blockSegments null checks
2026-08-07 15:25:16 +02:00
Levi Neely 0ac03a9931 Fix chat rendering and improve scroll behavior
- Emit SegmentsRole in dataChanged signals so QML updates properly
- Add onContentHeightChanged to scroll when content loads after session switch
- Add floating scroll-to-bottom button that appears when scrolled up
- Wrap chat ScrollView in Item to allow button overlay
2026-08-07 15:15:05 +02:00
Levi Neely 07232b94df Add PlantUML and Mermaid diagram rendering
- Detect plantuml/mermaid code fences and render as diagrams
- PlantUML: POST to localhost:8080/svg for SVG output
- Mermaid: GET to localhost:8081/img/ with base64 for JPEG output
  (SVG not usable - Qt doesn't support foreignObject)
- Cache rendered diagrams by content hash
- Toggle between source code and rendered image view
- Copy button for source text or image data
- Fall back to source display on render errors
- Add ClipboardHelper for image clipboard support
- Clear diagram cache on session reset
2026-08-07 14:59:20 +02:00
Levi Neely 2ea6ec1ba7 gui: fix scrolling in chat and message input
- Restore ScrollView for message input to enable overflow scrolling
- Remove manual wheel handlers that broke ListView virtualization
- Let wheel events propagate naturally to ListView
2026-08-07 11:20:13 +02:00
Levi Neely df8e69aeb8 gui: I-beam cursor over block content context menu area 2026-08-07 11:01:09 +02:00
Levi Neely f086400bf3 gui: add text selection and context menus
Chat blocks:
- Enable selectByMouse and persistentSelection for text selection
- Add context menu with Copy and Select All
- Disable ListView drag during text selection (preserves wheel scroll)
- I-beam cursor over text content

Prompt input:
- Enable selectByMouse and persistentSelection
- Add context menu with Cut, Copy, Paste, Select All
- Remove ScrollView wrapper (TextArea handles overflow natively)
- I-beam cursor
2026-08-07 11:00:15 +02:00
Levi Neely 624b7ad66d gui: smart auto-scroll follows streaming content
- Add shouldAutoScroll property to track user intent
- Auto-scroll when near bottom (within 50px threshold)
- Disable auto-scroll when user scrolls up to read history
- Re-enable when user scrolls back to bottom
- Reset to auto-scroll on session/agent switch
- Increase timer interval to 16ms for smoother layout settling
2026-08-07 10:21:53 +02:00
Levi Neely 1ca5563fdb gui: stream partial content to UI before newlines
appendData() now emits dataChanged with partial line buffer content
so the UI updates as tokens arrive, not just after complete lines.
This fixes the laggy streaming where text would appear in chunks.
2026-08-07 10:11:14 +02:00
Levi Neely bb1454f85a fix: ollie_ghost compile — stripPrefixEcho signature and forward declarations 2026-08-07 08:59:03 +02:00
Levi Neely 08ec46027e kate: replace ollie-9p complete with generate for code completions
- Build the completion prompt inline (mirrors agent/complete.go prompt)
- Call ollie-9p rdwr generate instead of ollie-9p rdwr complete
- Pass backend/model as JSON fields in the generate request
- StripCompletionNoise and stripPrefixEcho moved into C++ helpers
2026-08-07 07:37:42 +02:00
Levi Neely ab8aa8d719 kate: add 'Start Session' context action
Available without text selection. Ensures a kate session/agent exists
(reuses existing or creates new), sets cwd to the current project
directory, and updates the status bar.
2026-08-06 16:58:02 +02:00