From 6b5b801daeeda0b83759ea7e7cc0442ebe187bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=87=AF90331?= <90331@sangfor.com> Date: Fri, 15 May 2026 11:06:18 +0800 Subject: [PATCH] fix(ink): treat newline as return and suppress favorite fetch error in TUI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some terminals on CentOS emit \n or \r\n instead of \r for the Enter key. Map both sequences to 'return' in parseKeypress so key.return is set correctly. Replace console.warn with logForDebugging in favorite.ts to prevent network errors from polluting the TUI output. Signed-off-by: 林凯90331 <90331@sangfor.com> Co-authored-by: CoStrict --- packages/@ant/ink/src/core/parse-keypress.ts | 5 +++-- src/costrict/favorite/favorite.ts | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/@ant/ink/src/core/parse-keypress.ts b/packages/@ant/ink/src/core/parse-keypress.ts index 892fb5cca..6febc862e 100644 --- a/packages/@ant/ink/src/core/parse-keypress.ts +++ b/packages/@ant/ink/src/core/parse-keypress.ts @@ -697,11 +697,12 @@ function parseKeypress(s: string = ''): ParsedKey { return createNavKey(s, 'mouse', false) } - if (s === '\r') { + if (s === '\r' || s === '\r\n') { key.raw = undefined key.name = 'return' } else if (s === '\n') { - key.name = 'enter' + key.raw = undefined + key.name = 'return' } else if (s === '\t') { key.name = 'tab' } else if (s === '\b' || s === '\x1b\b') { diff --git a/src/costrict/favorite/favorite.ts b/src/costrict/favorite/favorite.ts index 45b3b659a..25887d475 100644 --- a/src/costrict/favorite/favorite.ts +++ b/src/costrict/favorite/favorite.ts @@ -6,6 +6,7 @@ import { getClaudeConfigHomeDir } from '../../utils/envUtils.js' import { saveGlobalConfig, getGlobalConfig } from '../../utils/config.js' import { clearSkillCaches } from '../../skills/loadSkillsDir.js' import { parseFrontmatter } from '../../utils/frontmatterParser.js' +import { logForDebugging } from '../../utils/debug.js' import type { McpServerConfig } from '../../services/mcp/types.js' const FAVORITE_PAGE_SIZE = 20 @@ -611,7 +612,7 @@ export async function listFavoriteItems(type?: FavoriteItemType): Promise