Hmbown/CodeWhale · warning

Task not found

Error message

Task not found: {id}

What it means

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.

Solutions

  1. Ensure an interactive session exists before running task commands (start/attach a session so current_session_id is set)
  2. Verify the task id is correct — if a session exists, the delegated lookup may still fail; check the id against the task list
  3. Re-run the command after the session initializes rather than during startup

Example fix

// before
if app.current_session_id.is_none() {
    return Err(anyhow!("Task not found: {id}"));
}
// after
let Some(session_id) = app.current_session_id.clone() else {
    app.add_message(HistoryCell::System { content: "No active session; start one first.".into() });
    return Ok(());
};
Defensive patterns

Strategy: validation

Validate before calling

fn can_open_task(app: &App) -> bool {
    app.current_session_id.is_some()
}

Type guard

fn active_session(app: &App) -> Option<&str> {
    app.current_session_id.as_deref()
}

Try / catch

match open_task(app, &id).await {
    Err(e) if e.to_string().starts_with("Task not found") => {
        app.add_message(HistoryCell::System {
            content: "No active session or unknown task id.".into(),
        });
    }
    r => r?,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/e6cfa97c85eae1c9. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/tui/ui/apply.rs:2400

            AppAction::RemoteControl(action) => match action {
                crate::remote_control::RemoteControlAction::Start => {
                    start_remote_control_session(app, config);
                }
                crate::remote_control::RemoteControlAction::Stop => {
                    app.remote_control.stop();
                    let status = app.remote_control.status_line();
                    app.sticky_status = None;
                    app.status_message = Some(status);
                }
            },
            AppAction::TaskShow { id } => {
                let task = match app.current_session_id.as_deref() {
                    Some(session_id) => {
                        task_manager
                            .get_task_for_interactive_session(&id, session_id)
                            .await
                    }
                    None => Err(anyhow::anyhow!("Task not found: {id}")),
                };
                match task {
                    Ok(task) => open_task_pager(app, &task),
                    Err(err) => {
                        app.add_message(HistoryCell::System {
                            content: format!("Task lookup failed: {err}"),
                        });
                    }
                }
            }
            AppAction::TaskCancel { id } => {
                let cancellation = match app.current_session_id.as_deref() {
                    Some(session_id) => {
                        task_manager
                            .cancel_task_for_interactive_session(&id, session_id)
                            .await
                    }
                    None => Err(anyhow::anyhow!("Task not found: {id}")),

View on GitHub (pinned to 73e0f67d83)