-
Notifications
You must be signed in to change notification settings - Fork 5
fix: pass directory param to OpenCode session rename API #373
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
Conversation
…sessions The session rename API requires a directory query parameter to find project-scoped sessions. Without it, only the global session store is searched, causing NotFoundError for project sessions.
Summary of ChangesHello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical bug preventing project-scoped sessions from being renamed correctly within the OpenCode environment. By introducing and properly utilizing a Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
WalkthroughThe change adds a required Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Fri Feb 6 02:37:20 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
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.
Code Review
This pull request correctly addresses a bug where project-scoped sessions could not be renamed by adding the necessary directory query parameter to the API call. The changes are well-contained, updating the renameSession helper and its callers in session-rename and sync_branch tools. I have one suggestion to improve the robustness of URL construction, but overall the fix is solid.
| const params = new URLSearchParams({ directory }) | ||
|
|
||
| try { | ||
| const response = await fetch(`${baseUrl}/session/${sessionID}`, { | ||
| const response = await fetch(`${baseUrl}/session/${sessionID}?${params}`, { |
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.
For improved robustness and readability when constructing URLs, it's better to use the URL API. This avoids manual string concatenation with ? and provides a cleaner way to manage query parameters, especially if more are added in the future.
| const params = new URLSearchParams({ directory }) | |
| try { | |
| const response = await fetch(`${baseUrl}/session/${sessionID}`, { | |
| const response = await fetch(`${baseUrl}/session/${sessionID}?${params}`, { | |
| const url = new URL(`/session/${sessionID}`, baseUrl); | |
| url.searchParams.set('directory', directory); | |
| try { | |
| const response = await fetch(url, { |
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.opencode/tool/session-rename.ts (1)
106-112:⚠️ Potential issue | 🟠 MajorBug:
git branch --show-currentignoresdirectory— runs in wrong working directory.The
sync_branchtool extractsdirectoryfrom context (line 103) and passes it torenameSession(line 118), but thegitcommand on line 108 doesn't scope to that directory. This causes the command to run in the process's current working directory instead of the project directory, returning incorrect branch information if they differ.The correct pattern already exists in
.agent/plugins/opencode-aidevops/index.mjs(line 129):git -C "${directory}" branch --show-current.🐛 Proposed fix
let branch: string try { - const branchResult = await Bun.$`git branch --show-current`.text() + const branchResult = await Bun.$`git -C ${directory} branch --show-current`.text() branch = branchResult.trim() } catch { return "Not in a git repository or git command failed"



Summary
directoryquery parameterNotFoundErrorfor project-scoped sessionsChanges
directoryparameter torenameSession()function signaturedirectoryfrom tool context to API calls viaURLSearchParamssession-renameandsync_branchtoolsTesting
session-renametool: confirmed working with title renamesync_branchtool: confirmed working with branch syncSummary by CodeRabbit
Release Notes