Add TUI display-only chat text transform hook (string→string) #8374

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

Originally created by @AnganSamadder on GitHub (Feb 2, 2026).

Originally assigned to: @thdxr on GitHub.

Problem

The TUI chat markdown output can sometimes be difficult to read depending on the content (e.g., long tables, deeply nested lists, or excessive whitespace). Currently, there is no mechanism for plugins to intercept and transform this text specifically for display purposes without affecting persistence or the Web UI.

Proposal

Add a new stable plugin hook (e.g., chat.display.transform) with a string -> string signature. This hook will allow plugins to perform display-only transformations on chat text before it is rendered in the TUI.

Scope & Constraints

  • TUI only: Initial implementation targets the TUI TextPart component.
  • Display-only: Transformations are transient and not persisted to the session history.
  • String -> String: Simple synchronous transformation.
  • No Web UI / File Viewer changes: This hook specifically targets chat message rendering.

Timing Modes

To balance performance and UX, the hook should support three timing modes (configurable via opencode.json with CLI overrides):

  1. final: Apply only once the message is complete.
  2. throttle: Apply on streaming updates but throttled (default 100ms).
  3. chunk: Apply on every streaming update (raw).

Safety & Reliability

  • Sync-only: Prevents async plugins from blocking the render loop.
  • Error Fallback: If a plugin throws or returns a non-string, the system logs the error and falls back to the original (or last successful) text, continuing the chain.
  • Deterministic Ordering: Hooks run in the sequence plugins are defined in the config.

Acceptance Criteria

  • New hook type added to plugin definitions.
  • TUI rendering wired at the TextPart chokepoint.
  • Configuration keys and CLI flags added for mode and throttle control.
  • Unit tests for multi-plugin ordering and error fallback.
Originally created by @AnganSamadder on GitHub (Feb 2, 2026). Originally assigned to: @thdxr on GitHub. ### Problem The TUI chat markdown output can sometimes be difficult to read depending on the content (e.g., long tables, deeply nested lists, or excessive whitespace). Currently, there is no mechanism for plugins to intercept and transform this text specifically for display purposes without affecting persistence or the Web UI. ### Proposal Add a new stable plugin hook (e.g., `chat.display.transform`) with a `string -> string` signature. This hook will allow plugins to perform display-only transformations on chat text before it is rendered in the TUI. ### Scope & Constraints - **TUI only**: Initial implementation targets the TUI `TextPart` component. - **Display-only**: Transformations are transient and not persisted to the session history. - **String -> String**: Simple synchronous transformation. - **No Web UI / File Viewer changes**: This hook specifically targets chat message rendering. ### Timing Modes To balance performance and UX, the hook should support three timing modes (configurable via `opencode.json` with CLI overrides): 1. `final`: Apply only once the message is complete. 2. `throttle`: Apply on streaming updates but throttled (default 100ms). 3. `chunk`: Apply on every streaming update (raw). ### Safety & Reliability - **Sync-only**: Prevents async plugins from blocking the render loop. - **Error Fallback**: If a plugin throws or returns a non-string, the system logs the error and falls back to the original (or last successful) text, continuing the chain. - **Deterministic Ordering**: Hooks run in the sequence plugins are defined in the config. ### Acceptance Criteria - [ ] New hook type added to plugin definitions. - [ ] TUI rendering wired at the `TextPart` chokepoint. - [ ] Configuration keys and CLI flags added for mode and throttle control. - [ ] Unit tests for multi-plugin ordering and error fallback.
yindo added the opentui label 2026-02-16 18:09:48 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 2, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #10868: [FEATURE]: Implement more hooks for plugin: API Extensions for Storage, Schema, TUI, and Command Registration - includes TUI rendering hook proposal which overlaps with display-only transformations
  • #7671: Markdown table formatting - related TUI rendering issue for markdown tables
  • #11048: Markdown being stripped - related TUI markdown rendering issue
  • #6142: Feature: Add sessionID to experimental.chat.system.transform hook - enhances existing transform hook infrastructure

Feel free to ignore if none of these address your specific case or if you're proposing something distinct from TUI rendering customization.

@github-actions[bot] commented on GitHub (Feb 2, 2026): This issue might be a duplicate of existing issues. Please check: - #10868: [FEATURE]: Implement more hooks for plugin: API Extensions for Storage, Schema, TUI, and Command Registration - includes TUI rendering hook proposal which overlaps with display-only transformations - #7671: Markdown table formatting - related TUI rendering issue for markdown tables - #11048: Markdown being stripped - related TUI markdown rendering issue - #6142: Feature: Add sessionID to experimental.chat.system.transform hook - enhances existing transform hook infrastructure Feel free to ignore if none of these address your specific case or if you're proposing something distinct from TUI rendering customization.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8374