Skip to content

fix(web-shell): restore context tags in queued and recalled prompts - #7312

Merged
yiliang114 merged 5 commits into
QwenLM:mainfrom
dreamWB:codex/webshell-custom-context-tag-restore
Jul 21, 2026
Merged

fix(web-shell): restore context tags in queued and recalled prompts#7312
yiliang114 merged 5 commits into
QwenLM:mainfrom
dreamWB:codex/webshell-custom-context-tag-restore

Conversation

@dreamWB

@dreamWB dreamWB commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

What this PR does

This PR keeps host-defined context references rendered as tags after a prompt enters the pending queue and when a user recalls a previous prompt through ArrowUp/ArrowDown or history search. It reuses the existing Web Shell customization contract and readonly tag renderer, validates parser output before using it, preserves the serialized prompt byte-for-byte, and regenerates input annotations through the normal submit path. No package-level API changes are introduced.

Why it's needed

The host customization added in #6578 renders context tags correctly in the composer and user-message bubbles, but two secondary prompt surfaces still exposed the raw serialized context syntax. Queued prompts displayed the original markup, and recalled prompts restored plain text instead of inline tags. Besides the visual regression, an immediately resubmitted history item could lose annotations or accidentally retain stale top-level tags.

Reviewer Test Plan

How to verify

Configure an existing parseUserMessageContent customization that maps a serialized context reference to a tag. Submit a prompt while another turn is active and confirm the queued preview renders the context as the host tag rather than raw markup. Recall the same prompt with ArrowUp/ArrowDown and with Ctrl-R using Tab, mouse selection, and Enter; confirm the composer restores inline tags, shell history remains raw, ArrowDown restores the draft, and resubmission preserves the exact serialized source with one matching input annotation. Also exercise a throwing, malformed, or source-mismatching parser and confirm the UI safely falls back to raw text.

Evidence (Before & After)

Before: pending queue rows and recalled history prompts exposed the host's serialized context markup as plain text. After: both surfaces render the same readonly/inline tag presentation already used by the composer and user-message bubbles, while the serialized prompt remains unchanged for submission. The behavior was manually verified in a real embedding-host debug session on macOS; no screenshot or recording is attached.

Tested on

OS Status
🍏 macOS ✅ tested
🪟 Windows ⚠️ not tested
🐧 Linux ⚠️ not tested

Environment (optional)

Tested locally on macOS with the repository Node/npm setup and an embedding-host debug build. Focused Web Shell tests passed (3 files, 47 tests), the full Web Shell suite passed (119 files, 1,918 tests), and the Web Shell coverage run passed (71.6% statements/lines, 78.3% branches, 61.72% functions). Web Shell lint, typecheck, build, git diff --check, and the repository pre-commit hook also passed. The exact root npm run preflight completed dependency setup, format, lint, build, and typecheck, then exited in the CLI test workspace on failures outside this seven-file Web Shell patch. Isolated reruns passed all 762 server tests and all 4 extension-list tests with an isolated Qwen home; one current-main AuthDialog assertion remains reproducible because Grok is now listed between DeepSeek and MiniMax while the unchanged test still sends one ArrowDown and expects MiniMax.

Risk & Scope

  • Main risk or tradeoff: Host parser output now participates in queue preview and history restoration, so malformed or non-lossless output must never crash or alter submitted text. The implementation validates parser/tag shapes inside an exception boundary and falls back to raw text when reconstruction does not exactly match the source.
  • Not validated / out of scope: Windows and Linux manual UI validation were not run, and no visual capture is attached. The current-main AuthDialog preflight baseline failure described above is not changed by this PR. Host-specific context schemas and workspace policies remain outside Web Shell.
  • Breaking changes / migration notes: None. This reuses the existing optional customization API; hosts that do not provide a parser retain the existing plain-text behavior.

Linked Issues

N/A — this is a follow-up bug fix to the host customization introduced by #6578; no separate issue was supplied.

中文说明

What this PR does

这个 PR 让宿主自定义的上下文引用在 prompt 进入待发送队列后,以及用户通过 ArrowUp/ArrowDown 或历史搜索召回旧 prompt 时,仍然以 tag 形式渲染。实现复用了现有的 Web Shell 自定义契约和只读 tag renderer,在使用 parser 输出前进行校验,逐字节保留序列化 prompt,并通过标准提交链路重新生成 input annotations。本次没有引入包级 API 变更。

Why it's needed

PR #6578 增加的宿主自定义能力已经能在输入框和用户消息气泡中正确渲染上下文 tag,但还有两个次级 prompt 展示面会暴露原始的序列化上下文语法:待发送 prompt 会直接展示原始标记,历史 prompt 被召回时也只会恢复成纯文本而不是内联 tag。除视觉回归外,立即重新提交历史项时还可能丢失 annotations,或者错误带入过期的顶层 tag。

Reviewer Test Plan

How to verify

配置一个现有的 parseUserMessageContent 自定义实现,把序列化上下文引用映射为 tag。在另一个 turn 正在执行时提交 prompt,确认队列预览展示宿主 tag,而不是原始标记。再通过 ArrowUp/ArrowDown,以及 Ctrl-R 的 Tab、鼠标选择和 Enter 路径召回同一个 prompt;确认输入框恢复内联 tag,shell 历史仍保持原始文本,ArrowDown 能恢复草稿,重新提交时序列化源文本完全一致且只生成一条匹配的 input annotation。还应让 parser 抛错、返回畸形结构或返回无法无损重建源文本的内容,并确认 UI 安全回退为原始文本。

Evidence (Before & After)

变更前:待发送队列行和召回的历史 prompt 会把宿主的序列化上下文标记直接显示为纯文本。变更后:这两个展示面会使用输入框和用户消息气泡已有的只读/内联 tag 展示,同时提交用的序列化 prompt 保持不变。该行为已在 macOS 上的真实嵌入宿主调试会话中完成人工验证;未附带截图或录屏。

Tested on

OS Status
🍏 macOS ✅ tested
🪟 Windows ⚠️ not tested
🐧 Linux ⚠️ not tested

Environment (optional)

在 macOS 上使用仓库的 Node/npm 环境和嵌入宿主调试构建完成验证。Web Shell 定向测试通过(3 个文件、47 个测试),完整 Web Shell 测试通过(119 个文件、1,918 个测试),Web Shell coverage 运行通过(statements/lines 71.6%、branches 78.3%、functions 61.72%)。Web Shell lint、typecheck、build、git diff --check 和仓库 pre-commit hook 也均通过。精确执行根目录 npm run preflight 时,依赖安装、format、lint、build 和 typecheck 均完成,随后在 CLI 测试 workspace 中因本次 7 文件 Web Shell 补丁范围外的失败而退出。隔离复跑后,762 个 server 测试全部通过,并且在隔离 Qwen home 后 4 个 extension-list 测试全部通过;当前主干仍可稳定复现一个 AuthDialog 断言失败,原因是 Grok 现在排在 DeepSeek 与 MiniMax 之间,而未更新的测试仍只发送一次 ArrowDown 就期望选中 MiniMax。

Risk & Scope

  • 主要风险或权衡:宿主 parser 输出现在会参与队列预览和历史恢复,因此畸形或非无损输出不能导致崩溃或改变提交文本。实现会在异常边界内校验 parser/tag 结构,并在重建结果不能与源文本完全一致时回退为原始文本。
  • 未验证或范围外:未进行 Windows 和 Linux 的人工 UI 验证,也未附带视觉截图。上面说明的当前主干 AuthDialog preflight 基线失败不在本 PR 修改范围内。宿主特定的上下文 schema 和 workspace 策略仍留在 Web Shell 之外。
  • 破坏性变更或迁移说明:无。本次复用现有的可选自定义 API;未提供 parser 的宿主保持原有纯文本行为。

Linked Issues

N/A — 这是对 #6578 所引入宿主自定义能力的后续 bug 修复;未提供独立 issue。

@qwen-code-ci-bot

qwen-code-ci-bot commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

🖼️ web-shell visual preview

Rendered against a mock daemon (no real backend): the PR base vs this PR head 0034989. Only screenshots that changed are shown (flows below, if any, are head-only) — refreshes on every push.

Screenshots · before / after

ℹ️ No screenshot changed against the PR base — but this PR edits 3 render-shaping files:

  • packages/web-shell/client/components/ChatEditor.tsx
  • packages/web-shell/client/components/QueuedPromptDisplay.tsx
  • packages/web-shell/client/components/messages/UserMessage.tsx

Either the change has no visual effect (logic, plumbing, a state the scenarios never reach), or no scenario renders this UI — in which case the preview cannot see it, and an empty result is a coverage gap rather than a clean bill of health. To make it visible, add a scenario to packages/web-shell/client/e2e/visuals/screenshots.spec.ts that seeds whatever state the UI is gated on; it then appears here as a head-only (NEW) capture.

Full-resolution recordings (.webm) are attached to the workflow run.

Qwen Code · web-shell visuals

@dreamWB
dreamWB force-pushed the codex/webshell-custom-context-tag-restore branch from 654d833 to 5143c14 Compare July 20, 2026 08:52
@github-actions

Copy link
Copy Markdown
Contributor

Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration.

中文

请勿对活跃的 PR 执行 rebase 或 force-push,因为这会使已有的评审评论失效。另外,供日后参考:作为集成流程的一部分,机器人始终会自动将所有改动压缩(squash)为单个提交。

@dreamWB
dreamWB force-pushed the codex/webshell-custom-context-tag-restore branch from 5143c14 to aba61a4 Compare July 20, 2026 09:48
Comment thread packages/web-shell/client/hooks/useComposerCore.ts
Comment thread packages/web-shell/client/utils/composerTag.ts
Comment thread packages/web-shell/client/components/QueuedPromptDisplay.tsx
@dreamWB
dreamWB force-pushed the codex/webshell-custom-context-tag-restore branch from aba61a4 to a7b1554 Compare July 20, 2026 11:28

@qwen-code-ci-bot qwen-code-ci-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed — no blockers. Suggestions are inline.

— qwen3.7-max via Qwen Code /review

Comment thread packages/web-shell/client/hooks/useComposerCore.ts
@dreamWB
dreamWB force-pushed the codex/webshell-custom-context-tag-restore branch from a7b1554 to e421a5d Compare July 20, 2026 16:29

@qwen-code-ci-bot qwen-code-ci-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed — no blockers. Suggestions are inline.

— qwen3.7-max via Qwen Code /review

Comment thread packages/web-shell/client/utils/composerTag.test.ts
@dreamWB
dreamWB force-pushed the codex/webshell-custom-context-tag-restore branch from e421a5d to a27e195 Compare July 20, 2026 19:03

@doudouOUC doudouOUC left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed — no blockers. Suggestions are inline.

— qwen3.7-max via Qwen Code /review

Comment thread packages/web-shell/client/hooks/useComposerCore.ts
Comment thread packages/web-shell/client/hooks/useComposerCore.ts

@qwen-code-ci-bot qwen-code-ci-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No issues found. LGTM! ✅

— qwen3.7-max via Qwen Code /review

@qwen-code-ci-bot qwen-code-ci-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No issues found. LGTM! ✅

— qwen3.7-max via Qwen Code /review

@dreamWB
dreamWB force-pushed the codex/webshell-custom-context-tag-restore branch from ddcb0f9 to 26551d3 Compare July 21, 2026 06:32

@qwen-code-ci-bot qwen-code-ci-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

⚠️ Downgraded from Approve to Comment: CI still running. Reviewed.

— qwen3.7-max via Qwen Code /review

@dreamWB
dreamWB force-pushed the codex/webshell-custom-context-tag-restore branch from 26551d3 to de656ac Compare July 21, 2026 07:45
@dreamWB

dreamWB commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

The visual harness does not configure a host parseUserMessageContent, so this host-defined state cannot be represented by its current scenarios. The queue/history behavior is covered by the focused DOM/component tests (80 tests) and the full WebShell suite (121 files, 1981 tests), and it was manually verified in the embedding host. Adding a host-customization visual fixture would require separate E2E harness work, so I am keeping that coverage expansion out of this focused fix.

@qwen-code-ci-bot qwen-code-ci-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No issues found. LGTM! ✅

— qwen3.7-max via Qwen Code /review

@dreamWB
dreamWB force-pushed the codex/webshell-custom-context-tag-restore branch 2 times, most recently from 350122a to 89d760e Compare July 21, 2026 10:27

@qwen-code-ci-bot qwen-code-ci-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No issues found. LGTM! ✅

— qwen3.7-max via Qwen Code /review

@dreamWB
dreamWB force-pushed the codex/webshell-custom-context-tag-restore branch from 89d760e to 0034989 Compare July 21, 2026 12:20
@yiliang114
yiliang114 added this pull request to the merge queue Jul 21, 2026
Merged via the queue into QwenLM:main with commit f4dbc7e Jul 21, 2026
31 of 32 checks passed
@qwen-code-ci-bot

Copy link
Copy Markdown
Collaborator

Released in v0.20.1.

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.

4 participants