Skip to content

fix(code): switch input mode without flashing the mode trigger#4243

Merged
Mason Daugherty (mdrxy) merged 10 commits into
mainfrom
open-swe/chat-input-prefix-flash
Jun 26, 2026
Merged

fix(code): switch input mode without flashing the mode trigger#4243
Mason Daugherty (mdrxy) merged 10 commits into
mainfrom
open-swe/chat-input-prefix-flash

Conversation

@mdrxy

@mdrxy Mason Daugherty (mdrxy) commented Jun 25, 2026

Copy link
Copy Markdown
Member

Fixed a brief flash of the !// character when switching the chat input into shell, incognito, or command mode.


Typing a mode trigger (!, !!, /) at the start of the chat input flashed the literal character for one frame: TextArea inserted it, a re-entrant change pass stripped it, and watch_mode's call_after_refresh swapped the prompt glyph a frame later. This intercepts the trigger keystroke in ChatTextArea._on_key and switches the mode directly — without ever inserting the character — driving the same completion/hint refresh inline. Mode-detection logic is extracted into _resolve_prefix_mode, shared with the change handler, which still covers the paste/history/drag-drop paths.

Related: backspace mode exit

Because the trigger is now consumed rather than inserted-then-stripped, the prompt prefix is purely a mode selector and never lives in the draft text. Backspace exits command/shell mode when the cursor is at the start of the prompt, including an empty prompt or a draft with text after the cursor. That preserves the draft text while clearing mode-specific UI such as slash-command argument hints. Exiting a mode (via backspace or Escape) no longer restores /, !, or !! into the input.

Made by Open SWE

Typing a mode trigger (`!`, `!!`, `/`) at the start of the chat input
inserted the character, then a re-entrant change pass stripped it and a
`call_after_refresh` swapped the prompt glyph a frame later. That insert
-> strip round trip left the literal trigger visible for one frame.

Intercept the trigger keystroke in `ChatTextArea._on_key` and switch the
mode directly (via the extracted `_resolve_prefix_mode` shared with the
change handler) without ever inserting the character, driving the same
completion/hint refresh inline. The change handler still covers paste,
history, and drag-drop paths.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
@github-actions github-actions Bot added dcode Related to `deepagents-code` fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization open-swe size: S 50-199 LOC labels Jun 25, 2026
@mdrxy
Mason Daugherty (mdrxy) marked this pull request as ready for review June 25, 2026 06:52

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Open SWE Review: No issues found

Open SWE reviewed this PR and found no potential bugs to report.

Open in WebView Open SWE trace

@github-actions github-actions Bot added size: M 200-499 LOC and removed size: S 50-199 LOC labels Jun 26, 2026

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open SWE Review found 1 potential issue.

Open in WebView Open SWE trace

Comment thread libs/code/tests/unit_tests/test_chat_input.py
@mdrxy
Mason Daugherty (mdrxy) merged commit fc5d9cb into main Jun 26, 2026
54 checks passed
@mdrxy
Mason Daugherty (mdrxy) deleted the open-swe/chat-input-prefix-flash branch June 26, 2026 05:15
Mason Daugherty (mdrxy) added a commit that referenced this pull request Jun 26, 2026
> [!CAUTION]
> Merging this PR will automatically publish to **PyPI** and create a
**GitHub release**.

For the full release process, see
[`.github/RELEASING.md`](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md).

---

_Everything below this line will be the GitHub release body._

---


##
[0.1.25](deepagents-code==0.1.24...deepagents-code==0.1.25)
(2026-06-26)

### Bug Fixes

* Bind ephemeral port instead of squatting `langgraph dev`'s 2024
([#4264](#4264))
([11e5359](11e5359))
* Block dotenv shell startup hooks
([#4288](#4288))
([686d6f3](686d6f3))
* Defer server graph construction
([#4300](#4300))
([220dfc0](220dfc0))
* Avoid blocking MCP imports during graph readiness
([#4302](#4302))
([7533ca8](7533ca8))
* Gate `delete` file operations
([#4299](#4299))
([92a8681](92a8681))
* Handle recursive `fetch_url` conversion
([#4257](#4257))
([f240a40](f240a40))
* Report editable SDK runtime version
([#4304](#4304))
([4439e91](4439e91))
* Show months instead of "0y ago" for 360-364 day old timestamps
([#4267](#4267))
([820b331](820b331))
* Surface `/auth`-stored credentials in `config show`/`get`
([#4258](#4258))
([c7c8788](c7c8788))
* Switch input mode without flashing the mode trigger
([#4243](#4243))
([fc5d9cb](fc5d9cb))

---

_Everything above this line will be the GitHub release body._

---

> [!NOTE]
> A **New Contributors** section is appended to the GitHub release notes
automatically at publish time (see [Release
Pipeline](https://github.com/langchain-ai/deepagents/blob/main/.github/RELEASING.md#release-pipeline),
step 2).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Mason Daugherty <github@mdrxy.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dcode Related to `deepagents-code` fix A bug fix (PATCH) internal User is a member of the `langchain-ai` GitHub organization open-swe size: M 200-499 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant