Skip to content

Add OpenCode provider support with dashboard#7

Closed
biyiklioglu wants to merge 4 commits into
mdemirhan:mainfrom
biyiklioglu:codex/add-opencode-provider
Closed

Add OpenCode provider support with dashboard#7
biyiklioglu wants to merge 4 commits into
mdemirhan:mainfrom
biyiklioglu:codex/add-opencode-provider

Conversation

@biyiklioglu
Copy link
Copy Markdown
Contributor

@biyiklioglu biyiklioglu commented Apr 13, 2026

Summary

Adds OpenCode as a first-class provider in Code Trail.

This PR brings OpenCode into the same indexing and desktop UX flow as the existing providers, covering discovery, parsing, indexing, search, provider filters, dashboard stats, settings, edit rendering, and exports. It also includes a small app-state migration so older saved configs automatically pick up the new provider instead of silently leaving it disabled.

What Changed

  • Added opencode to the canonical provider surface and provider-driven contracts
  • Added opencodeRoot discovery config and default platform paths
  • Added SQLite-backed OpenCode discovery from opencode.db
  • Added an OpenCode provider adapter and parser path for session, message, and part rows
  • Normalized OpenCode tool payloads into the existing generic tool/edit flow
  • Extended materialized-source handling to support logical source keys plus physical backing paths
  • Added changed-path expansion so database changes reindex affected OpenCode sessions
  • Added changed-db cleanup for removed OpenCode sessions
  • Surfaced OpenCode in desktop settings, provider displays, dashboard stats, filters, and raw edit rendering
  • Healed legacy saved indexing state so older default provider selections automatically enable OpenCode on startup

Why

OpenCode stores session history differently from the file-backed providers already supported in Code Trail. Without provider-aware materialized discovery and backing-path handling, the app could not reliably treat individual OpenCode sessions as indexable sources.

The app-state migration is included because older installs persisted the pre-OpenCode default enabled-provider list. That left OpenCode supported in code but still disabled in practice until users manually changed settings.

Impact

Users can now index and explore OpenCode sessions in the same way they already use Claude, Codex, Gemini, Cursor, and Copilot history.

That includes:

  • history browsing
  • search
  • provider filtering
  • dashboard/provider aggregates
  • tool/edit rendering
  • AI code activity stats
  • exports

Test Coverage

Test File Coverage
apps/desktop/src/main/appStateStore.test.ts Verifies the legacy enabled-provider migration adds opencode to older default saved configs, and confirms intentional custom provider subsets are preserved.
apps/desktop/src/main/bootstrap.test.ts Covers bootstrap-level provider/config wiring so OpenCode-aware settings and defaults resolve correctly.
apps/desktop/src/main/liveSessionStore.test.ts Updates live-session-related fixtures/config to include OpenCode in provider-aware state handling, while keeping live watch itself out of scope.
apps/desktop/src/renderer/App.test.tsx Covers app-shell behavior with updated provider state, including dashboard loading and reopen refresh paths with OpenCode-aware fixtures.
apps/desktop/src/renderer/components/SettingsView.test.tsx Verifies OpenCode appears in Settings, including provider labels and the OpenCode data root discovery path.
apps/desktop/src/renderer/components/history/ProjectPane.test.tsx Updates provider-count fixtures so project-pane provider displays and counts handle OpenCode.
apps/desktop/src/renderer/components/messages/toolParsing.test.ts Verifies OpenCode-native edit payload fields like filePath, oldString, newString, and content normalize into the existing edit renderer/tool parsing flow.
apps/desktop/src/renderer/features/DashboardView.test.tsx Covers dashboard/provider aggregate rendering with OpenCode included in counts and provider sections.
apps/desktop/src/renderer/features/useLiveWatchController.test.ts Updates provider-count fixtures so live-watch-adjacent controller logic remains stable with the expanded provider set.
apps/desktop/src/renderer/hooks/usePaneStateSync.test.tsx Verifies pane-state sync and provider-based UI preferences handle the added opencode provider.
packages/core/src/contracts/ipc.test.ts Validates IPC schemas and provider-driven payloads accept opencode and the related discovery/settings structures.
packages/core/src/discovery/discoverSessionFiles.pythonFixtures.test.ts Updates fixture-backed discovery expectations to include the OpenCode root in config resolution.
packages/core/src/discovery/discoverSessionFiles.test.ts Verifies OpenCode session discovery from opencode.db, plus changed-path expansion from the DB file to logical session sources.
packages/core/src/discovery/discoverSingleFile.test.ts Verifies a single OpenCode synthetic source key resolves to the correct discovered session, including logical source key and backing DB path.
packages/core/src/indexing/indexSessions.integration.test.ts End-to-end coverage for indexing OpenCode sessions, tool calls, edit file extraction, and cleanup of deleted sessions during changed-db reindexing.
packages/core/src/parsing/providerParsers.test.ts Verifies OpenCode parsing rules for user, assistant, thinking, tool_use, tool_edit, and tool_result, including timestamps and tool payload preservation.
packages/core/src/search/searchMessages.integration.test.ts Covers provider-count and search integration paths with OpenCode included in aggregated search stats.
packages/core/src/testing/inMemory.test.ts Updates in-memory discovery/test fixtures so OpenCode roots participate in shared test setup.
packages/core/src/testing/liveWatchFixtures.ts Extends shared provider-count fixtures with OpenCode so dependent tests stay aligned with the full provider set.

Validation

Passed focused OpenCode coverage across discovery, parsing, indexing, search, app state, settings, dashboard, and app shell:

  • ELECTRON_RUN_AS_NODE=1 ./apps/desktop/node_modules/.bin/electron ./node_modules/vitest/vitest.mjs run apps/desktop/src/main/appStateStore.test.ts packages/core/src/discovery/discoverSingleFile.test.ts packages/core/src/discovery/discoverSessionFiles.test.ts packages/core/src/parsing/providerParsers.test.ts packages/core/src/indexing/indexSessions.integration.test.ts packages/core/src/contracts/ipc.test.ts apps/desktop/src/main/data/queryService.test.ts apps/desktop/src/renderer/components/messages/toolParsing.test.ts apps/desktop/src/renderer/components/SettingsView.test.tsx apps/desktop/src/renderer/features/DashboardView.test.tsx apps/desktop/src/renderer/App.test.tsx packages/core/src/search/searchMessages.integration.test.ts
  • bun run desktop:build

Screenshots

image

Introduce a top-bar dashboard view that surfaces provider, project, session,
message, bookmark, token, tool-call, model, and recent-activity aggregates in
a new renderer layout. Adds hero metrics, provider throughput, category
composition, activity skyline, and top project/model sections while fitting the
existing app shell patterns.

Add a dashboard:getStats IPC contract and query-service aggregation path that
combines SQLite-backed session metrics with bookmark totals and provider
activity rollups. Wire the request through bootstrap, preload, the shared
bridge, and renderer types so the desktop app can fetch the dashboard through
the existing typed boundary.

Cover the new behavior with query-service, IPC-contract, App-shell, focus
restoration, TopBar, and DashboardView tests, including top-bar navigation and
dashboard refresh/error handling.
Extend the dashboard:getStats response with AI code-writing metrics derived from
explicit tool_edit events. Adds a shared helper that parses stored tool-call
payloads into per-file write summaries, including change type counts, file and
extension rollups, line additions/deletions, and recent write activity.

Expand the dashboard UI with a dedicated AI Code Activity section that surfaces
write KPIs, coverage notes, write velocity, change profile, provider write
throughput, top written files, and top file types while staying within the
existing dashboard card and chart patterns.

Refresh dashboard data whenever the view is reopened instead of loading it only
once per app session. Cover the new behavior with shared helper, query-service,
IPC-contract, dashboard renderer, and App-shell tests, including partial
coverage, empty-state, and dashboard reopen refresh scenarios.
Adjust the rebased AI code activity aggregation to support upstream's move
change type in parsed tool edit payloads. Extend the dashboard IPC contract,
default state, fixtures, and query-service rollups so move operations are
counted explicitly instead of surfacing as invalid change-type totals.

Update the dashboard change profile and focused tests to reflect the wider
write classification model introduced on upstream/main while keeping the
rebased dashboard and AI analytics behavior green.
Introduce OpenCode as a first-class provider across discovery, parsing,
indexing, search, settings, dashboard stats, and history rendering. Add a
SQLite-backed OpenCode adapter that reads session data from ,
normalizes it through the existing provider pipeline, and preserves generic
tool/edit payloads so diff rendering, tool-call indexing, and AI code activity
stats work without provider-specific branches.

Extend materialized-source handling so providers can use stable logical source
keys while still tracking a real backing path for change detection. Add
OpenCode change expansion, changed-db session cleanup, provider metadata/default
roots, and provider-count/search plumbing so OpenCode participates in refresh,
filtering, exports, and aggregate stats alongside the existing providers.

Surface OpenCode in the desktop app through provider styling, settings labels,
dashboard/provider displays, and raw edit rendering. Heal legacy saved indexing
state so older default provider selections automatically enable OpenCode on
startup without overriding intentional custom subsets, and cover the new
behavior with discovery, parser, indexing, app-state, settings, dashboard,
search, and app shell tests.
@biyiklioglu biyiklioglu changed the title [codex] Add OpenCode provider support Add OpenCode provider support Apr 13, 2026
@biyiklioglu biyiklioglu changed the title Add OpenCode provider support Add OpenCode provider support with dashboard Apr 13, 2026
@mdemirhan
Copy link
Copy Markdown
Owner

@copilot resolve the merge conflicts in this pull request

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.

2 participants