Studio Code: don't wipe in-progress typing on turn boundaries#3352
Merged
Conversation
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>
Collaborator
📊 Performance Test ResultsComparing f39b1f2 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues
How AI was used in this PR
Investigated the
AiChatUIlifecycle, identified the twoeditor.setText('')calls that fire across turn boundaries, and removed them after confirming pi-tui already clears the editor on submit.Proposed Changes
this.editor.setText('')fromAiChatUI.waitForInput()andAiChatUI.beginAgentTurn()inapps/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 additionalsetText('')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 severalawaits inrunAgentTurn(provider/env setup). Anything typed in that gap also gets wiped.In both cases the editor is already empty in the normal flow (because
submitValuecleared it), so removing these calls is a no-op except in the race window where the user's input was being lost.Testing Instructions
npm run cli:build && node apps/cli/dist/cli/main.mjs— start Studio Code.Pre-merge Checklist
trunkare unrelated.)🤖 Generated with Claude Code