Add session-scoped routes for follow-up and queue operations (Vibe Kanban) (#1606)

* Yup, I'll hold off and do nothing for now. Let me know when you're ready to proceed with the session routes task, and I'll start exploring the codebase and planning the implementation.

All cherry-pick conflicts resolved:

1. **`sessions/queue.rs`** - Fixed analytics to use `session.id` and `session.workspace_id` (2 locations)
2. **`task_attempts.rs`** - Removed the old `follow_up()` function that was already moved to `sessions/mod.rs`

No remaining conflict markers in the routes directory.

All fixes complete:

1. **`sessions/queue.rs`** ✓ - Fixed analytics to use `session.id` and `session.workspace_id`
2. **`task_attempts.rs`** ✓ - Removed old `follow_up` function (moved to sessions)
3. **`sessions/mod.rs`** ✓ - Fixed to use `find_latest_coding_agent_turn_session_id(pool, session.id)` instead of non-existent method

The session-based `follow_up` now correctly scopes the agent_session_id lookup to the current session rather than across all workspace sessions.

* All done:

1. ✓ `container.rs` - Changed to `find_latest_coding_agent_turn_session_id(pool, ctx.session.id)`
2. ✓ `pr.rs` - Changed to `find_latest_coding_agent_turn_session_id(pool, session.id)`
3. ✓ Deleted `find_latest_agent_session_id_by_workspace` from `execution_process.rs`

All workspace-scoped `agent_session_id` lookups have been converted to session-scoped lookups and the unused method has been removed.

Cleanup script changes for task attempt afc116fb-e639-4150-a299-b05c1f14f61e

Done. Removed the unnecessary `Session::create` call and now using `&ctx.session` directly.

Lint, db

* Done. Simplified the validation:
- Removed the extra `Session::find_by_id` DB call
- Now directly checks `process.session_id != session.id`
- Updated error message to "Process does not belong to this session"
This commit is contained in:
Alex Netsch
2025-12-19 12:46:24 +00:00
committed by GitHub
parent 84ea4b71ee
commit 6a129d0fa8
25 changed files with 459 additions and 436 deletions

View File

@@ -20,7 +20,6 @@ use db::{
project_repo::ProjectRepo,
repo::Repo,
scratch::{DraftFollowUpData, Scratch, ScratchType},
session::{CreateSession, Session},
task::{Task, TaskStatus},
workspace::Workspace,
workspace_repo::WorkspaceRepo,
@@ -742,13 +741,13 @@ impl LocalContainerService {
ctx: &ExecutionContext,
queued_data: &DraftFollowUpData,
) -> Result<ExecutionProcess, ContainerError> {
// Get executor profile from the latest CodingAgent process
let initial_executor_profile_id = ExecutionProcess::latest_executor_profile_for_workspace(
&self.db.pool,
ctx.workspace.id,
)
.await
.map_err(|e| ContainerError::Other(anyhow!("Failed to get executor profile: {e}")))?;
// Get executor profile from the latest CodingAgent process in this session
let initial_executor_profile_id =
ExecutionProcess::latest_executor_profile_for_session(&self.db.pool, ctx.session.id)
.await
.map_err(|e| {
ContainerError::Other(anyhow!("Failed to get executor profile: {e}"))
})?;
let executor_profile_id = ExecutorProfileId {
executor: initial_executor_profile_id.executor,
@@ -756,9 +755,9 @@ impl LocalContainerService {
};
// Get latest agent session ID for session continuity (from coding agent turns)
let latest_agent_session_id = ExecutionProcess::find_latest_agent_session_id_by_workspace(
let latest_agent_session_id = ExecutionProcess::find_latest_coding_agent_turn_session_id(
&self.db.pool,
ctx.workspace.id,
ctx.session.id,
)
.await?;
@@ -781,20 +780,9 @@ impl LocalContainerService {
let action = ExecutorAction::new(action_type, cleanup_action.map(Box::new));
// Create a new session for this follow-up
let session = Session::create(
&self.db.pool,
&CreateSession {
executor: Some(executor_profile_id.to_string()),
},
Uuid::new_v4(),
ctx.workspace.id,
)
.await?;
self.start_execution(
&ctx.workspace,
&session,
&ctx.session,
&action,
&ExecutionProcessRunReason::CodingAgent,
)