Codex stop-hook caught: even after the orchestrator-level reuse fix (a720aac1), `orchestrator-sub-agent.ts` still calls `isMobileFullScreen(plan)` independently in 2 places (L374 in executeSubAgent + L734 in buildSubAgentUserPrompt). Both run AFTER the orchestrator stripped the status-bar subtask, so they see a smaller subtask count than the orchestrator's pre-strip classify. A 2-subtask [status-bar, content] plan would flip from "mobile" → "not-mobile" across the strip, and sub-agent prompt builders would then disagree with the orchestrator about chrome handling — sub- agent emits its own status bar / wraps in a phone mockup. Architectural fix: classify ONCE per plan and memoize the result on a WeakMap keyed by the plan object. Subsequent calls (whether from orchestrator, executeSubAgent, or buildSubAgentUserPrompt) return the cached pre-mutation answer. WeakMap avoids polluting the public OrchestratorPlan type and lets the cache vacate naturally when the plan goes out of scope. This subsumes the orchestrator.ts L838 local-reuse fix from a720aac1 — that path is now safe via memo too — but the explicit reuse is retained as defense-in-depth + readability (clear that the same classification value is used at two adjacent call sites). Tests: 2 new cases — mutation-survives-classify + per-plan isolation. Existing 7 cases continue to pass. |
||
|---|---|---|
| .. | ||
| public | ||
| server | ||
| src | ||
| CLAUDE.md | ||
| components.json | ||
| dev.ts | ||
| package.json | ||
| tsconfig.json | ||
| vite.config.ts | ||