Skip to content

Add OpenCode provider support#9

Merged
mdemirhan merged 6 commits into
mdemirhan:mainfrom
biyiklioglu:codex/add-opencode-provider-minimal
Apr 16, 2026
Merged

Add OpenCode provider support#9
mdemirhan merged 6 commits into
mdemirhan:mainfrom
biyiklioglu:codex/add-opencode-provider-minimal

Conversation

@biyiklioglu
Copy link
Copy Markdown
Contributor

@biyiklioglu biyiklioglu commented Apr 14, 2026

Summary

Add OpenCode as a new provider in Code Trail with support for discovery, parsing,
indexing, search, settings, and history rendering.

What Changed

  • added opencode to the provider contracts and metadata
  • added default OpenCode discovery roots and settings support
  • added SQLite-backed OpenCode session discovery from opencode.db
  • added an OpenCode adapter that loads session, message, and part data into the existing provider pipeline
  • added OpenCode parsing for user, assistant, thinking, tool use, tool edit, and tool result messages
  • extended materialized-source handling so database-backed providers can expose stable logical session sources with a real backing file for change detection
  • added changed-path expansion for OpenCode database updates
  • added generic tool-edit extraction so OpenCode write/edit events participate in existing diff and history rendering
  • added the minimal app-state migration needed so older saved default provider selections heal forward to include OpenCode
  • surfaced OpenCode in Settings and provider-aware UI paths

Why

OpenCode session history lives in a SQLite database rather than transcript files, so it needs provider-specific discovery and loading while still fitting the existing indexing and renderer flow. This change keeps the integration narrowly scoped and avoids unrelated refactors.

Validation

  • ELECTRON_RUN_AS_NODE=1 ./apps/desktop/node_modules/.bin/electron ./node_modules/vitest/vitest.mjs run 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 apps/desktop/src/main/appStateStore.test.ts apps/desktop/src/renderer/components/messages/toolParsing.test.ts apps/desktop/src/renderer/components/SettingsView.test.tsx
  • bun run desktop:build

Test Coverage

Test File Coverage
apps/desktop/src/main/appStateStore.test.ts Verifies legacy saved provider selections heal forward to include opencode, while preserving intentional custom subsets.
apps/desktop/src/renderer/components/SettingsView.test.tsx Verifies OpenCode appears in Settings, including the OpenCode data root path.
apps/desktop/src/renderer/components/messages/toolParsing.test.ts Verifies OpenCode-native edit fields like filePath, content, oldString, and newString normalize into the shared tool parsing flow.
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 session source resolves to the correct discovered session, including logical source identity and backing DB path.
packages/core/src/indexing/indexSessions.integration.test.ts Covers end-to-end indexing for OpenCode sessions, including tool calls, edit file extraction, and changed-db cleanup behavior.
packages/core/src/parsing/providerParsers.test.ts Verifies OpenCode parsing for user, assistant, thinking, tool use, tool edit, and tool result messages, including timestamps and tool payload preservation.

Screenshots

image

Introduce OpenCode as a first-class provider across discovery, parsing,
indexing, search, settings, and history rendering. Add a SQLite-backed
OpenCode adapter that reads session data from �[1m�[22m, exposes stable
logical session sources, and normalizes tool and edit payloads through the
existing provider pipeline.

Keep the change set focused by extending the shared materialized-source flow
only where needed for database-backed sessions. Add changed-path expansion,
generic tool-edit extraction for OpenCode writes, default discovery roots, and
the small UI and app-state updates required to surface OpenCode in settings and
provider-driven state.

Cover the new provider with focused discovery, parser, indexing, tool-parsing,
settings, and app-state tests, including a migration that heals older default
saved provider selections so OpenCode appears for existing installs without
overriding intentional custom subsets.
Fold the OpenCode follow-up fixes into a single commit by tightening renderer shortcut handling, platform-boundary compatibility, provider-aware test fixtures, and type-safe test data updates required by the expanded provider set.

Stabilize the App pagination shortcut coverage by making the Cmd+Left/Right test use an explicit multi-page history fixture and wait for the pager to become navigable before asserting the shortcut transition. Keep the OpenCode provider branch green across lint, platform-boundary checks, typecheck, test, and coverage verification.
@biyiklioglu biyiklioglu force-pushed the codex/add-opencode-provider-minimal branch from 506d19b to d9f0ffd Compare April 15, 2026 06:16
@biyiklioglu biyiklioglu changed the title [codex] Add OpenCode provider support Add OpenCode provider support Apr 15, 2026
@mdemirhan mdemirhan marked this pull request as ready for review April 16, 2026 07:15
@mdemirhan mdemirhan merged commit 177142e into mdemirhan:main Apr 16, 2026
0 of 3 checks passed
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