feat: port upstream changes from pi-mono (6730b4fa..b74535dc)
Provider additions: - Added Amazon Bedrock provider with bedrock-converse-stream API - Added MiniMax provider with OpenAI-compatible API - Added EU cross-region inference model variants for Bedrock Provider fixes: - Fixed Gemini CLI retries with header parsing and empty stream retry logic - Fixed Bedrock tool call transforms via transformMessages - Fixed z.ai thinking/reasoning params - Fixed OpenRouter+Anthropic cache control - Fixed OpenAI responses timeout and service tier options - Fixed tool call ID normalization for cross-provider switches - Fixed thought signature validation for Google providers - Fixed prompt cache key using session ID TUI improvements: - Added OverlayOptions API with CSS-like positioning (SizeValue, percentages) - Added OverlayHandle for programmatic visibility control - Added visible callback for responsive overlays - Added pad parameter to truncateToWidth - Added pageUp/pageDown key support - Fixed numbered list items showing 1. when code blocks break continuity - Fixed overlay width overflow crash with complex ANSI sequences - Fixed light theme colors for WCAG AA compliance Coding agent fixes: - Fixed /new command to create new session file - Fixed session selector to stay open when folder has no sessions - Added session header emission in JSON print mode - Added queued message hint with theme.tree.hook - Exported highlightCode and getLanguageFromPath for extensions Also renamed transorm-messages.ts to transform-messages.ts (typo fix)
This commit is contained in:
@@ -664,18 +664,20 @@ export function applyBackgroundToLine(line: string, width: number, bgFn: (text:
|
||||
|
||||
/**
|
||||
* Truncate text to fit within a maximum visible width, adding ellipsis if needed.
|
||||
* Optionally pad with spaces to reach exactly maxWidth.
|
||||
* Properly handles ANSI escape codes (they don't count toward width).
|
||||
*
|
||||
* @param text - Text to truncate (may contain ANSI codes)
|
||||
* @param maxWidth - Maximum visible width
|
||||
* @param ellipsis - Ellipsis string to append when truncating (default: "...")
|
||||
* @returns Truncated text with ellipsis if it exceeded maxWidth
|
||||
* @param ellipsis - Ellipsis string to append when truncating (default: "…")
|
||||
* @param pad - If true, pad result with spaces to exactly maxWidth (default: false)
|
||||
* @returns Truncated text, optionally padded to exactly maxWidth
|
||||
*/
|
||||
export function truncateToWidth(text: string, maxWidth: number, ellipsis: string = "..."): string {
|
||||
export function truncateToWidth(text: string, maxWidth: number, ellipsis: string = "…", pad: boolean = false): string {
|
||||
const textVisibleWidth = visibleWidth(text);
|
||||
|
||||
if (textVisibleWidth <= maxWidth) {
|
||||
return text;
|
||||
return pad ? text + " ".repeat(maxWidth - textVisibleWidth) : text;
|
||||
}
|
||||
|
||||
const ellipsisWidth = visibleWidth(ellipsis);
|
||||
@@ -736,7 +738,12 @@ export function truncateToWidth(text: string, maxWidth: number, ellipsis: string
|
||||
}
|
||||
|
||||
// Add reset code before ellipsis to prevent styling leaking into it
|
||||
return `${result}\x1b[0m${ellipsis}`;
|
||||
const truncated = `${result}\x1b[0m${ellipsis}`;
|
||||
if (pad) {
|
||||
const truncatedWidth = visibleWidth(truncated);
|
||||
return truncated + " ".repeat(Math.max(0, maxWidth - truncatedWidth));
|
||||
}
|
||||
return truncated;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user