fix: 解决 node 下 loading 按钮计算错误问题

This commit is contained in:
claude-code-best
2026-04-17 10:42:40 +08:00
parent c659912517
commit ac42ce2d67
3 changed files with 7 additions and 5 deletions

View File

@@ -27,7 +27,7 @@ jobs:
run: bun test --coverage --coverage-reporter=lcov run: bun test --coverage --coverage-reporter=lcov
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v5
with: with:
file: ./coverage/lcov.info file: ./coverage/lcov.info
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}

View File

@@ -597,7 +597,7 @@ function renderSystemMessage(text) {
const LOADING_ID = "loading-indicator"; const LOADING_ID = "loading-indicator";
// TUI star spinner frames (same as Claude Code CLI) // TUI star spinner frames (same as Claude Code CLI)
const SPINNER_FRAMES = ["·", "✢", "", "✶", "✻", "✽"]; const SPINNER_FRAMES = ["·", "✢", "", "✶", "✻", "✽"];
const SPINNER_CYCLE = [...SPINNER_FRAMES, ...SPINNER_FRAMES.slice().reverse()]; const SPINNER_CYCLE = [...SPINNER_FRAMES, ...SPINNER_FRAMES.slice().reverse()];
// 204 verbs from TUI src/constants/spinnerVerbs.ts // 204 verbs from TUI src/constants/spinnerVerbs.ts

View File

@@ -3,11 +3,13 @@ import type { RGBColor as RGBColorType } from './types.js'
export function getDefaultCharacters(): string[] { export function getDefaultCharacters(): string[] {
if (process.env.TERM === 'xterm-ghostty') { if (process.env.TERM === 'xterm-ghostty') {
return ['·', '✢', '', '✶', '✻', '*'] // Use * instead of ✽ for Ghostty because the latter renders in a way that's slightly offset return ['·', '✢', '', '✶', '✻', '*'] // ✱ replaces ✳ (emoji, renders offset in Ghostty); * replaces ✽ (same)
} }
// ✳ (U+2733) is matched by emoji-regex in Node.js → stringWidth returns 2 instead of 1,
// causing layout jitter when the spinner cycles frames. ✱ (U+2731) is visually similar but not emoji.
return process.platform === 'darwin' return process.platform === 'darwin'
? ['·', '✢', '', '✶', '✻', '✽'] ? ['·', '✢', '', '✶', '✻', '✽']
: ['·', '✢', '*', '✶', '✻', '✽'] : ['·', '✢', '', '✶', '✻', '✽']
} }
// Interpolate between two RGB colors // Interpolate between two RGB colors