Skip to content

Studio Code: don't wipe in-progress typing on turn boundaries#3352

Merged
youknowriad merged 1 commit into
trunkfrom
claude/kind-bell-f0946f
May 6, 2026
Merged

Studio Code: don't wipe in-progress typing on turn boundaries#3352
youknowriad merged 1 commit into
trunkfrom
claude/kind-bell-f0946f

Conversation

@youknowriad
Copy link
Copy Markdown
Contributor

Related issues

  • Related to: in-session bug report — while Studio Code's agent is running, text the user is typing into the prompt sometimes disappears (most often right when the agent finishes a turn).

How AI was used in this PR

Investigated the AiChatUI lifecycle, identified the two editor.setText('') calls that fire across turn boundaries, and removed them after confirming pi-tui already clears the editor on submit.

Proposed Changes

  • Remove this.editor.setText('') from AiChatUI.waitForInput() and AiChatUI.beginAgentTurn() in apps/cli/ai/ui.ts.

The TUI editor stays focused while the agent runs, so users can keep typing during a turn. pi-tui's Editor.submitValue() already clears the editor synchronously when the user presses Enter, so the additional setText('') calls only ever fire on text the user typed during the async gap around turn start/end:

  • waitForInput — runs after the agent returns control. If you typed (without pressing Enter) while the turn was finishing, those characters get wiped here. This is the case the bug report described.
  • beginAgentTurn — runs after several awaits in runAgentTurn (provider/env setup). Anything typed in that gap also gets wiped.

In both cases the editor is already empty in the normal flow (because submitValue cleared it), so removing these calls is a no-op except in the race window where the user's input was being lost.

Testing Instructions

  1. npm run cli:build && node apps/cli/dist/cli/main.mjs — start Studio Code.
  2. Send any prompt that triggers a multi-step agent turn.
  3. While the agent is running, start typing into the prompt (without pressing Enter).
  4. Wait for the turn to complete.
  5. Before this PR: the typed text disappears the moment the turn ends. After this PR: the text stays in the editor, ready to submit.
  6. Sanity-check that the normal submit-and-clear flow still works (press Enter on a prompt → editor clears as expected).

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors? (Pre-existing typecheck errors on trunk are unrelated.)

🤖 Generated with Claude Code

The TUI editor stays focused while the agent runs, so users can keep
typing during a turn. pi-tui already clears the editor synchronously
when the user presses Enter, so the additional `setText('')` calls in
`waitForInput` and `beginAgentTurn` only ever fire on text the user
typed during the async gap around turn start/end — wiping it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@wpmobilebot
Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing f39b1f2 vs trunk

app-size

Metric trunk f39b1f2 Diff Change
App Size (Mac) 1454.06 MB 1454.06 MB +0.00 MB ⚪ 0.0%

site-editor

Metric trunk f39b1f2 Diff Change
load 1494 ms 1502 ms +8 ms ⚪ 0.0%

site-startup

Metric trunk f39b1f2 Diff Change
siteCreation 8086 ms 8080 ms 6 ms ⚪ 0.0%
siteStartup 4934 ms 4923 ms 11 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@youknowriad youknowriad merged commit 7227de3 into trunk May 6, 2026
11 checks passed
@youknowriad youknowriad deleted the claude/kind-bell-f0946f branch May 6, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants