Commit graph

2 commits

Author SHA1 Message Date
顾盼
21a40bd74a
feat(cli): support /copy N to copy Nth-last AI message (#4761)
* feat(cli): support /copy N to copy Nth-last AI message

Lets users grab earlier AI replies without scrolling — `/copy 2` copies
the second-to-last AI message, `/copy 3 code python` extracts the last
Python code block from the third-to-last, etc. Useful when the agent's
final action is something low-signal (TODO update, status line) and the
substantive output is one or two turns back.

The arg parser strips a leading positive-integer token and treats it as
a 1-based message index (1 = last AI message); the remaining tokens are
passed unchanged to the existing code/LaTeX sub-selectors. `/copy code
python 2` keeps its prior meaning (2nd python block in last message)
because its leading token isn't a digit.

Closes #4744

* feat(cli): add argumentHint for /copy so completion menu shows syntax

* feat(cli): simplify /copy argumentHint to [N], add four-component regression test

Claude Code's /copy only exposes N as an arg ("Copy Claude's last response
to clipboard (or /copy N for the Nth-latest)"); block selection happens in
a UI picker, not via command syntax. Aligning the hint with that — the
existing code/latex/<lang>/<index> sub-selectors still work but they were
never advertised in a hint before and double-numeric "[N] … [<index>]"
was confusing.

Also lock in /copy 3 code python 2 (message-index + code + lang +
within-message block-index) as a regression test, since that combo was
not previously asserted.

* feat(cli): inline /copy N hint in description across all 9 locales

The `[N]` argumentHint alone is opaque — users see "[N]" in the
completion menu but the description "Copy the last result or code
snippet to clipboard" never says what N does. Claude Code's /copy
solves this by inlining the hint in the description itself: "Copy
Claude's last response to clipboard (or /copy N for the Nth-latest)".

Mirror that pattern. The i18n key is the English source string, so
all 9 locale files (en/zh/zh-TW/de/fr/pt/ca/ru/ja) must update both
the key and the localized value to avoid orphaning translations and
falling back to English. Translated each one to keep parity.

Also drop "or code snippet" — code/latex sub-selection is a secondary
feature documented in docs/users/features/markdown-rendering.md, and
Claude Code's reference UX doesn't mention it in the description.

* fix(cli): /copy N — N-aware result wording, rename _args, polish de translation

Three review findings from a self-review pass:

1. Result strings hardcoded "last AI output" / "Last output copied" even
   when the user explicitly addressed an earlier message via /copy N. A
   user running `/copy 3 code` previously got "No matching code block
   found in the last AI output." — but they didn't ask about the last,
   they asked about the 3rd-last. Source label now branches on N:
   N=1 / no-N keep the original "last AI output" / "Last output copied"
   wording (tests stable); N>1 reads "AI message N". Covers the three
   "found in" error strings, the "contains no text to copy" branch,
   and the full-message success label. New tests assert the AI-message-N
   wording in the no-text and selector-miss cases.

2. The action handler signature still used `_args` (underscore-prefix
   indicates an unused parameter), but the body now reads from it via
   `parseLeadingMessageIndex(_args)`. Rename to `args` so the convention
   matches actual usage and other commands in this directory.

3. de translation `N-letzte` floats grammatically (adjective without a
   head noun); native speakers understand it but it reads clipped. Add
   the missing article: `für die N-letzte`.
2026-06-08 10:08:45 +08:00
ChiGao
7f0c9791b7
feat(cli): expand TUI markdown rendering (#3680)
Some checks are pending
Qwen Code CI / Lint (push) Waiting to run
Qwen Code CI / Test (push) Blocked by required conditions
Qwen Code CI / Test-1 (push) Blocked by required conditions
Qwen Code CI / Test-2 (push) Blocked by required conditions
Qwen Code CI / Test-3 (push) Blocked by required conditions
Qwen Code CI / Test-4 (push) Blocked by required conditions
Qwen Code CI / Test-5 (push) Blocked by required conditions
Qwen Code CI / Test-6 (push) Blocked by required conditions
Qwen Code CI / Test-7 (push) Blocked by required conditions
Qwen Code CI / Test-8 (push) Blocked by required conditions
Qwen Code CI / Post Coverage Comment (push) Blocked by required conditions
Qwen Code CI / CodeQL (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:docker (push) Waiting to run
E2E Tests / E2E Test (Linux) - sandbox:none (push) Waiting to run
E2E Tests / E2E Test - macOS (push) Waiting to run
SDK Python / SDK Python (3.10) (push) Waiting to run
SDK Python / SDK Python (3.11) (push) Waiting to run
SDK Python / SDK Python (3.12) (push) Waiting to run
* feat(cli): expand markdown rendering in tui

* fix(cli): render finalized mermaid images synchronously

* fix(cli): harden markdown rendering paths

* fix(cli): preserve mermaid source fallbacks

* test(cli): make mermaid image renderer mock cross-platform

* fix(cli): run windows mmdc shims through shell

* fix(cli): address markdown rendering review comments

* fix(cli): validate mermaid render timeout

* feat(cli): expose rendered markdown source blocks

* fix(cli): align mermaid source copy controls

* fix(cli): make markdown render toggle visible

* fix(cli): keep markdown render toggle quiet

* fix(cli): generalize markdown render mode

* fix(cli): broaden render mode and copy latex blocks

* fix(cli): align rendered copy source indices

* fix(cli): support copying inline latex expressions

* feat(cli): document markdown render controls

* test(cli): cover markdown render controls

* fix(cli): tighten markdown render fallbacks

* fix(cli): bound mermaid renderer cache

* fix(cli): address markdown render review feedback

* fix(cli): address markdown render review comments

* test(cli): strengthen render mode shortcut coverage

* fix(cli): address mermaid image review comments

* fix(cli): stabilize renderer output truncation

* test(cli): flush fake renderer stderr before exit

* fix(cli): address markdown renderer review feedback

* docs(cli): clarify mermaid image limits

* fix(cli): refresh mermaid images on height resize

* fix(cli): address markdown render review

* chore: revert unrelated review formatting churn

* fix(cli): avoid mermaid regex codeql alert

* fix(cli): silence mermaid operator codeql alert

* fix(cli): render inline math in markdown tables

* fix(cli): harden markdown visual renderers

* fix(cli): strip c1 controls from mermaid previews

---------

Co-authored-by: 秦奇 <gary.gq@alibaba-inc.com>
2026-05-07 16:24:13 +08:00