qwen-code/packages/cli
ChiGao 3d664336df
fix(cli): improve rendering on narrow terminals (#3968)
* fix(cli): improve rendering on narrow terminals

- TableRenderer: switch to vertical format when contentWidth < 60 cols,
  preventing wide horizontal tables from overflowing into scrollback on
  narrow terminals.
- Composer: suppress bottom loading indicator when terminal width ≤ 30
  cols during streaming, avoiding unnecessary redraws on ultra-narrow
  terminals.

Generated with AI

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* test(cli): cover narrow-terminal rendering branches + tighten thresholds

Address review feedback on #3968:

- Composer: drop redundant `isStreaming &&` guard from
  `suppressBottomLoadingIndicator`; the trailing
  `=== StreamingState.Responding` already implies streaming, and the
  redundancy risked future drift if `isStreaming` were extended.
- Composer.test: add four cases pinning the suppression contract —
  Responding @ 25/30 cols hides, @ 31 cols shows, and
  WaitingForConfirmation @ 25 cols still shows so confirmation
  prompts never disappear on narrow terminals.
- TableRenderer: replace the content-agnostic 60-col floor with a
  column-aware threshold
  (`max(24, colCount * MIN_COLUMN_WIDTH + borderOverhead + SAFETY_MARGIN)`)
  so a 2-column table with short values renders horizontally on a
  ~30-col terminal instead of being forced into vertical mode. The
  existing `maxLineWidth` post-build check still catches actual overflow.
- TableRenderer.test: add explicit horizontal-vs-vertical threshold
  cases (2 cols @ 60/30/20 and 5 cols @ 30) and bump the alignment
  tests to contentWidth=60 with `┌` guards so they fail loudly if the
  threshold ever pushes them back into vertical no-op mode.

Generated with AI

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(cli): preserve esc-to-cancel on narrow terminals + boundary tests

Address review feedback on the narrow-terminal rendering changes:

- Composer: when the full LoadingIndicator is suppressed on ≤30-col
  terminals during Responding, render a minimal "(esc to cancel)" text
  fallback so users retain the cancel affordance. Suppressing the full
  indicator still avoids layout breakage, but the affordance now stays
  visible.
- TableRenderer: clarify that `borderOverhead` is reused by the
  horizontal-vs-vertical layout threshold so a future change to the
  border-width formula does not silently shift the threshold.
- TableRenderer tests: add equality boundary cases at
  `ABSOLUTE_MIN_HORIZONTAL_TABLE_WIDTH` (24) and at the 5-column
  column-budget threshold (35), plus one-below cases, so a future
  `<` → `<=` regression on the strict comparator is caught.
- Composer tests: assert the fallback string is rendered when (and
  only when) the full indicator is suppressed.

Generated with AI

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>

* fix(cli): use existing 'Esc to cancel' i18n key for narrow-terminal fallback

The 169031d9c fix passed `'(esc to cancel)'` to `t()` but no such key
exists in any locale file. `t()` falls back to returning the key
verbatim, so English users saw correct text but non-English locales got
the untranslated English string — i.e. zero i18n coverage.

The repo already ships a translated `'Esc to cancel'` key in all 9
locales (used by QwenOAuthProgress and similar). Reuse it and move the
parentheses outside the call so the surrounding `()` is layout-only,
not translatable.

* test(Composer): update esc-fallback assertions to match i18n key casing

The cada422f8 fix switched the fallback from `t('(esc to cancel)')` to
`({t('Esc to cancel')})` (using the existing translated key). The
Composer tests still asserted lowercase 'esc to cancel' which no longer
appears in the rendered output.

Bump the two assertions to match the new casing.

---------

Co-authored-by: 秦奇 <gary.gq@alibaba-inc.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-05-12 13:58:38 +08:00
..
src fix(cli): improve rendering on narrow terminals (#3968) 2026-05-12 13:58:38 +08:00
index.ts fix(cli): stop double-wrapping and double-printing API errors in non-interactive mode (#3749) 2026-05-03 08:39:31 +08:00
package.json chore(deps): upgrade ink 6.2.3 → 7.0.2 + bump Node engine to 22 (#3860) 2026-05-11 17:29:50 +08:00
test-setup.ts fix: prevent bogus shell permission rules in tests 2026-03-20 17:55:33 +08:00
tsconfig.json Add background agent resume and continuation (#3739) 2026-05-01 12:14:33 +08:00
vitest.config.ts refactor(core): Unify package exports and improve dev experience 2026-02-01 11:59:05 +08:00