Skip to content

fix: resolve 43 pre-existing TypeScript errors in src/#257

Closed
amDosion wants to merge 2 commits intoclaude-code-best:mainfrom
amDosion:fix/src-typescript-errors
Closed

fix: resolve 43 pre-existing TypeScript errors in src/#257
amDosion wants to merge 2 commits intoclaude-code-best:mainfrom
amDosion:fix/src-typescript-errors

Conversation

@amDosion
Copy link
Copy Markdown
Collaborator

@amDosion amDosion commented Apr 14, 2026

Summary

  • Fix all 43 pre-existing TypeScript tsc --noEmit errors in src/ directory, bringing the count from 43 to 0
  • All fixes are precise and type-safe (no as any patches), validated via Codex external review

Changes by Category

Production Code (5 files)

File Issue Fix
REPL.tsx Missing getCwd and toError imports Add imports from utils/cwd.js and utils/errors.js
send/send.ts Missing removeSendOverride import Add to existing pipeMuteState.js import
spawnInProcess.ts teammateTask referenced outside setAppState callback scope Capture pendingAutonomyRunIds inside callback, use after
InProcessTeammateTask.tsx Conditional spread creates {} | undefined type widening; Message['origin'] resolves to unknown Replace spreads with typed locals; use MessageOrigin type
autonomyRuns.ts .map() return type doesn't match AutonomyRunRecord[] Introduce PersistedAutonomyRunRecord type + normalizePersistedRunRecord()

Test Code (3 files)

File Issue Fix
autonomy.test.ts result.value on LocalCommandResult union without narrowing Add expectTextResult() assertion helper
autonomyRuns.test.ts Nullable command/first/second from createAutonomyQueuedPrompt Add expect().not.toBeNull() + ! assertions
proactive.baseline.test.ts mod.call() called with 3 args, signature expects 2 Remove extraneous 3rd argument

Test plan

  • bunx tsc --noEmit — src/ errors: 0 (was 43)
  • bun test2757 pass / 1 fail (Langfuse test, pre-existing)
  • All 27 daemon restructure tests still pass

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added background session management with unified daemon commands (daemon ps/logs/attach/kill).
    • Added template job system with commands to list, create, and manage template-based jobs.
    • Added language selection command to switch between English, Chinese, and auto-detect modes.
    • Enhanced assistant session discovery and interactive session chooser.
    • Improved proactive autonomy mode with heartbeat task scheduling and managed flow progression.
    • Cross-platform background engine supporting tmux and detached process modes.
  • Documentation

    • Added comprehensive design and task documentation for daemon restructuring, background sessions, templates, and assistant functionality.

unraid added 2 commits April 13, 2026 23:15
Squashed merge of 5 feature branches:
1. fix/mcp-tsc-errors — 修复上游 MCP 重构后的 tsc 错误和测试失败
2. feat/pipe-mute-disconnect — Pipe IPC 逻辑断开、/lang 命令、mute 状态机
3. feat/stub-recovery-all — 实现全部 stub 恢复 (task 001-012)
4. feat/kairos-activation — KAIROS 激活解除阻塞 + 工具实现
5. codex/openclaw-autonomy-pr — 自治权限系统、运行记录、managed flows

Daemon 重构 (task 013-016):
- BgEngine 跨平台引擎抽象 (TmuxEngine + DetachedEngine)
- /daemon 命令层级化 (CLI + REPL 双注册)
- /job 命令层级化 (CLI + REPL 双注册)
- 旧命令向后兼容 (ps/logs/attach/kill/new/list/reply → deprecation)
- 12 个新测试
- REPL.tsx: add missing getCwd and toError imports
- send.ts: add missing removeSendOverride import
- spawnInProcess.ts: capture pendingAutonomyRunIds inside setAppState
  callback to avoid referencing out-of-scope teammateTask variable
- InProcessTeammateTask.tsx: replace conditional spread with typed
  locals to fix origin type widening; use MessageOrigin instead of
  Message['origin'] (which resolves to unknown due to index signature)
- autonomyRuns.ts: introduce PersistedAutonomyRunRecord type and
  normalizePersistedRunRecord function for proper type narrowing
- autonomy.test.ts: add expectTextResult helper for LocalCommandResult
  union narrowing; add null checks for createAutonomyQueuedPrompt
- autonomyRuns.test.ts: add non-null assertions after expect guards
- proactive.baseline.test.ts: remove extraneous 3rd argument to
  local-jsx command call()
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Introduces comprehensive autonomy management system with background session engine abstraction (tmux/detached), template/job state management, proactive mode activation with heartbeat tasks, managed autonomy flow orchestration, assistant session discovery, pipe muting controls, language preference system, daemon state persistence, and extensive test coverage across all new systems.

Changes

Cohort / File(s) Summary
Autonomy Authority & Core
src/utils/autonomyAuthority.ts, src/utils/autonomyFlows.ts, src/utils/autonomyRuns.ts, src/utils/autonomyPersistence.ts
New modules implementing autonomy authority loading (heartbeat tasks, agents), managed flow lifecycle, run persistence/tracking, and cross-instance locking for autonomy state.
Background Session Engines
src/cli/bg/engine.ts, src/cli/bg/engines/tmux.ts, src/cli/bg/engines/detached.ts, src/cli/bg/engines/index.ts, src/cli/bg/tail.ts, src/cli/bg.ts
Engine abstraction for background sessions with tmux and detached process implementations, log tailing, session discovery, and CLI handlers (ps/logs/attach/kill).
Daemon State & Management
src/daemon/state.ts, src/daemon/main.ts
Daemon state file persistence (~/.claude/daemon/remote-control.json), status querying, and unified daemon CLI command hierarchy with subcommand routing.
Template/Job System
src/jobs/state.ts, src/jobs/templates.ts, src/jobs/classifier.ts, src/cli/handlers/templateJobs.ts
Job directory management, template discovery/loading, job state persistence, and CLI handlers for list/new/reply/status operations.
Assistant Mode (KAIROS)
src/assistant/index.ts, src/assistant/gate.ts, src/assistant/sessionDiscovery.ts, src/assistant/AssistantSessionChooser.tsx, src/commands/assistant/assistant.tsx
Assistant mode activation, session discovery from sessions API, interactive session chooser, install wizard, and assistant command handler.
Pipe Muting & Transport Control
src/utils/pipeMuteState.ts, src/utils/pipePermissionRelay.ts, src/utils/pipeTransport.ts, src/hooks/usePipeMuteSync.ts, src/hooks/useMasterMonitor.ts, src/hooks/usePipeRelay.ts
Master-side pipe mute state management, send overrides, relay muting, and cross-slave synchronization for logical disconnect.
Language & Internationalization
src/utils/language.ts, src/utils/config.ts, src/commands/lang/index.ts, src/commands/lang/lang.ts
Language preference system with auto/en/zh resolution, display names, config persistence, and /lang command.
Command Modules
src/commands/daemon/index.ts, src/commands/daemon/daemon.tsx, src/commands/job/index.ts, src/commands/job/job.tsx, src/commands/autonomy.ts, src/commands/torch.ts
New REPL slash commands for daemon, job, autonomy management, and torch.
Feature Flags & CLI Entrypoints
build.ts, scripts/dev.ts, src/entrypoints/cli.tsx, src/commands.ts
Default feature flag additions (BG_SESSIONS, TEMPLATES), CLI fast-path routing consolidation, and conditional command registration.
Proactive & Autonomy Hooks
src/proactive/useProactive.ts, src/hooks/useScheduledTasks.ts, src/cli/print.ts, src/utils/handlePromptSubmit.ts
Proactive autonomy command creation, scheduled task fire handling with autonomy queueing, tick/run lifecycle tracking, and error finalization.
In-Process Teammate Integration
src/tasks/InProcessTeammateTask/InProcessTeammateTask.tsx, src/tasks/InProcessTeammateTask/types.ts, src/utils/swarm/inProcessRunner.ts, src/utils/swarm/spawnInProcess.ts
Autonomy run linkage to teammate messages, lifecycle tracking within teammates, and kill-handler autonomy failure marking.
Builtin Tools Updates
packages/builtin-tools/src/tools/PushNotificationTool/PushNotificationTool.ts, packages/builtin-tools/src/tools/SendUserFileTool/SendUserFileTool.ts
Bridge delivery for push notifications and file uploads with context-aware error handling.
Test Suites
src/__tests__/context.baseline.test.ts, src/proactive/__tests__/state.baseline.test.ts, src/commands/__tests__/autonomy.test.ts, src/commands/__tests__/proactive.baseline.test.ts, src/daemon/__tests__/*, src/cli/bg/__tests__/*, src/jobs/__tests__/*, src/utils/__tests__/*, src/services/api/openai/__tests__/*, src/services/langfuse/__tests__/*
Baseline test suites for context/CLAUDE.md, proactive state, autonomy, daemon, background sessions, jobs, autonomy authority/runs/flows, cron, language, language pipes, task summary, isolated OpenAI integration, and Langfuse integration.
API & Service Integration
src/services/api/openai/__tests__/queryModelOpenAI.isolated.ts, src/services/api/openai/__tests__/queryModelOpenAI.test.ts, src/services/api/openai/__tests__/streamAdapter.test.ts, src/services/awaySummary.ts, src/services/analytics/growthbook.ts, src/services/langfuse/__tests__/*
OpenAI stream adapter isolated testing, away summary localization, GrowthBook gate defaults and fallback reordering, and Langfuse isolated test migration.
REPL & Screen Updates
src/screens/REPL.tsx, src/main.tsx, src/commands/send/send.ts, src/commands/init.ts, src/commands/up.ts, src/commands/rollback.ts, src/hooks/useAwaySummary.ts
Autonomy run lifecycle in REPL/IPC, KAIROS gating refinement, send mute override support, autonomy agents path in init, up/rollback CLI handlers, and away summary hook cleanup.
CLI Handlers
src/cli/handlers/ant.ts
Real implementations for log, error, export, task management, and completion handlers (replacing stubs).
Test Plan & Documentation
docs/task/task-001-daemon-status-stop.md, docs/task/task-002-bg-sessions-ps-logs-kill.md, docs/task/task-003-templates-job-mvp.md, docs/task/task-004-assistant-session-attach.md, docs/task/task-013-bg-engine-abstraction.md, docs/task/task-014-daemon-command-hierarchy.md, docs/task/task-015-job-command-hierarchy.md, docs/task/task-016-backward-compat-tests.md, docs/features/daemon-restructure-design.md, docs/features/stub-recovery-design-1-4.md, docs/test-plans/openclaw-autonomy-baseline.md, .gitignore, 02-kairos (1).md
Task implementation specs, feature design docs, test plans, baseline documentation, and build/ignore file updates.
TypeScript Configuration & Utilities
tsconfig.json, tests/mocks/file-system.ts, src/utils/taskSummary.ts
Path alias additions for mcp-client and agent-tools packages, temp directory test utilities, and task summary rate limiting/status generation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant REPL
    participant AutonomyRuns
    participant AutonomyFlows
    participant HeartbeatTask
    participant ManagedStep

    User->>REPL: Trigger proactive tick / scheduled task
    activate REPL
    REPL->>AutonomyRuns: createAutonomyQueuedPrompt()
    activate AutonomyRuns
    AutonomyRuns->>AutonomyFlows: Check for managed flows
    activate AutonomyFlows
    AutonomyFlows-->>AutonomyRuns: Flow metadata (if exists)
    deactivate AutonomyFlows
    AutonomyRuns->>HeartbeatTask: Load & parse heartbeat authority
    activate HeartbeatTask
    HeartbeatTask-->>AutonomyRuns: Due tasks with steps
    deactivate HeartbeatTask
    AutonomyRuns->>AutonomyRuns: Create queued run + persist
    AutonomyRuns-->>REPL: QueuedCommand with autonomy metadata
    deactivate AutonomyRuns

    REPL->>REPL: Enqueue command for execution
    REPL->>REPL: markAutonomyRunRunning(runId)
    REPL->>REPL: Execute LLM turn
    REPL->>ManagedStep: finalizeAutonomyRunCompleted(runId)
    activate ManagedStep
    ManagedStep->>AutonomyFlows: Advance flow to next step
    activate AutonomyFlows
    AutonomyFlows-->>ManagedStep: Next step (if any)
    deactivate AutonomyFlows
    ManagedStep-->>REPL: Follow-up commands
    deactivate ManagedStep
    REPL->>REPL: Enqueue follow-up commands
    deactivate REPL
    REPL-->>User: Display autonomy run status
Loading
sequenceDiagram
    participant CLI
    participant SelectEngine
    participant TmuxEngine
    participant DetachedEngine
    participant Session

    CLI->>CLI: `claude --bg` or `daemon bg` invoked
    activate CLI
    CLI->>SelectEngine: selectEngine()
    activate SelectEngine
    
    alt Platform is Windows
        SelectEngine->>DetachedEngine: new DetachedEngine()
        activate DetachedEngine
        SelectEngine-->>CLI: DetachedEngine instance
        deactivate DetachedEngine
    else Platform is Unix-like
        SelectEngine->>TmuxEngine: new TmuxEngine()
        activate TmuxEngine
        TmuxEngine->>TmuxEngine: check tmux availability
        alt Tmux available
            SelectEngine-->>CLI: TmuxEngine instance
            deactivate TmuxEngine
        else Tmux unavailable
            SelectEngine->>DetachedEngine: new DetachedEngine()
            activate DetachedEngine
            SelectEngine-->>CLI: DetachedEngine instance
            deactivate DetachedEngine
        end
    end
    
    CLI->>Session: engine.start(opts)
    activate Session
    Session->>Session: Spawn process / create tmux session
    Session-->>CLI: BgStartResult { pid, sessionName, logPath, engineUsed }
    deactivate Session
    
    CLI->>Session: Persist session entry with engine field
    deactivate CLI
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~150+ minutes

Possibly related PRs

  • PR #153: Both modify src/services/analytics/growthbook.ts to update GrowthBook gate defaults and feature flag fallback logic—directly related at code level.
  • PR #232: Both modify src/screens/REPL.tsx (main PR adds autonomy run lifecycle; #232 adds other integrations)—same-file overlap.
  • PR #243: Both add/modify pipe, UDS, beacon, registry, and transport modules—extensively overlapping IPC/relay functionality.

Suggested labels

v6

Suggested reviewers

  • KonghaYao

Poem

🐰 Autonomy awakens in the daemon's gentle sleep,
Template jobs and flows now leap,
Sessions mute, pipes dance, languages gleam,
Where heartbeat tasks fulfill each team's dream! ✨
Build flags bloom and tests take wing,
What a glorious autonomy-spring! 🌱

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

@amDosion amDosion closed this Apr 14, 2026
@amDosion amDosion deleted the fix/src-typescript-errors branch April 14, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant