-
Notifications
You must be signed in to change notification settings - Fork 726
fix(agent): sync session project dir #1554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -415,9 +415,14 @@ export class AgentSessionPresenter { | |
| if (normalizedInput.text.trim() || (normalizedInput.files?.length ?? 0) > 0) { | ||
| console.log(`[AgentSessionPresenter] firing queuePendingInput (non-blocking)`) | ||
| if (agent.queuePendingInput) { | ||
| agent.queuePendingInput(sessionId, normalizedInput, { source: 'send' }).catch((err) => { | ||
| console.error('[AgentSessionPresenter] queuePendingInput failed:', err) | ||
| }) | ||
| agent | ||
| .queuePendingInput(sessionId, normalizedInput, { | ||
| source: 'send', | ||
| projectDir | ||
| }) | ||
| .catch((err) => { | ||
| console.error('[AgentSessionPresenter] queuePendingInput failed:', err) | ||
| }) | ||
| } else { | ||
| agent.processMessage(sessionId, normalizedInput, { projectDir }).catch((err) => { | ||
| console.error('[AgentSessionPresenter] processMessage failed:', err) | ||
|
|
@@ -732,7 +737,10 @@ export class AgentSessionPresenter { | |
| session.projectDir ?? null | ||
| ) | ||
| if (agent.queuePendingInput) { | ||
| await agent.queuePendingInput(sessionId, normalizedInput, { source: 'send' }) | ||
| await agent.queuePendingInput(sessionId, normalizedInput, { | ||
| source: 'send', | ||
| projectDir: session.projectDir ?? null | ||
| }) | ||
| if (!hadMessages && !wasDraft) { | ||
| void this.generateSessionTitle(sessionId, session.title, providerId, state?.modelId ?? '') | ||
| } | ||
|
|
@@ -794,7 +802,10 @@ export class AgentSessionPresenter { | |
| currentSession.agentId, | ||
| currentSession.projectDir ?? null | ||
| ) | ||
| return await agent.queuePendingInput(sessionId, normalizedInput, { source: 'queue' }) | ||
| return await agent.queuePendingInput(sessionId, normalizedInput, { | ||
| source: 'queue', | ||
| projectDir: currentSession.projectDir ?? null | ||
| }) | ||
| } | ||
|
|
||
| async updateQueuedInput(sessionId: string, itemId: string, content: string | SendMessageInput) { | ||
|
|
@@ -1696,12 +1707,25 @@ export class AgentSessionPresenter { | |
| throw new Error(`Session not found: ${sessionId}`) | ||
| } | ||
|
|
||
| this.sessionManager.update(sessionId, { projectDir }) | ||
| const agent = await this.resolveAgentImplementation(session.agentId) | ||
| const state = await agent.getSessionState(sessionId) | ||
| const providerId = | ||
| state?.providerId?.trim() || | ||
| ((await this.getAgentType(session.agentId)) === 'acp' ? 'acp' : '') | ||
| const normalizedProjectDir = projectDir?.trim() || null | ||
| this.assertAcpSessionHasWorkdir(providerId, normalizedProjectDir) | ||
|
|
||
| this.sessionManager.update(sessionId, { projectDir: normalizedProjectDir }) | ||
|
|
||
| // Sync environment for new project dir | ||
| if (projectDir) { | ||
| this.sqlitePresenter.newEnvironmentsTable.syncPath(projectDir) | ||
| if (normalizedProjectDir) { | ||
| this.sqlitePresenter.newEnvironmentsTable.syncPath(normalizedProjectDir) | ||
| } | ||
|
|
||
| if (agent.setSessionProjectDir) { | ||
| await agent.setSessionProjectDir(sessionId, normalizedProjectDir) | ||
| } | ||
| await this.syncAcpSessionWorkdir(providerId, sessionId, session.agentId, normalizedProjectDir) | ||
|
Comment on lines
+1718
to
+1728
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid committing the new workdir before downstream sync can fail. If 🤖 Prompt for AI Agents |
||
|
|
||
| const updated = this.sessionManager.get(sessionId) | ||
| if (!updated) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resync the previous environment path too.
syncPath()only recomputes the path you pass in. After Line 1718 moves a session from/oldto/newor clears the directory, the aggregate row for/oldis left stale because only the new pathis refreshed here.
♻️ Suggested fix
🤖 Prompt for AI Agents