fix(acp): use global session list for unstable_listSessions#18645
fix(acp): use global session list for unstable_listSessions#18645Haohao-end wants to merge 2 commits intoanomalyco:devfrom
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Potential duplicate found:
This PR appears to be addressing the exact same issue (#18575) with nearly identical changes. Both PRs fix the same problem where ACP's You should check whether PR #18576 is already merged or if one of these PRs should be closed in favor of the other. |
atharvau
left a comment
There was a problem hiding this comment.
Code Review for PR #18645: ACP Session List Fix
✅ Overall Assessment: APPROVED
This PR fixes a significant issue in the ACP agent by switching from local session filtering to the global experimental session list API. This is both a correctness fix and a performance improvement.
🔍 Changes Summary
File: packages/opencode/src/acp/agent.ts
- Replaces manual session filtering with
sdk.experimental.session.list - Uses proper pagination with cursor from response headers
- Removes manual sorting and slicing logic
File: packages/opencode/test/acp/list-sessions.test.ts
- Adds comprehensive test coverage for the new implementation
- Mocks SDK properly to test pagination behavior
✅ What's Good
- Correct API Usage: Now uses the proper global session list instead of local directory-scoped filtering
- Better Performance: Delegates pagination to the server instead of client-side processing
- Proper Pagination: Uses standard cursor-based pagination from response headers
- Excellent Test Coverage: Comprehensive test that verifies the API calls and response mapping
- Clean Refactoring: Removes ~15 lines of manual pagination logic
🔧 Code Quality
- Simpler Logic: Much cleaner code without manual sorting/filtering
- Proper Error Handling: Maintains
throwOnError: truebehavior - Consistent Mapping: Session response mapping remains unchanged
🧪 Testing
The test is well-structured:
- Good Mocking: Creates realistic SDK mock with proper response structure
- Proper Cleanup: Uses try/finally to ensure agent cleanup
- Complete Coverage: Tests both input parameters and output mapping
- Realistic Data: Uses actual timestamp values and proper data structure
🚀 Recommendation: APPROVE
This is an excellent fix that corrects a fundamental issue while improving code quality and adding proper test coverage. The change simplifies the implementation while making it more correct.
Rating: ⭐⭐⭐⭐⭐
atharvau
left a comment
There was a problem hiding this comment.
Code Review Summary
Overall Assessment: ✅ APPROVE with Minor Concerns
Good refactoring to use the global session API, but needs consideration of behavioral changes.
✅ Strengths:
- Better API Usage: Migrates from deprecated local session list to global experimental API
- Proper Pagination: Uses cursor-based pagination from headers
- Comprehensive Tests: Well-written test coverage validates the new behavior
- Performance: More efficient than client-side filtering/sorting
🟡 Potential Issues:
- Behavioral Change: Now returns global sessions instead of directory-scoped sessions
- API Dependency: Relies on experimental API (stability concerns)
- Parameter Ignored:
params.cwdparameter is completely ignored now
Security & Performance:
- ✅ No security issues
- ✅ Better performance (server-side pagination)
- ✅ Proper error handling
Breaking Changes:
⚠️ API behavior change: Previously filtered by directory, now returns global sessions- This may affect clients expecting directory-scoped results
Recommendation: Approve, but consider if the behavioral change is intentional and documented.
|
Reopening this PR. I accidentally closed it while trying to respond to the review thread. To clarify the behavior change: this is intentional for #18575. |
Issue for this PR
Closes #18575
Type of change
What does this PR do?
unstable_listSessionswas using the project-scoped session list path, so ACP only returned sessions for the current project.This changes it to use the global session list path and keeps the existing response mapping and pagination behavior.
How did you verify your code works?
unstable_listSessionsbun test test/acp/list-sessions.test.tsbun typecheckScreenshots / recordings
N/A
Checklist