From 0970bd3180bbd37a257716d34575f59f34c22e74 Mon Sep 17 00:00:00 2001 From: yanghang <2390375302@qq.com> Date: Mon, 8 Jun 2026 23:53:52 +0800 Subject: [PATCH] fix(tui-v3): expand pasted placeholders before slash-command dispatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Slash commands returned from _on_enter before _expand ran, so a command argument carried the literal [Pasted text #N] / [File #N] / [Image #N] placeholder instead of the real content — e.g. `/morphling ` reached the agent as the marker string, not the paste. Expand placeholders at the top of the command branch (mirroring the normal submit path) and clear the placeholder stores afterward. No-op for commands without placeholders. --- frontends/tui_v3.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/frontends/tui_v3.py b/frontends/tui_v3.py index 57efeb8f9..de104f333 100644 --- a/frontends/tui_v3.py +++ b/frontends/tui_v3.py @@ -3997,12 +3997,20 @@ def _on_enter(self) -> None: self._run_shell(raw[1:].strip()) return if raw.startswith('/'): + # Expand pasted/file/image placeholders BEFORE dispatch so a command + # carries the real pasted text, not a `[Pasted text #N]` marker — e.g. + # `/morphling `. Without this the command + # path returned here before the expansion below ever ran, so the agent + # got the literal placeholder. `self.hist` already kept the raw input. + expanded = self._expand(raw) # /btw owns its own live-region panel — keep the command itself # out of the main scrollback. - cmd0 = (raw[1:].split(None, 1)[0] or '').lower() + cmd0 = (expanded[1:].split(None, 1)[0] or '').lower() if cmd0 != 'btw': - self._commit_user(raw) - self._cmd(raw); return + self._commit_user(expanded) + self._cmd(expanded) + self._pstore.clear(); self._fstore.clear(); self._imgs.clear() + return # Expand placeholders FIRST so the agent receives the resolved text, # not the [Image #N] / [Pasted #N] markers. This matches the idle # submit path below — keeping the form identical means a queued