Skip to content

[FEATURE]: TUI extensibility: host hooks needed for plugin-only advanced addons #26043

@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 set of generic TUI host extension points that would allow advanced addons to work against official OpenCode builds without requiring a local host patch.
This is not a request to merge a specific product feature.
The goal is to upstream a few host-level hooks so plugins can:

  • intercept prompt submission
  • react to exact multi-step keybindings
  • render notices in the native session view
  • project a logical session/transcript policy over the native session route
  • influence how the native session switcher resolves the current/target session
    The default UX should remain unchanged when no plugin uses these hooks.

Why this matters

Today, some advanced TUI features are only feasible by shipping:

  • a plugin
  • plus a local patch over the host/core
    That is workable for experimentation, but not ideal for:
  • official releases
  • binary installs
  • upgrades
  • long-term maintenance
  • independently distributed addons
    A small set of generic host hooks would let these addons work as real plugins instead of local patches.

Non-goals

This proposal is not asking to upstream:

  • a specific background-tasks feature
  • any plugin-specific KV shape
  • any runtime/server behavior
  • any hardcoded feature logic in core
    The intention is to keep core generic and let plugins own feature-specific policy.

Proposed host hooks

1. Exact multi-stroke keybinding sequences

Examples:

  • ctrl+b ctrl+b
  • ctrl+f ctrl+f
    This is broadly useful beyond any single addon.

2. Prompt submit interception

A host hook that allows a plugin to intercept or override prompt submission while preserving native prompt rendering.
Conceptual need:

  • native prompt remains the host UI
  • plugin can decide how the submission is routed
    This capability exists in local experimentation and seems broadly reusable.

3. Session notice slot

A generic insertion point inside the native session view for banners/notices/hints.
Examples of generic uses:

  • inspection notices
  • mode banners
  • contextual session hints
    This avoids hardcoding feature-specific copy into core.

4. Session projection adapter

A plugin hook to provide a partial projection policy for the native session view, with native fallback when no adapter is registered.
Conceptual 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 remains unchanged

5. Session list adapter

A plugin hook to provide a partial projection policy for the native session switcher/list.
Conceptual responsibilities:

  • resolve current highlighted session
  • resolve navigation target before switching
  • optional pre-navigation cleanup hook
    Important:
  • this avoids fragile command shadowing
  • native session list remains the host UI

6. Busy-input policy hook

There is also a need to let plugins express that a session may be technically busy while the prompt should still remain logically usable.
A simple boolean works, but this may deserve a more generic shape than allowSubmitWhenBusy.
Open question:

  • keep a boolean?
  • or expose a more general input/busy strategy?

Design principles

Any accepted API should be:

  • generic
  • optional
  • sync
  • deterministic
  • side-effect free in the projection layer
  • safe when unused
  • fallback-compatible with native behavior
    Also:
  • no runtime/server changes
  • no default UX regressions
  • no feature-specific logic in core

Suggested rollout order

I would recommend evaluating these in small chunks instead of a single large change:

  1. multi-stroke keybinding sequences
  2. prompt submit interception
  3. session notice slot
  4. busy-input policy hook
  5. session projection adapter
  6. session list adapter
    This keeps each change easier to review independently.

Why not just override whole views in plugins?

Because replacing the entire native session route or duplicating native UI components tends to create:

  • drift
  • duplicated rendering logic
  • fragile maintenance
  • weaker UX consistency
    The proposal here is intentionally narrower:
  • native views stay native
  • plugins only inject policy and small UI fragments

Practical motivation

There is already a real addon experiment that has validated this architecture:

  • plugin-owned feature logic
  • host patch only for missing extension points
  • no runtime/server changes
  • native session UX preserved
    That experiment strongly suggests the remaining blocker is host hook availability, not feature design.

Success criteria

A successful outcome would be:

  • advanced plugins can work against official OpenCode builds
  • no local host patch needed for supported versions
  • native TUI behavior remains unchanged for users who don't use these plugins
  • core becomes more extensible without becoming feature-specific

Open question for maintainers

Would you prefer discussing these as:

  1. one RFC issue first and then small PRs, or
  2. direct small PRs starting from the least controversial hooks (keybind sequences / prompt interception / session notice)?

Metadata

Metadata

Assignees

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