Skip to content

fix(acp): add tests asserting cwd and mcpServers are always passed to session/load (#1593)#1624

Open
theslava wants to merge 4 commits into
getpaseo:mainfrom
theslava:fix/acp-session-load-invariant
Open

fix(acp): add tests asserting cwd and mcpServers are always passed to session/load (#1593)#1624
theslava wants to merge 4 commits into
getpaseo:mainfrom
theslava:fix/acp-session-load-invariant

Conversation

@theslava

@theslava theslava commented Jun 20, 2026

Copy link
Copy Markdown

Linked issue

Closes #1593

Type of change

  • Bug fix
  • New feature (with prior issue + design alignment)
  • Refactor / code improvement
  • Docs

What does this PR do

Adds unit tests in acp-agent.test.ts that verify initializeResumedSession() always calls loadSession and unstable_resumeSession with { sessionId, cwd, mcpServers } — even when mcpServers is an empty array. Some strict ACP providers (e.g., Devin CLI) return "Invalid params" if any of these fields are omitted.

Also adds a docstring above initializeResumedSession() documenting this requirement so future refactors don't accidentally drop params.

How did you verify it

  • npx vitest run packages/server/src/server/agent/providers/acp-agent.test.ts --bail=1 — 59 tests passed
  • npm run typecheck — passed
  • npm run lint — passed
  • npm run format — ran

Risk surface

Tests only. No behavioral change — the existing code already passes all three params. This guards against a future refactor that might accidentally drop cwd or mcpServers.

Checklist

  • One focused change. Unrelated cleanups split out.
  • npm run typecheck passes
  • npm run lint passes
  • npm run format ran (Biome)
  • UI changes include screenshots or video for every affected platform (N/A: no UI changes)
  • Tests added or updated where it makes sense

@greptile-apps

greptile-apps Bot commented Jun 20, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds regression tests and a docstring to guard the invariant that initializeResumedSession() always passes cwd and mcpServers (even as an empty array) to both loadSession and unstable_resumeSession — a hard requirement for strict ACP providers such as Devin CLI that return "Invalid params" when these fields are absent. No behavioral changes are introduced.

  • A shared makeTestSession factory eliminates the per-test subclass duplication flagged in the previous review round, and handle is now passed via the typed constructor rather than a private-field cast.
  • Three focused tests cover: loadSession with supportsMcpServers: true, loadSession with supportsMcpServers: false (where acpMcpServers() short-circuits to []), and the unstable_resumeSession branch — all asserting the full { sessionId, cwd, mcpServers } shape.
  • A JSDoc comment above initializeResumedSession documents the constraint so future refactors cannot accidentally drop either field.

Confidence Score: 5/5

Safe to merge — purely additive tests and a docstring, zero production logic change.

All three tests exercise real code paths through initializeResumedSession, the shared factory is clean, and the docstring accurately describes the existing behavior. The PR addresses the two findings from the previous review round.

No files require special attention.

Important Files Changed

Filename Overview
packages/server/src/server/agent/providers/acp-agent.test.ts Adds a new describe block with three regression tests for initializeResumedSession, using a clean shared makeTestSession factory; addresses previous review comments about private-field casts and copy-paste duplication.
packages/server/src/server/agent/providers/acp-agent.ts Adds a JSDoc warning above initializeResumedSession documenting the ACP invariant that cwd and mcpServers must always be included in session/load calls; no behavioral change.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["initializeResumedSession()"] --> B{agentCapabilities\n.loadSession?}
    B -- yes --> C["connection.loadSession({\n  sessionId,\n  cwd, mcpServers\n})"]
    B -- no --> D{sessionCapabilities\n.resume?}
    D -- yes --> E["connection.unstable_resumeSession({\n  sessionId,\n  cwd, mcpServers\n})"]
    D -- no --> F["throw: provider does\nnot support resume"]
    C --> G["applySessionState()"]
    E --> G

    subgraph "acpMcpServers()"
        H{this.capabilities\n.supportsMcpServers?}
        H -- yes --> I["normalizeMcpServers(config.mcpServers)"]
        H -- no --> J["[] always returned"]
    end

    C -.->|calls| H
    E -.->|calls| H
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["initializeResumedSession()"] --> B{agentCapabilities\n.loadSession?}
    B -- yes --> C["connection.loadSession({\n  sessionId,\n  cwd, mcpServers\n})"]
    B -- no --> D{sessionCapabilities\n.resume?}
    D -- yes --> E["connection.unstable_resumeSession({\n  sessionId,\n  cwd, mcpServers\n})"]
    D -- no --> F["throw: provider does\nnot support resume"]
    C --> G["applySessionState()"]
    E --> G

    subgraph "acpMcpServers()"
        H{this.capabilities\n.supportsMcpServers?}
        H -- yes --> I["normalizeMcpServers(config.mcpServers)"]
        H -- no --> J["[] always returned"]
    end

    C -.->|calls| H
    E -.->|calls| H
Loading

Reviews (11): Last reviewed commit: "fix(tests): ensure ACP agent session loa..." | Re-trigger Greptile

Comment thread packages/server/src/server/agent/providers/acp-agent.test.ts
Comment thread packages/server/src/server/agent/providers/acp-agent.test.ts Outdated
@theslava theslava force-pushed the fix/acp-session-load-invariant branch 3 times, most recently from 2144f4f to 59180ec Compare June 25, 2026 20:17
@theslava

Copy link
Copy Markdown
Author

@greptileai

@theslava theslava force-pushed the fix/acp-session-load-invariant branch 2 times, most recently from 59180ec to 56ac34f Compare June 26, 2026 05:40
theslava added 2 commits June 26, 2026 08:58
… session/load (getpaseo#1593)

Add unit tests in acp-agent.test.ts that verify initializeResumedSession()
always calls loadSession and unstable_resumeSession with { sessionId, cwd,
mcpServers } — even when mcpServers is an empty array. Some strict ACP
providers (e.g., Devin CLI) return 'Invalid params' if any of these fields
are omitted.

Also adds a docstring above initializeResumedSession() documenting this
requirement so future refactors don't accidentally drop params.

Closes getpaseo#1593
- Extract shared makeTestSession() factory to eliminate duplicated TestSession
  class definitions across all three tests (concern getpaseo#1)
- Pass handle through typed constructor option instead of casting private
  initialHandle field (concern getpaseo#2)
- Add missing type imports for AgentCapabilityFlags and AgentPersistenceHandle
@theslava theslava force-pushed the fix/acp-session-load-invariant branch from 56ac34f to f4a07b8 Compare June 26, 2026 12:58
@boudra boudra enabled auto-merge (squash) June 26, 2026 13:09
auto-merge was automatically disabled June 26, 2026 14:27

Head branch was pushed to by a user without write access

@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown

Want your agent to iterate on Greptile's feedback? Try greploops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No test coverage asserting cwd and mcpServers are always passed to ACP session/load

1 participant