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
- Create a plugin with
experimental.text.complete hook that modifies text
- Generate LLM response containing markdown tables
- Hook runs and modifies text (confirmed by logs)
- 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:
- Caching the streamed
text-delta updates
- 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.
Description
The
experimental.text.completehook is being triggered correctly and modifying text, but the modified text is not reflected in the TUI display.Environment
Steps to Reproduce
experimental.text.completehook that modifies textEvidence
Plugin logs show the hook IS being called and IS modifying text:
Expected Behavior
TUI should display the text modified by
experimental.text.completehook.Actual Behavior
TUI displays the original streamed text, not the hook-modified text.
Analysis
Looking at
packages/opencode/src/session/processor.ts:The hook result is saved to the session, but the TUI may be:
text-deltaupdatesPossible Root Cause
During streaming,
text-deltaevents update the TUI in real-time. Whentext-endtriggers the hook and saves the modified text, the TUI might not refresh to show the updated content.