Skip to content

Add opencode extension - #27515

Closed
mormubis wants to merge 11 commits into
raycast:mainfrom
mormubis:ext/opencode
Closed

mormubis wants to merge 11 commits into
raycast:mainfrom
mormubis:ext/opencode

Conversation

@mormubis

@mormubis mormubis commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

I use OpenCode across multiple projects daily and end up with hundreds of sessions. Finding a past conversation or switching to the right session means digging through terminal tabs or remembering which project it was in. I wanted something faster — a way to jump to any session from anywhere without leaving what I'm doing.

Raycast extension for managing OpenCode projects and sessions. OpenCode is an open source AI coding agent for the terminal.

Commands:

  • Search Projects — browse all OpenCode projects with session counts, drill into sessions grouped by working directory
  • Search Sessions — find conversations by title or message content using multi-word scored search

Features:

  • Detects which sessions are actively running or open in a terminal (Active/Open badges)
  • Focuses the existing iTerm2 tab when resuming a session that's already open
  • Supports iTerm2 and Terminal.app via preferences
  • Shows helpful error when OpenCode is not installed

How it works:
Uses the OpenCode SDK to start a lightweight server for API access (projects, todos, messages). Falls back to SQLite for cross-project session listing and content search. Session liveness is detected by scanning running processes and checking recent database activity.

Checklist

- fix: store compliance — subtitles, terminal preference, install check, title, README
- fix: address all code review findings — injection fixes, dead code removal, perf improvements
- docs: replace screenshots with mock data versions
- docs: add third screenshot
- docs: add README and CHANGELOG for store submission
- fix: default search mode to content
- feat: multi-word scored search — exact phrase, individual words, title + content
- feat: combine title + content search like recover-opencode-conversation skill
- fix: pass SQL via stdin to avoid shell escaping issues in content search
- chore: use OpenCode brand icon (512x512)
- fix: reveal hotkey window after selecting tab
- fix: select tab at window level with select tab N for proper focus
- fix: use iTerm2 app name and tab index iteration for focus
- fix: focus iTerm tab by matching TTY from process list
- feat: focus existing iTerm tab when session is already open
- feat: add folder dropdown filter for project sessions
- fix: use subtitle for folder name so fuzzy filtering works
- feat: add folder name as keyword for filtering project sessions by directory
- fix: use dedicated project sessions query instead of global limit
- feat: group project sessions by directory basename
- fix: exclude sub-agent sessions (parent_id IS NOT NULL) from all queries
- feat: replace Open/Idle tags with Active/Open liveness detection via DB
- fix: add Open/status tags to project sessions view
- fix: guard openIds type before calling includes
- fix: use array instead of Set for open session IDs (serialization)
- feat: show Open badge on sessions currently running in a terminal
- fix: disable client-side filtering in content search mode
- feat: add content search mode to Search Sessions — searches message text as fallback
- fix: make View Sessions the default action on projects
- fix: use SQLite for cross-project session counts and listing
- fix: use random port to avoid conflicts with existing servers
- fix: ensure PATH includes homebrew for Raycast environment
- fix: use createOpencode() instead of server discovery — solves auth issue
- fix: lint — add description, remove unused var, format with prettier
- feat: add hooks, Search Projects command, Search Sessions command with activity view
- feat: add core modules — SDK, server discovery, client pool, iTerm2 integration
- chore: initial raycast extension scaffold
@raycastbot raycastbot added new extension Label for PRs with new extensions platform: macOS labels Apr 29, 2026
@raycastbot

Copy link
Copy Markdown
Collaborator

Congratulations on your new Raycast extension! 🚀

We're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 10-15 business days.

Once the PR is approved and merged, the extension will be available on our Store.

@mormubis
mormubis marked this pull request as ready for review April 29, 2026 11:04
@greptile-apps

greptile-apps Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a new Raycast extension for managing OpenCode projects and sessions. It exposes three commands (Search Projects, Search Sessions, New Session), reads data from the OpenCode SQLite database via @raycast/utils executeSQL/useSQL, and opens/focuses terminal tabs across iTerm2, Terminal.app, Warp, Ghostty, and Kitty using AppleScript.

  • Search Projects drills into per-project sessions grouped by working directory; Search Sessions combines a recent-sessions list with multi-word scored SQLite search against titles and message content.
  • A singleton OpenCode SDK client is started lazily (with correct retry-on-failure logic) to serve the session activity detail view (todos and recent messages).
  • Terminal integration uses a shellQuote + esc layering to safely embed paths inside AppleScript string literals.

Confidence Score: 5/5

The extension is safe to merge; all findings are non-blocking quality suggestions.

The core data paths (SQLite queries, terminal launching, SDK client lifecycle) are correct and well-structured. The two flagged issues — unhandled hook errors producing a misleading empty state, and basename-only directory grouping — are UX polish items that do not affect correctness or data integrity.

extensions/opencode/src/search-sessions.tsx and extensions/opencode/src/search-projects.tsx could benefit from surfacing hook errors and using full directory paths as grouping keys.

Important Files Changed

Filename Overview
extensions/opencode/src/lib/clients.ts Manages the singleton OpenCode SDK client; correctly resets initializing on rejection so transient failures allow a retry.
extensions/opencode/src/lib/db.ts SQLite access via executeSQL; uses typed row objects, proper ''-escaping for user-supplied LIKE terms, and in-memory caching for liveness data.
extensions/opencode/src/lib/hooks.ts Wraps all data fetches in useCachedPromise/useSQL; hook errors are exposed via the error property but not consumed at call sites.
extensions/opencode/src/lib/terminal.ts Multi-terminal support via AppleScript/execSync; uses shellQuote + esc layering for directory paths in AppleScript string literals; getPreferenceValues<Preferences>() correctly uses the auto-generated type.
extensions/opencode/src/search-sessions.tsx Main session search view; formatTime correctly uses the normalised ts value; hook errors are not surfaced, so DB/permission failures display a misleading empty state.
extensions/opencode/src/search-projects.tsx Project and session browsing view; groupByDirectory uses basename-only keys which can merge sessions from different paths that share the same final component.
extensions/opencode/src/new-session.ts Simple no-view command that opens a new OpenCode session in the given (or home) directory; straightforward and correct.
extensions/opencode/package.json Well-formed Raycast manifest with $schema, correct platforms, appropriate categories, and all three dependencies actually used in source.
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
extensions/opencode/src/search-sessions.tsx:1120-1123
**Unhandled hook errors produce a misleading empty state**

`useAllSessions`, `useContentSearch`, and `useOpenSessions` all expose an `error` property that is never destructured. When `executeSQL` throws — e.g., the database doesn't exist yet because OpenCode has never been run, or Full Disk Access is denied — `data` stays `[]` and the component renders the "No Sessions Found / Start OpenCode in a terminal" message, which misdirects the user. Destructure `error` from each hook and surface it (e.g., via `showToast` or a dedicated empty view description) so users know why they're seeing no results.

### Issue 2 of 2
extensions/opencode/src/search-projects.tsx:818-831
**Basename-only grouping key can merge unrelated sessions**

`groupByDirectory` uses `dirBasename(s.directory)` — just the final path component — as both the Map key and the section title. Two sessions whose `directory` ends in the same component (e.g., `/workspace/frontend/components` and `/workspace/backend/components`) will be collapsed into a single "components" section under the same project. The Dropdown filter would also map both to the same value, making one unfilterable. Using the full `s.directory` as the Map key while still displaying only the basename in section titles would avoid this.

Reviews (11): Last reviewed commit: "Update opencode extension" | Re-trigger Greptile

Comment thread extensions/opencode/src/lib/terminal.ts Resolved
Comment thread extensions/opencode/src/lib/db.ts Resolved
Comment thread extensions/opencode/src/lib/terminal.ts Resolved
mormubis added 2 commits May 6, 2026 23:32
- feat: rename Open in Terminal to New Session (cmd+n) in project list
- feat: add New Session action to project sessions view (cmd+n)
- fix: escape shellQuote in AppleScript strings, make getOpenSessions async
- docs: improve command descriptions for store listing
- docs: update README and CHANGELOG with new session, terminal support
@0xdhrv 0xdhrv self-assigned this May 20, 2026

@0xdhrv 0xdhrv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution 

We already have an extension in the Store that deals with this. Could we consider enhancing the existing extension below instead of creating another one?

If there are unique features or workflows you’re aiming to add, we’d love to hear them and see if they can be integrated into this to avoid duplication and improve discoverability.

This would help avoid duplication and keep related functionality consolidated in one place.
As mentioned in our extension guidelines here

@0xdhrv
0xdhrv marked this pull request as draft May 20, 2026 17:31
@mormubis

Copy link
Copy Markdown
Contributor Author

I checked the existing extension before submitting. They solve different problems @0xdhrv.

opencode-sessions is a session browser/inspector — view transcripts, see stats (cost, tokens, model), copy things, delete sessions. Mine is a session launcher — find sessions fast across projects, detect what's running, and jump into them in your terminal.

opencode (this PR) opencode-sessions (existing)
Data source OpenCode SDK server + SQLite fallback SQLite only
Session search Multi-word scored search over title + message content Raycast built-in filtering (title only)
Project browsing Dedicated command, grouped by working directory Dropdown filter
Session liveness Detects Active/Open via process scanning No
Resume session Opens terminal directly, focuses existing tab Copy command to clipboard
Terminal support iTerm2, Terminal.app, Warp, Ghostty, Kitty N/A
Transcript viewer No Yes, with markdown rendering
Session stats No Cost, tokens, model, files changed
AI summary No Yes
Delete sessions No Yes

The features are complementary. I'm open to contributing to the existing extension if that's the preferred path, but the scope and intent are pretty different. What do you think?

@mormubis
mormubis requested a review from 0xdhrv May 20, 2026 21:53
@mormubis
mormubis marked this pull request as ready for review May 22, 2026 08:18
@0xdhrv
0xdhrv marked this pull request as draft May 25, 2026 09:55
@0xdhrv

0xdhrv commented May 25, 2026

Copy link
Copy Markdown
Member

I checked the existing extension before submitting. They solve different problems @0xdhrv.

opencode-sessions is a session browser/inspector — view transcripts, see stats (cost, tokens, model), copy things, delete sessions. Mine is a session launcher — find sessions fast across projects, detect what's running, and jump into them in your terminal.

opencode (this PR) opencode-sessions (existing)
Data source OpenCode SDK server + SQLite fallback SQLite only
Session search Multi-word scored search over title + message content Raycast built-in filtering (title only)
Project browsing Dedicated command, grouped by working directory Dropdown filter
Session liveness Detects Active/Open via process scanning No
Resume session Opens terminal directly, focuses existing tab Copy command to clipboard
Terminal support iTerm2, Terminal.app, Warp, Ghostty, Kitty N/A
Transcript viewer No Yes, with markdown rendering
Session stats No Cost, tokens, model, files changed
AI summary No Yes
Delete sessions No Yes
The features are complementary. I'm open to contributing to the existing extension if that's the preferred path, but the scope and intent are pretty different. What do you think?

Thanks for the clarification; I agree the implementations and feature sets differ, and I can see the additional work around terminal integration, liveness detection, and project navigation here.

That said, I still think this falls into the same core extension domain as opencode-sessions: helping users discover, manage, and resume OpenCode sessions. The workflows are adjacent enough that, from a Store perspective, this feels more like an evolution/expansion of the existing extension rather than a separate category of tool.

The Extensions Guidelines generally push us toward consolidating related functionality where possible, even when the implementations or UX approaches differ substantially. The concern is less “do these have identical features?” and more “would users reasonably expect these capabilities to live in one extension?”.

In this case, I think the answer is probably yes:

  • both extensions operate on the same underlying OpenCode session data
  • both center around session discovery and interaction
  • the differences are mostly in how users interact with sessions afterward (inspect vs resume/manage)

Features like:

  • terminal launching
  • active-session detection
  • improved search/navigation
  • project grouping

all feel like capabilities that could strengthen the existing extension rather than justify a parallel one in the Store.

I understand that integrating this into the current extension may require significant restructuring or coordination with the maintainer, but that’s generally the direction we prefer when the primary problem space overlaps this closely.

I’d recommend reaching out to opencode-sessions’ maintainer to explore collaboration and whether these workflows can be merged into the existing extension instead of introducing a second OpenCode session manager.

@mormubis mormubis closed this May 25, 2026
@mormubis
mormubis deleted the ext/opencode branch May 25, 2026 13:27
@mormubis mormubis mentioned this pull request May 26, 2026
5 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new extension Label for PRs with new extensions platform: macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants