Skip to content

Add OpenCode provider support#8

Closed
biyiklioglu wants to merge 1 commit into
mdemirhan:mainfrom
biyiklioglu:codex/add-opencode-provider-clean
Closed

Add OpenCode provider support#8
biyiklioglu wants to merge 1 commit into
mdemirhan:mainfrom
biyiklioglu:codex/add-opencode-provider-clean

Conversation

@biyiklioglu
Copy link
Copy Markdown
Contributor

@biyiklioglu biyiklioglu commented Apr 13, 2026

Summary

Adds OpenCode as a provider in Code Trail.

This change brings OpenCode into the same indexing and desktop UX flow as the existing providers, covering discovery, parsing, indexing, search, provider filters, settings, edit rendering, and exports.

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 and 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, 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
  • tool and edit rendering
  • exports

Test Coverage

Test File Coverage
apps/desktop/src/main/appStateStore.test.ts Verifies legacy saved indexing state heals forward to include opencode, while preserving intentional custom provider selections.
apps/desktop/src/main/bootstrap.test.ts Covers bootstrap wiring for OpenCode-aware settings, provider defaults, and provider-driven app initialization.
apps/desktop/src/main/liveSessionStore.test.ts Updates provider-aware live-session fixtures so the expanded provider set remains consistent, without adding OpenCode live watch behavior.
apps/desktop/src/renderer/App.test.tsx Covers app-shell behavior with the expanded provider set and OpenCode-aware state fixtures.
apps/desktop/src/renderer/components/SettingsView.test.tsx Verifies OpenCode appears in Settings, including the provider label and OpenCode data root path.
apps/desktop/src/renderer/components/history/ProjectPane.test.tsx Updates project-pane provider-count coverage so OpenCode is included in provider summaries and badges.
apps/desktop/src/renderer/components/messages/toolParsing.test.ts Verifies OpenCode-native edit payload fields like filePath, content, oldString, and newString normalize into the shared tool/edit parsing flow.
apps/desktop/src/renderer/features/useLiveWatchController.test.ts Keeps live-watch-adjacent provider-count handling aligned with the new full provider set.
apps/desktop/src/renderer/hooks/usePaneStateSync.test.tsx Verifies pane-state sync handles the added opencode provider in provider-based UI preferences.
packages/core/src/discovery/discoverSessionFiles.pythonFixtures.test.ts Updates fixture-backed discovery expectations to include the OpenCode root in resolved config.
packages/core/src/discovery/discoverSessionFiles.test.ts Verifies OpenCode session discovery from opencode.db and changed-path expansion from the database file to logical session sources.
packages/core/src/discovery/discoverSingleFile.test.ts Verifies a synthetic OpenCode source key resolves to the correct discovered session, including logical source identity 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 removed OpenCode sessions during changed-db reindexing.
packages/core/src/parsing/providerParsers.test.ts Verifies OpenCode parsing for user, assistant, thinking, tool_use, tool_edit, and tool_result, including timestamps and tool payload preservation.
packages/core/src/testing/inMemory.test.ts Updates shared in-memory discovery fixtures so OpenCode roots participate in test setup.

Validation

Focused OpenCode coverage passed across discovery, parsing, indexing, search, app state, settings, and app shell, and the desktop build completed successfully.

Screenshots

image

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 marked this pull request as ready for review April 13, 2026 10:15
@mdemirhan
Copy link
Copy Markdown
Owner

@copilot resolve the merge conflicts in this pull request

@biyiklioglu biyiklioglu marked this pull request as draft April 14, 2026 17:27
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