Feature Request: Plugin hook for filtering session list in /sessions dialog #6893

Open
opened 2026-02-16 18:05:31 -05:00 by yindo · 1 comment
Owner

Originally created by @codelipenghui on GitHub (Jan 20, 2026).

Originally assigned to: @thdxr on GitHub.

Design: Session Filtering Hook for Plugin Integration

Goal

Allow plugins to control which sessions appear in the /sessions dialog by returning a filtered list of session IDs.

API Surface

New Plugin Hook

  • session.list.filter(input, output)
    • Input: { projectID, directory, sessionID? }
    • Output: { sessionIDs? }
    • Behavior: If sessionIDs is provided, the UI should only display those sessions. If not provided, the UI shows all sessions.

New Server Endpoint

  • GET /session/filter?sessionID=...
    • Invokes the hook and returns { sessionIDs? }
    • Tied to current Instance.project.id and Instance.directory

Data Flow

  1. /sessions dialog opens in TUI.
  2. TUI requests /session/filter using the SDK internal client (so it runs through Server.App().fetch).
  3. Server triggers session.list.filter hook.
  4. Plugin returns sessionIDs to display.
  5. TUI filters the session list to those IDs.

TUI Behavior

  • If hook returns sessionIDs, filter the list with a set lookup.
  • If hook returns nothing, show all sessions (current behavior).

Backward Compatibility

  • If no plugin implements the hook, session list remains unchanged.
  • No behavior change for existing sessions or storage formats.

Files Touched (opencode)

  • packages/plugin/src/index.ts — hook type definition
  • packages/opencode/src/server/routes/session.ts — filter endpoint
  • packages/opencode/src/cli/cmd/tui/component/dialog-session-list.tsx — request + UI filtering
Originally created by @codelipenghui on GitHub (Jan 20, 2026). Originally assigned to: @thdxr on GitHub. ## Design: Session Filtering Hook for Plugin Integration ### Goal Allow plugins to control which sessions appear in the `/sessions` dialog by returning a filtered list of session IDs. ### API Surface **New Plugin Hook** - `session.list.filter(input, output)` - **Input**: `{ projectID, directory, sessionID? }` - **Output**: `{ sessionIDs? }` - Behavior: If `sessionIDs` is provided, the UI should only display those sessions. If not provided, the UI shows all sessions. **New Server Endpoint** - `GET /session/filter?sessionID=...` - Invokes the hook and returns `{ sessionIDs? }` - Tied to current `Instance.project.id` and `Instance.directory` ### Data Flow 1. `/sessions` dialog opens in TUI. 2. TUI requests `/session/filter` using the SDK internal client (so it runs through `Server.App().fetch`). 3. Server triggers `session.list.filter` hook. 4. Plugin returns `sessionIDs` to display. 5. TUI filters the session list to those IDs. ### TUI Behavior - If hook returns `sessionIDs`, filter the list with a set lookup. - If hook returns nothing, show all sessions (current behavior). ### Backward Compatibility - If no plugin implements the hook, session list remains unchanged. - No behavior change for existing sessions or storage formats. ### Files Touched (opencode) - `packages/plugin/src/index.ts` — hook type definition - `packages/opencode/src/server/routes/session.ts` — filter endpoint - `packages/opencode/src/cli/cmd/tui/component/dialog-session-list.tsx` — request + UI filtering
Author
Owner

@github-actions[bot] commented on GitHub (Jan 20, 2026):

Thanks for this detailed feature request! I've searched through existing issues and found several related session management discussions, but this appears to be the first request specifically for a plugin hook to filter/customize the session list.

While I found related issues around session management and organization (like #8541 for directory navigation in sessions, #6461 for session origin tracking, and #9526 for session switching), none of them propose the plugin hook mechanism you're suggesting here.

Your proposal for a session.list.filter hook is a good design that maintains composability across multiple plugins. The use cases you outlined—workspace-based filtering, tag/label filtering, time-based views, and multi-project views—are all compelling scenarios that would benefit from this extensibility.

This seems like a solid foundation for plugin-driven session management!

@github-actions[bot] commented on GitHub (Jan 20, 2026): Thanks for this detailed feature request! I've searched through existing issues and found several related session management discussions, but this appears to be the first request specifically for a **plugin hook to filter/customize the session list**. While I found related issues around session management and organization (like #8541 for directory navigation in sessions, #6461 for session origin tracking, and #9526 for session switching), none of them propose the plugin hook mechanism you're suggesting here. Your proposal for a `session.list.filter` hook is a good design that maintains composability across multiple plugins. The use cases you outlined—workspace-based filtering, tag/label filtering, time-based views, and multi-project views—are all compelling scenarios that would benefit from this extensibility. This seems like a solid foundation for plugin-driven session management!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6893