fix: 添加 goalState 模块存根,修复 CI 构建打包解析失败

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(...),让类型直接来自
存根模块,避免类型定义重复。
This commit is contained in:
claude-code-best
2026-06-11 17:48:56 +08:00
parent 551a62a2c2
commit 0bc132688d
2 changed files with 32 additions and 5 deletions

View File

@@ -137,10 +137,7 @@ function GoalElapsedIndicator(): React.ReactNode {
}, []); }, []);
void tick; void tick;
const goalModule = require('../../services/goal/goalState.js') as unknown as { const goalModule = require('../../services/goal/goalState.js') as typeof import('../../services/goal/goalState');
getGoal: () => { status: string; [k: string]: unknown } | null;
getActiveElapsedMs: (g: { status: string; [k: string]: unknown }) => number;
};
const goal = goalModule.getGoal(); const goal = goalModule.getGoal();
if (!goal) return null; if (!goal) return null;
@@ -431,7 +428,7 @@ function ModeIndicator({
: []), : []),
// Goal elapsed indicator — compact "goal (XhYmin)" after PID // Goal elapsed indicator — compact "goal (XhYmin)" after PID
...(feature('GOAL') && ...(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()
? [<GoalElapsedIndicator key="goal-elapsed" />] ? [<GoalElapsedIndicator key="goal-elapsed" />]
: []), : []),
]; ];

View File

@@ -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
}