Skip to content

fix(tui): keep prompt mounted during permission and question modals#21262

Open
kevinWangSheng wants to merge 2 commits intoanomalyco:devfrom
kevinWangSheng:fix/tui-prompt-unmount-on-permission
Open

fix(tui): keep prompt mounted during permission and question modals#21262
kevinWangSheng wants to merge 2 commits intoanomalyco:devfrom
kevinWangSheng:fix/tui-prompt-unmount-on-permission

Conversation

@kevinWangSheng
Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #21120

Type of change

  • Bug fix

What does this PR do?

The TUI prompt input loses any text typed while the agent is working as soon as a permission or question modal appears.

The root cause is in tui/routes/session/index.tsx. The visible() memo is:

const visible = createMemo(() => !session()?.parentID && permissions().length === 0 && questions().length === 0)

When a permission fires, visible() becomes false, and the <Show when={visible()}> wrapper unmounts the entire Prompt component. The local state holding the typed text is destroyed. After the modal is dismissed, Prompt remounts from scratch with an empty input.

The fix removes the <Show when={visible()}> wrapper. The Prompt component already handles visible={false} correctly — it blurs the input and hides its <box visible={props.visible !== false}> — so no separate <Show> guard is needed. The visible={visible()} prop is still forwarded to both TuiPluginRuntime.Slot and Prompt, preserving all existing hide/blur behavior while keeping the component tree (and its typed text) alive across modal interactions.

How did you verify your code works?

  • cd packages/opencode && bun run typecheck passes cleanly
  • Traced the flow: permissions().length > 0visible() = false → Prompt's internal createEffect blurs the input and <box visible={false}> hides it, while store.prompt.input remains intact. On dismiss, visible() = true → box shows again, input refocuses with the text still present.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

visible() was gated behind <Show when={visible()}>, so the Prompt component
was unmounted whenever a permission or question request became active.
On dismiss, it remounted fresh, losing any text the user had typed.

The Prompt component already handles visible={false} correctly: it blurs
the input and hides its <box>. Removing the <Show> wrapper lets the Prompt
stay mounted throughout, preserving draft text across modal interactions.

Fixes anomalyco#21120
@kevinWangSheng kevinWangSheng force-pushed the fix/tui-prompt-unmount-on-permission branch from f3d5e76 to 9b36639 Compare April 7, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Input text disappears after permission-modal is shown

1 participant