Skip to content

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

@sungchul2

Description

@sungchul2

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.

Metadata

Metadata

Assignees

Labels

opentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions