From 0bc132688d7de7e6b926f23704feb96140a99709 Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Thu, 11 Jun 2026 17:48:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=20goalState=20?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=AD=98=E6=A0=B9=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=20CI=20=E6=9E=84=E5=BB=BA=E6=89=93=E5=8C=85=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI 中的 autonomy-lifecycle-user-flow 集成测试会执行 build.ts 打包 CLI。 此前 PromptInputFooterLeftSide.tsx 中 require('../../services/goal/goalState.js') 的路径在源码中不存在,打包器报 Could not resolve,导致 (unnamed) 测试失败。 新增 src/services/goal/goalState.ts 存根模块(getGoal 返回 null,组件不渲染), 让打包器在构建期可以解析该 require 路径。同时把 PromptInputFooterLeftSide.tsx 里两处 as unknown as 内联类型签名换成 as typeof import(...),让类型直接来自 存根模块,避免类型定义重复。 --- .../PromptInput/PromptInputFooterLeftSide.tsx | 7 ++--- src/services/goal/goalState.ts | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 src/services/goal/goalState.ts diff --git a/src/components/PromptInput/PromptInputFooterLeftSide.tsx b/src/components/PromptInput/PromptInputFooterLeftSide.tsx index d307dcb1b..77df155c6 100644 --- a/src/components/PromptInput/PromptInputFooterLeftSide.tsx +++ b/src/components/PromptInput/PromptInputFooterLeftSide.tsx @@ -137,10 +137,7 @@ function GoalElapsedIndicator(): React.ReactNode { }, []); void tick; - const goalModule = require('../../services/goal/goalState.js') as unknown as { - getGoal: () => { status: string; [k: string]: unknown } | null; - getActiveElapsedMs: (g: { status: string; [k: string]: unknown }) => number; - }; + const goalModule = require('../../services/goal/goalState.js') as typeof import('../../services/goal/goalState'); const goal = goalModule.getGoal(); if (!goal) return null; @@ -431,7 +428,7 @@ function ModeIndicator({ : []), // Goal elapsed indicator — compact "goal (XhYmin)" after PID ...(feature('GOAL') && - (require('../../services/goal/goalState.js') as unknown as { getGoal: () => unknown }).getGoal() + (require('../../services/goal/goalState.js') as typeof import('../../services/goal/goalState')).getGoal() ? [] : []), ]; diff --git a/src/services/goal/goalState.ts b/src/services/goal/goalState.ts new file mode 100644 index 000000000..18c304c8f --- /dev/null +++ b/src/services/goal/goalState.ts @@ -0,0 +1,30 @@ +/** + * Stub for the goal feature module. + * + * The goal feature is not yet implemented. This stub exists so that + * PromptInputFooterLeftSide.tsx's require() can be resolved by Bun's + * bundler (build.ts). At runtime, getGoal() returns null, so the + * GoalElapsedIndicator component renders nothing. + * + * When the goal feature is implemented, replace this stub with the + * real implementation. + */ + +export type GoalState = { + status: + | 'active' + | 'paused' + | 'budget_limited' + | 'usage_limited' + | 'blocked' + | 'complete' + [key: string]: unknown +} + +export function getGoal(): GoalState | null { + return null +} + +export function getActiveElapsedMs(_goal: GoalState): number { + return 0 +}