Skip to content

feat(history): add full-history search, cleanup and global timeline navigation - #723

Open
pascalandr wants to merge 9 commits into
devfrom
feat/session-history-queries
Open

pascalandr wants to merge 9 commits into
devfrom
feat/session-history-queries

Conversation

@pascalandr

@pascalandr pascalandr commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Combine full-history search/counts and technical cleanup with a global timeline and direct message-window navigation through the existing bundled native pruning plugin.

  • Cleanup: plan from stored history, including pre-compaction messages, using IDs, content revisions and counts. Execute bounded batches with progress/cancellation and explicit skipped/failed-message reporting.
  • Counts and search: refreshable history snapshots, entire-session/workspace scope, optional technical content and bounded excerpts. Current-session results jump directly to the selected passage; other-session results open a single-message preview.
  • Global timeline: lightweight metadata covers the whole session independently of the resident transcript. Distant clicks load at most 200 destination messages without reading intermediate pages. Search clicks, keyboard navigation and missing restoration anchors share the direct loader.
  • Reading position: retain the visible transcript while loading, let the latest click win, cancel obsolete work on navigation/view changes, overlap adjacent windows and preserve historical reading during live generation.
  • Standard native scrollbars: timeline and transcript share standard geometry. Only marker rectangles narrow; icon dimensions and vertical spacing stay fixed. Timeline extent is calculated from measured marker/gap primitives rather than estimated hidden rows.
  • Session return: retain four recent metadata-only outlines across view unmounts; interrupted scans resume their accepted cursor. Reuse the completed rail immediately while refreshing, and expose progress during the initial scan. Search excludes tools/reasoning by default.
  • Keep search non-modal, preserve keyboard focus and translate new visible strings in every supported locale.
  • Keep unchanged timeline marker identities stable during streaming; manual rail browsing cancels a pending automatic reveal, so a second destination remains clickable during a slow jump.

Implementation and boundaries

  • Dedicated CodeNomad routes expose fixed history, pruneBatch, outline and window operations. Generic RPC proxy access remains closed.
  • A shared helper binds read-only SQLite access to the authenticated daemon through a fresh plugin-storage challenge. Ownership includes native directory/project/legacy workspace identity; navigation rechecks session location, project, revert and workspace authorization before publication.
  • History queries scan at most 32 rows per page; outlines return up to 256 compact entries with a sequence horizon. Navigation reads yield every 16 rows and bound parsed page payloads to 24 MiB / 16 MiB per message. Scheduler waits no longer fragment an outline into tiny pages.
  • Direct windows use indexed native sequence order, a read transaction, at most 200 messages and a 24 MiB total payload budget. Neighbor windows overlap by 16 messages. Missing targets or oversized windows fail explicitly.
  • CodeNomad anchor cursors are explicitly namespaced and never sent to native APIs. Existing native cursors remain supported; truncated newer-page paths can use a resident anchor instead of replaying intermediate pages.
  • Publication retains request epochs, instance/connection generations, mutation revisions, cancellation and the stronger latest-window streaming checks. Historical content does not replace the composer's model/agent choice.
  • Workspace query contributions are authorized per location, including independent clones sharing project IDs. Cleanup retains synchronous per-message transactions, durable native execution-claim fences, revision checks and atomic retry receipts.

User-visible semantics

  • Search is literal/case-insensitive, with one excerpt per matching message and one resident result page. Attachments and opaque continuation state are not searched.
  • Counts and outlines are refreshable metadata snapshots. Initial scanning is proportional to history size; destination-window loading does not traverse the distance to the target.
  • Staged undo stays hidden. Deleted navigation targets report a conflict while retaining the current page.
  • Cleanup is atomic per message, not across a whole session. Active/changed messages are refused. Cancellation stops subsequent batches; an already dispatched batch may commit.

Validation

  • Original history implementation: 56 server/plugin/route tests, 45 UI-store tests, 43 Chromium transcript regressions and 8 Chromium search/utility-window tests.
  • Navigation extension: 55 server/plugin/route tests; 75 UI-store tests; 56 distinct Chromium cases covering transcript/window regressions, distant jumps, rapid competing targets, hidden-session cancellation, search click/keyboard navigation, streaming and restoration.
  • Full-stylesheet geometry assertions cover overflow, hover, focus, RTL and 125% zoom; icons and marker heights remain identical with and without the gutter. Rendered captures inspected.
  • Server/UI typechecks, production UI build, bundled plugin build and diff checks pass.
  • Real isolated Windows OpenCode 2.0.5: 241-message counts/search/cleanup with preserved text and replayable receipts; 1,501-message navigation with complete window payloads compared against native export and single-message reads. Existing native concurrency, active-generation refusal, pre-compaction, presence/restart and ownership regressions pass.
  • Follow-up fixes: all 14 Chromium navigation cases, including mixed-height native thumb gestures, exact rail extent, visible passage alignment, adjacent windows, global endpoints, keyboard ownership, interrupted outline resumption and completed-rail reuse across unmounts. The transcript regression suite also passed (43 cases), with 17 affected cases rerun after follow-state ordering changes.
  • Seven updated navigation/store/route cases and server/UI typechecks pass. The complete isolated native Windows OpenCode 2.0.5 UI fixture was rerun successfully with full 256-entry outline-page assertions. Packaged-resource smoke checks pass.

Native fixtures use synthetic isolated DB/config and child daemons. WSL, Linux and macOS are not covered by these Windows checks.

Installed Windows Tauri build: 0.20.0-dev-20260920-c5d9aa40, executable/UI hashes verified. On the real long conversation, a native held-thumb gesture landed at 49.54% with the transcript anchor and pixel offset unchanged. A session-away/return cycle retained 13,815 markers, scroll extent, rail offset and transcript anchor exactly; no history HTTP errors were observed during the subsequent 45-second capture. An earlier intermittent refresh HTTP 500 was observed; the retained completed rail remained usable. User acceptance and final gatekeeper review remain pending.

Documentation and maintenance

See dev-docs/SESSION_HISTORY_QUERIES.md, dev-docs/SESSION_HISTORY_NAVIGATION.md and the updated agent conventions.

Existing oversized files touched, under packages/ui/src/: components/message-section.tsx (~1,525 lines), components/message-timeline.tsx (~654), components/session/session-view.tsx (~694), lib/api-client.ts (~584), stores/opencode-data.ts (~691), stores/session-api.ts (~1,846), stores/session-request-authority.test.ts (~2,029), plus the original history changes in lib/hooks/use-commands.ts (~635) and stores/session-actions.ts (~680). New concerns are isolated in focused modules.

…h native RPC

Replace transcript-wide API downloads with bounded plugin-side history scans. The search window now offers session/workspace scope, message and technical-content snapshots, paginated excerpts and explicit single-message previews that do not populate or displace the resident transcript window.

Plan whole-session technical cleanup using compact IDs, revisions and counts, then execute batches through the existing synchronous SQLite ownership and durable execution-claim fences. Preserve text and pre-compaction history semantics, refuse changed or active content, retain atomic retry receipts, and expose progress, cancellation and partial failures.

Bind reads to the authenticated daemon storage, constrain cursors and payload sizes, and validate every contributing location against local worktree ownership before publishing workspace counts or excerpts. Keep native RPC access narrow, preserve migrated global history, add translations for all locales, and retain search-input focus with the new controls.

Validation: 56 server/plugin/route tests, 45 UI store tests, 43 transcript browser regressions and 8 search/utility-window browser tests passed. Server/UI typechecks, the UI build and bundled plugin build passed. The isolated Windows OpenCode 2.0.5 fixture verified 241-message counts/search/cleanup, exact batch retries, active-claim refusal, pre-compaction discovery and existing concurrency/cache behavior. Desktop release interaction and other native platforms remain separate validation.
Extend the existing history-query plugin with bounded outline and anchor-window reads so timeline and current-session search can reach distant passages without loading intervening transcript pages. Share daemon-storage identity binding, preserve location/project/revert authorization, enforce payload budgets and retain overlapping neighbors for reading-position restoration.

Route timeline, search and missing restoration anchors through the existing message-load authority fences. Keep the visible transcript during navigation, let the latest requested destination win, reject late results after cancellation or leaving the session, and retain historical reading positions during live generation.

Restore a discreet timeline scrollbar with stable reserved geometry. Only marker rectangles narrow; icon dimensions and vertical spacing remain fixed across hover, focus, RTL and fractional zoom. Include localized loading/retry UI and document the navigation contract.

Validated with server/plugin/route regressions, 75 UI store tests, 56 distinct Chromium cases, server/UI typechecks, UI/plugin builds and an isolated Windows OpenCode 2.0.5 fixture comparing 1501-message navigation against native export and message reads. Installed desktop and other-platform validation remain separate.
@pascalandr pascalandr changed the title feat(history): query full sessions and clean technical content without loading transcripts feat(history): add full-history search, cleanup and global timeline navigation Sep 20, 2026
@pascalandr

Copy link
Copy Markdown
Contributor Author

Additional isolated target-runtime qualification: published head 5b988ec passes scripts/test-session-pruning-native.mjs with the official Windows x64 OpenCode 2.0.11 CLI and unchanged client/plugin 2.0.4. Includes 241-message counts/search/complete technical cleanup and batch receipts; 1501-message outline/distant windows/overlap/native payload and restore parity; surrounding proxy, worktree, event-relay, plugin lifecycle and pruning concurrency/history checks. Synthetic fixture DB only, no shared daemon or user storage. #728 records the evidence and upgrades client/plugin separately; the combined merge will still need its own native rerun.

Update two source-level regression assertions left over from exhaustive resident-transcript search. The current implementation guards its local locator directly and publishes a bounded native-query result page with an atomic active-index reset.

Retain the synchronous raw-query invalidation and batched-publication invariants. All 23 pagination tests pass; direct search click and keyboard navigation are additionally covered by the Chromium history-navigation fixture. This changes tests only and leaves the rebuilt desktop artifacts unchanged.
Cancel deferred active-marker reveals when the reader scrolls or interacts with the global rail, and reveal without a smooth animation. A previous selection must not move or unmount the next click target while its distant window is still loading.

Extend the Chromium latest-intent regression to keep the next destination visible beyond the reveal delay. Update the isolated native pruning UI fixture to proxy history routes and provide the same service-location inventory used by whole-session cleanup.

Validated all five browser navigation cases, the UI typecheck, packaged-resource smoke checks, and the complete isolated OpenCode 2.0.5 native/UI pruning fixture, including whole-session confirmation and persistence after reload.
Keep unchanged outline projections referentially stable within each message section. Virtua keys its rows by item identity, so rebuilding historical marker objects on resident updates remounted distant hover, focus and automation targets during generation.

Bound the projection cache to the current outline and compare all generated presentation fields, including tool-part identities, so changed content and locale labels still update normally.

Add a real-component Chromium regression proving that a new resident streamed message retains a distant marker's DOM node, and verify historical-window streaming too. The new test fails without identity reuse and passes with it; all six history-navigation tests and the UI typecheck pass.
Replace estimated timeline row measurements with an exact virtual layout derived from the marker and group-gap primitives. Hidden tools no longer contribute estimated heights, and the rail uses the same standard native scrollbar as the transcript: only marker width changes, never icons or vertical spacing. Manual rail browsing suppresses active-marker reveals until a transcript gesture, and intermediate window positions cannot reclaim it.

Keep native transcript thumb drags escaped beyond the ordinary gesture timeout, delay adjacent-window paging until release, and recognize wheel gestures at an already-clamped boundary. Publish follow state before handing boundary callbacks control. Preserve access to first/latest commands at local window edges and default history search to excluding tools and reasoning.

Exercise the real SessionView with mixed long replies, short replies, tools and idle records. Browser regressions verify exact scroll extent, native held-thumb dragging, streaming anchors, distant landing positions, adjacent windows, global endpoints, keyboard ownership, RTL and fractional zoom. The held-thumb regression is red with native drag ownership disabled and green with it; transcript rendering and nested-scroll regressions and UI typecheck pass.
The installed Windows application returned only four metadata entries from a 10,763-message session because the outline's wall-time budget included cooperative event-loop waits. Remove scheduler time from pagination and bound each page by 256 rows and 24 MiB of parsed source payloads instead. Yield every 16 rows in both outline and message-window reads, preserving cancellation without paying one scheduler round trip per message.

Regression coverage advances the clock across each observation, checks full metadata pages, verifies cancellation releases the read transaction, and proves byte-budget pagination retains the first unread message. Strengthen the isolated native fixture to require full small-record pages. Seven navigation/store/route checks and the server typecheck pass.
Keep four recent metadata-only outline snapshots across SessionView unmounts. A hidden or evicted view cancels its active request but retains accepted pages and the sequence-horizon cursor. Returning immediately reuses a completed rail, or resumes its interrupted scan, instead of repeatedly showing only the resident transcript while scanning from zero.

Fence cached metadata by instance/session, connection generation, destructive content revision and staged undo. Message revisions and status transitions refresh completed snapshots without clearing their display; status churn cannot discard an incomplete scan. Show localized initial loading progress so a partial resident timeline is not silently presented as complete.

A real SessionView browser regression pauses the second outline page, changes status, unmounts and returns, then checks cursor reuse and immediate completed-rail restoration. All 14 navigation/browser cases and the UI typecheck pass.
Historical markers rendered a bare paragraph outside the rich MessagePreview surface, leaving its text unbounded and transparent across the application. Use the same small plain-text tooltip for historical and resident markers, with wrapping, an opaque surface, viewport-constrained width and height, and clamped placement on either side of the rail.

Hover no longer mounts a message renderer or reads resident message data. Cancel delayed previews on scrolling and detached markers, dismiss on resize or Escape, and support keyboard focus with tooltip descriptions. A real SessionView regression covers both historical and resident previews, geometry, opaque styling and absence of payload loads; keyboard and native rail-thumb regressions and the UI typecheck pass.
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