Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/cli/src/ui/components/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export const Composer = () => {
const isStreaming =
uiState.streamingState === StreamingState.Responding ||
uiState.streamingState === StreamingState.WaitingForConfirmation;
const suppressBottomLoadingIndicator =
isStreaming &&

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.

[Suggestion] isStreaming && 在此处是冗余条件。isStreaming 定义为 Responding || WaitingForConfirmation,而后续又用 === Responding 收窄,因此 isStreaming && === Responding 等价于 === Responding。冗余增加了维护风险:若未来有人扩展 isStreaming 的定义,会误以为此 guard 已覆盖新状态。

Suggested change
isStreaming &&
const suppressBottomLoadingIndicator =
uiState.streamingState === StreamingState.Responding &&
uiState.terminalWidth <= 30;

— DeepSeek/deepseek-v4-pro via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch — accepted in 0779de3. Dropped the redundant isStreaming && guard. Kept the explicit === Responding check so any future expansion of isStreaming (e.g. a new Idle-ish substate) doesn't silently widen suppression. Added a test pinning that WaitingForConfirmation on a 25-col terminal still shows the indicator.

uiState.streamingState === StreamingState.Responding &&
uiState.terminalWidth <= 30;

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.

[Suggestion] Magic number 30 — the narrow-terminal suppression threshold is a bare literal with no named constant or rationale comment. LoadingIndicator independently uses 80 for its internal isNarrowWidth() threshold. If LoadingIndicator is later restyled and grows wider than 30 columns, the suppression threshold silently becomes too aggressive.

Suggested change
uiState.terminalWidth <= 30;
const SUPPRESS_LOADING_INDICATOR_MAX_WIDTH = 30;
const suppressBottomLoadingIndicator =
uiState.streamingState === StreamingState.Responding &&
uiState.terminalWidth <= SUPPRESS_LOADING_INDICATOR_MAX_WIDTH;

— deepseek-v4-pro via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Adopted in 7f77d8d. Extracted to SUPPRESS_LOADING_INDICATOR_MAX_WIDTH with a JSDoc that flags the relationship to LoadingIndicator's independent internal isNarrowWidth() threshold (80) so a future LoadingIndicator restyle has a single, documented knob to adjust.


// Aggregate agent tool tokens from executing tool calls. Only changes when
// a subagent reports progress, so it doesn't drive the animation loop.
Expand Down Expand Up @@ -80,7 +84,7 @@ export const Composer = () => {

return (
<Box flexDirection="column" marginTop={1}>
{!uiState.embeddedShellFocused && (
{!uiState.embeddedShellFocused && !suppressBottomLoadingIndicator && (

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.

[Suggestion] This suppresses the whole LoadingIndicator on ultra-narrow terminals while responding. That component also carries the visible esc to cancel affordance, so this removes the only on-screen cancel hint during the active long-running state.

Consider preserving a compact fallback such as esc to cancel, or suppressing only the animation/phrase/timer-heavy parts while keeping the cancel hint visible.

— gpt-5.5 via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch — adopted the minimal-fallback approach. Composer now renders a compact (esc to cancel) text line at paddingLeft={2} whenever the full LoadingIndicator is suppressed (Responding on ≤30 cols). The spinner/phrase/timer remains hidden to avoid layout breakage on a 25-col terminal, but the cancel affordance stays visible. Added two Composer tests asserting the fallback shows when (and only when) the indicator is suppressed. Fixed in 169031d.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch — fixed in cada422. Switched to the existing t('Esc to cancel') key (option 1) and moved the parentheses outside the t() call so they are layout-only, not translatable. All 9 locales now resolve correctly.

<LoadingIndicator
// Hide loading phrases when enableLoadingPhrases is explicitly false.
// Using === false ensures phrases show by default when undefined.
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/ui/utils/TableRenderer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('<TableRenderer />', () => {
const output = renderTable(
['项目', 'ANSI', 'Markdown'],
[['中文内容', '\u001b[31mRed\u001b[0m Blue', '**bold** and `code`']],
42,
80,
['left', 'center', 'right'],
);
expectAllLinesToHaveSameVisibleWidth(output);
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/ui/utils/TableRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const MIN_COLUMN_WIDTH = 3;
/** Maximum number of lines per row before switching to vertical format */
const MAX_ROW_LINES = 4;

/** Narrow terminals make horizontal tables unreadable and scrollback-heavy. */

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.

[Suggestion] MIN_HORIZONTAL_TABLE_WIDTH = 60 是内容无关的硬阈值。一个 2 列、值为短字符串的表格在 50 列宽度下完全可以水平渲染,但会被强制切为垂直格式。渲染管线下游已有 maxLineWidth > contentWidth - SAFETY_MARGIN 的内容感知安全检查作为兜底,但新阈值直接绕过了它。建议:降低阈值至 40,或改为基于实际列宽的动态判断(如 colCount * MIN_COLUMN_WIDTH + borderOverhead + SAFETY_MARGIN)。

— DeepSeek/deepseek-v4-pro via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fair point — the fixed 60-col floor was content-agnostic. Replaced in 0779de3 with a column-aware threshold:

const minHorizontalTableWidth = Math.max(
  ABSOLUTE_MIN_HORIZONTAL_TABLE_WIDTH,  // 24, the readability floor
  colCount * MIN_COLUMN_WIDTH + borderOverhead + SAFETY_MARGIN,
);

So a 2-col table with short values now renders horizontally on a ~30-col terminal (2*3 + 7 + 4 = 17 < 30), while a 5-col table on the same width correctly falls back to vertical (5*3 + 16 + 4 = 35 > 30). The downstream maxLineWidth > contentWidth - SAFETY_MARGIN check is still in place as the content-aware safety net you noted. Added explicit threshold tests covering both directions.

const MIN_HORIZONTAL_TABLE_WIDTH = 60;

/** Safety margin to account for terminal resize races */
const SAFETY_MARGIN = 4;

Expand Down Expand Up @@ -392,7 +395,8 @@ export const TableRenderer: React.FC<TableRendererProps> = ({
}

const maxRowLines = calculateMaxRowLines();

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.

[Suggestion] calculateMaxRowLines() (iterates every cell through wrapText) runs before the minHorizontalTableWidth check. When contentWidth < minHorizontalTableWidth triggers vertical mode, all prior column-width allocation and wrapping work is discarded. The new column-aware threshold intends to provide a fast-path but doesn't actually short-circuit the expensive computation.

Consider hoisting the threshold check before column-width allocation:

Suggested change
const maxRowLines = calculateMaxRowLines();
const minHorizontalTableWidth = Math.max(
ABSOLUTE_MIN_HORIZONTAL_TABLE_WIDTH,
colCount * MIN_COLUMN_WIDTH + borderOverhead + SAFETY_MARGIN,
);
if (contentWidth < minHorizontalTableWidth) {
return <Box marginY={1}><Text>{renderVerticalFormat()}</Text></Box>;
}
// Only compute columnWidths and maxRowLines for the horizontal path

— deepseek-v4-pro via Qwen Code /review

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Adopted in 7f77d8d. Hoisted the minHorizontalTableWidth check above calculateMaxRowLines() and early-return to the vertical format. The per-cell wrapText pass (and the column-width allocation right before it) is now skipped whenever the terminal is already too narrow for horizontal layout — that work was discarded on the prior code path. Behavior is unchanged: same threshold, same vertical fallback, same secondary MAX_ROW_LINES check still gates the horizontal path. All 71 tests in Composer.test.tsx + TableRenderer.test.tsx pass; the existing equality-boundary tests at contentWidth 24/34/35 continue to pin the strict < comparator.

const useVerticalFormat = maxRowLines > MAX_ROW_LINES;
const useVerticalFormat =
contentWidth < MIN_HORIZONTAL_TABLE_WIDTH || maxRowLines > MAX_ROW_LINES;

// ── Helper: Get alignment for a column ──
const getAlign = (colIndex: number): ColumnAlign =>
Expand Down
Loading