experimental.text.complete hook output not reflected in TUI display #4405

Closed
opened 2026-02-16 17:43:41 -05:00 by yindo · 1 comment
Owner

Originally created by @sungchul2 on GitHub (Jan 7, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

The experimental.text.complete hook is being triggered correctly and modifying text, but the modified text is not reflected in the TUI display.

Environment

Steps to Reproduce

  1. Create a plugin with experimental.text.complete hook that modifies text
  2. Generate LLM response containing markdown tables
  3. Hook runs and modifies text (confirmed by logs)
  4. TUI displays original unmodified text

Evidence

Plugin logs show the hook IS being called and IS modifying text:

[table-formatter] Formatted table {"tableCount":1,"beforeLength":1625,"afterLength":1828}
[table-formatter] Formatted table {"tableCount":1,"beforeLength":780,"afterLength":775}

Expected Behavior

TUI should display the text modified by experimental.text.complete hook.

Actual Behavior

TUI displays the original streamed text, not the hook-modified text.

Analysis

Looking at packages/opencode/src/session/processor.ts:

case "text-end":
  if (currentText) {
    currentText.text = currentText.text.trimEnd()
    const textOutput = await Plugin.trigger(
      "experimental.text.complete",
      {...},
      { text: currentText.text },
    )
    currentText.text = textOutput.text  // ✅ Result assigned
    await Session.updatePart(currentText)  // ✅ Saved
  }

The hook result is saved to the session, but the TUI may be:

  1. Caching the streamed text-delta updates
  2. Not re-rendering when the final text is saved after hook completion

Possible Root Cause

During streaming, text-delta events update the TUI in real-time. When text-end triggers the hook and saves the modified text, the TUI might not refresh to show the updated content.

Originally created by @sungchul2 on GitHub (Jan 7, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description The `experimental.text.complete` hook is being triggered correctly and modifying text, but the modified text is not reflected in the TUI display. ### Environment - OpenCode version: 1.1.6 - Plugin: oh-my-opencode (table-formatter hook https://github.com/code-yeongyu/oh-my-opencode/pull/576) - OS: macOS ### Steps to Reproduce 1. Create a plugin with `experimental.text.complete` hook that modifies text 2. Generate LLM response containing markdown tables 3. Hook runs and modifies text (confirmed by logs) 4. TUI displays original unmodified text ### Evidence Plugin logs show the hook IS being called and IS modifying text: ``` [table-formatter] Formatted table {"tableCount":1,"beforeLength":1625,"afterLength":1828} [table-formatter] Formatted table {"tableCount":1,"beforeLength":780,"afterLength":775} ``` ### Expected Behavior TUI should display the text modified by `experimental.text.complete` hook. ### Actual Behavior TUI displays the original streamed text, not the hook-modified text. ### Analysis Looking at `packages/opencode/src/session/processor.ts`: ```typescript case "text-end": if (currentText) { currentText.text = currentText.text.trimEnd() const textOutput = await Plugin.trigger( "experimental.text.complete", {...}, { text: currentText.text }, ) currentText.text = textOutput.text // ✅ Result assigned await Session.updatePart(currentText) // ✅ Saved } ``` The hook result is saved to the session, but the TUI may be: 1. Caching the streamed `text-delta` updates 2. Not re-rendering when the final text is saved after hook completion ### Possible Root Cause During streaming, `text-delta` events update the TUI in real-time. When `text-end` triggers the hook and saves the modified text, the TUI might not refresh to show the updated content.
yindo added the opentui label 2026-02-16 17:43:41 -05:00
yindo closed this issue 2026-02-16 17:43:41 -05:00
Author
Owner

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

I've searched through existing issues and did not find any clear duplicates of this issue. The problem appears to be specific to the experimental.text.complete hook not reflecting modifications in the TUI display despite the changes being saved to the session.

This is a distinct issue, though #196 is tangentially related in that it also deals with streamed message display behavior in the TUI.

@github-actions[bot] commented on GitHub (Jan 7, 2026): I've searched through existing issues and did not find any clear duplicates of this issue. The problem appears to be specific to the `experimental.text.complete` hook not reflecting modifications in the TUI display despite the changes being saved to the session. This is a distinct issue, though #196 is tangentially related in that it also deals with streamed message display behavior in the TUI.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4405