Skip to content

[FEATURE]: TUI plugin API: session projection | session list adapters #26077

@juanma91m

Description

@juanma91m

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Summary

I'd like to propose a small extension to the TUI plugin API so plugins can influence:

  1. the projection of the native session view
  2. the projection of the native session switcher/list
    This is not a request to upstream a specific product feature.
    The goal is to expose generic host hooks so advanced plugins can work without requiring local host patches.

Problem

Today, plugins can inject some UI and commands, but they still lack a clean way to control session-aware behavior in the native TUI.
In practice, some advanced addons need to express things like:

  • which session should be considered the active logical session
  • which messages should be visible in the native session view
  • whether the prompt should be visible for a given projected session state
  • how the native session list should resolve the current highlighted session
  • how session selection should map from a logical session to a concrete target session
    Without host hooks for this, the only alternatives are:
  • fragile command shadowing
  • duplicating native views
  • or local host patches

Proposal

Add two optional plugin hooks with full native fallback:

1. Session projection adapter

Conceptually similar to:

  • session.registerAdapter(...)
    This would let a plugin provide a partial projection policy for the native session view.
    Examples of responsibilities:
  • resolve active session id
  • resolve visible messages
  • resolve prompt visibility
  • resolve permission/question routing
  • surface inspection state
    Important:
  • core still renders the native session view
  • plugin only provides policy
  • default behavior stays unchanged when no adapter is registered

2. Session list adapter

Conceptually similar to:

  • session.registerListAdapter(...)
    This would let a plugin provide a partial projection policy for the native session list/switcher.
    Examples of responsibilities:
  • resolve current highlighted session
  • resolve target session before navigation
  • optional pre-navigation cleanup hook
    Important:
  • native session list remains the host UI
  • this avoids fragile command overrides

Why this should live in core

This is not feature-specific logic.
It is host-level TUI extensibility.
These hooks would help any plugin/addon that needs a logical session model on top of the native TUI, while preserving:

  • native rendering
  • native fallback behavior
  • no runtime/server changes

Related issues

I reviewed the related items suggested by the bot, especially around plugin extensibility and TUI hooks.
This proposal is specifically about session-aware projection hooks for:

  • native session
  • native session list/switcher
    It is narrower than a general plugin extensibility umbrella, and more specific than generic UI injection points.

Success criteria

A successful outcome would be:

  • advanced plugins can work against official OpenCode builds
  • native session and session list remain the host UI
  • no default UX regressions
  • no feature-specific logic needs to live in core
  • local host patching becomes unnecessary for this class of addons

Open question

Would maintainers prefer:

  1. discussing this API shape first in an issue, then opening small PRs
  2. or going directly to a focused PR for one adapter at a time?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions