{"record":{"id":"e6cfa97c85eae1c9","repo":"Hmbown/CodeWhale","slug":"task-not-found-id-e6cfa9","errorCode":null,"errorMessage":"Task not found: {id}","messagePattern":"Task not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/tui/ui/apply.rs","lineNumber":2400,"sourceCode":"            AppAction::RemoteControl(action) => match action {\n                crate::remote_control::RemoteControlAction::Start => {\n                    start_remote_control_session(app, config);\n                }\n                crate::remote_control::RemoteControlAction::Stop => {\n                    app.remote_control.stop();\n                    let status = app.remote_control.status_line();\n                    app.sticky_status = None;\n                    app.status_message = Some(status);\n                }\n            },\n            AppAction::TaskShow { id } => {\n                let task = match app.current_session_id.as_deref() {\n                    Some(session_id) => {\n                        task_manager\n                            .get_task_for_interactive_session(&id, session_id)\n                            .await\n                    }\n                    None => Err(anyhow::anyhow!(\"Task not found: {id}\")),\n                };\n                match task {\n                    Ok(task) => open_task_pager(app, &task),\n                    Err(err) => {\n                        app.add_message(HistoryCell::System {\n                            content: format!(\"Task lookup failed: {err}\"),\n                        });\n                    }\n                }\n            }\n            AppAction::TaskCancel { id } => {\n                let cancellation = match app.current_session_id.as_deref() {\n                    Some(session_id) => {\n                        task_manager\n                            .cancel_task_for_interactive_session(&id, session_id)\n                            .await\n                    }\n                    None => Err(anyhow::anyhow!(\"Task not found: {id}\")),","sourceCodeStart":2382,"sourceCodeEnd":2418,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tui/ui/apply.rs#L2382-L2418","documentation":"When handling a 'task open' style command, a task id is resolved via task_manager.get_task_for_interactive_session. If the app has no current interactive session (current_session_id is None), no lookup is even attempted and 'Task not found: {id}' is returned immediately.","triggerScenarios":"Issuing a task-open command when app.current_session_id is None — e.g. before any session has been created, in a fresh startup state, or from a context where the task command ran outside an interactive session.","commonSituations":"Running /task <id> right after launching before a session attaches; task commands dispatched from an event path (execute_command_input, run_event_loop) during startup; a stale automation invoking task commands headlessly.","solutions":["Ensure an interactive session exists before running task commands (start/attach a session so current_session_id is set)","Verify the task id is correct — if a session exists, the delegated lookup may still fail; check the id against the task list","Re-run the command after the session initializes rather than during startup"],"exampleFix":"// before\nif app.current_session_id.is_none() {\n    return Err(anyhow!(\"Task not found: {id}\"));\n}\n// after\nlet Some(session_id) = app.current_session_id.clone() else {\n    app.add_message(HistoryCell::System { content: \"No active session; start one first.\".into() });\n    return Ok(());\n};","handlingStrategy":"validation","validationCode":"fn can_open_task(app: &App) -> bool {\n    app.current_session_id.is_some()\n}","typeGuard":"fn active_session(app: &App) -> Option<&str> {\n    app.current_session_id.as_deref()\n}","tryCatchPattern":"match open_task(app, &id).await {\n    Err(e) if e.to_string().starts_with(\"Task not found\") => {\n        app.add_message(HistoryCell::System {\n            content: \"No active session or unknown task id.\".into(),\n        });\n    }\n    r => r?,\n}","preventionTips":["Gate task commands behind 'has active session' checks in the command dispatcher","List available tasks with the task-list command before opening by id","Avoid firing task commands during startup event processing before a session attaches"],"tags":["task-lookup","session","not-found","cli"],"backgroundTag":"entity-not-found","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}