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.
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.
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.
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.
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.
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.
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.
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.
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
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
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.
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.
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
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.
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.
- 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)
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.
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.
- 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
- 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
- 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
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
- 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
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.