fix(acp): reuse session by cwd in NewSession to persist history across Zed reloads #1600
Closed
Pnkcaht wants to merge 1 commit intodocker:mainfrom
Closed
fix(acp): reuse session by cwd in NewSession to persist history across Zed reloads #1600Pnkcaht wants to merge 1 commit intodocker:mainfrom
Pnkcaht wants to merge 1 commit intodocker:mainfrom
Conversation
…s Zed reloads (docker#1591) Signed-off-by: pnkcaht <samzoovsk19@gmail.com>
Contributor
|
I implemented the proper fixes in #1601 to make sure we follow the patterns used for other commands in cagent and create a consistent experience |
Contributor
Author
Ok, thanks friend :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I Did
NewSessioninpkg/acp/agent.goto persist and reuse sessions by working directory (cwd) using the SQLite session store.params.Cwdas a stable key to identify sessions (fallback to new UUID if empty).store.GetSessions(ctx).WorkingDiris found → reuse its ID and loaded session object.sessObj.WorkingDir = key, and persist immediately withstore.AddSession.This prevents session history loss after Zed reloads when cagent runs as an ACP server.
Releated issue
Closes #1591
Before vs After
Before (history lost after Zed reload):
NewSessioncall from Zed creates a new UUID.cagent sessionsshows only current in-memory sessions (old ones disappear).After (history preserved across Zed reloads):
NewSessionusesparams.Cwdas key.WorkingDirexists incagent_sessions.db→ reuse same session ID and load full state.Flow Diagram (Before vs After)
sequenceDiagram participant Zed as Zed Editor participant Cagent as cagent (ACP Server) participant DB as cagent_sessions.db Note over Zed,Cagent: Before (broken) Zed->>Cagent: NewSession (cwd: /project) Cagent-->>Zed: New UUID Note over Zed: Reload Zed->>Cagent: NewSession (same cwd) Cagent-->>Zed: Another new UUID Note over Zed: History lost Note over Zed,Cagent: After (fixed) Zed->>Cagent: NewSession (cwd: /project) Cagent->>DB: Find by WorkingDir DB-->>Cagent: Reuse ID abc-789 Cagent-->>Zed: Same SessionId Note over Zed: Reload → History preserved