Skip to content

feat(sidebar): copy resume command with session directory - #221

Open
1fanwang wants to merge 2 commits into
matt1398:mainfrom
1fanwang:resume-command-include-cwd
Open

1fanwang wants to merge 2 commits into
matt1398:mainfrom
1fanwang:resume-command-include-cwd

Conversation

@1fanwang

@1fanwang 1fanwang commented Jun 30, 2026 •

Copy link
Copy Markdown

Why

The sidebar copied claude --resume <id>, so the resumed session started in whichever directory the terminal already used. Paths with spaces, quotes, shell variables, or Windows separators also made a pasted command unreliable.

What

The copied command now changes to the session's resolved project directory first. Both the directory and session ID use POSIX-safe single quoting, and Windows backslashes are normalized before quoting. If no project path is available, the command stays as a bare resume command.

Validation

git worktree add --detach /tmp/claude-devtools-resume-red \
  ba707a88e4ab0e72dc4854f2054718b3eeb41d2c
git diff ba707a88e4ab0e72dc4854f2054718b3eeb41d2c..823d2caa162b809e1e2ae722dece4bf0f1b789f6 \
  -- test/renderer/utils/resumeCommand.test.ts \
  | git -C /tmp/claude-devtools-resume-red apply -
ln -s "$PWD/node_modules" /tmp/claude-devtools-resume-red/node_modules
(cd /tmp/claude-devtools-resume-red && \
  ./node_modules/.bin/vitest run test/renderer/utils/resumeCommand.test.ts --maxWorkers=1)

./node_modules/.bin/vitest run test/renderer/utils/resumeCommand.test.ts --maxWorkers=1
Raw logs
# Before
Test Files  1 failed (1)
Tests       6 failed (6)

# After
Test Files  1 passed (1)
Tests       6 passed (6)

# The generated command treats shell syntax as the session ID argument
command=cd '/tmp/claude-devtools-resume-$HOME'\''s project' && claude --resume 'abc'\''; exit 42 #'
exit_code=0
args:
--resume
abc'; exit 42 #

Refs #34

Summary by CodeRabbit

  • New Features

    • “Copy Resume Command” now includes the session’s associated project directory, making resumed sessions launch in the correct location.
  • Bug Fixes

    • Resume commands now safely handle spaces, quotes, shell characters, and Windows-style paths.
    • Windows path separators are normalized for improved compatibility with POSIX shells.
    • Sessions without a working directory continue to produce a valid command without one.

…mand

"Copy Resume Command" copied `claude --resume <id>`, which resumes in whatever directory the terminal happens to be in — so users had to manually cd into the project first. Prefix the command with `cd "<cwd>"` using the project's resolved path (the encoded project dir is the session's launch cwd), quoted so paths with spaces survive the paste. Falls back to the bare command when the path can't be resolved.

The command builder is extracted as a pure, unit-tested helper (buildResumeCommand).
@coderabbitai coderabbitai Bot added the feature request New feature or request label Jun 30, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 introduces a helper function buildResumeCommand to automatically change directories to the session's working directory before resuming a Claude Code session, updating the context menu to use this command. The feedback suggests normalizing Windows backslashes to forward slashes to prevent shell syntax errors on cross-platform environments, along with adding a corresponding unit test.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/renderer/utils/resumeCommand.ts
Comment thread test/renderer/utils/resumeCommand.test.ts
@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: df31ff51-7198-4f8a-91a2-b3740a564411

📥 Commits

Reviewing files that changed from the base of the PR and between ba707a8 and 823d2ca.

📒 Files selected for processing (2)
  • src/renderer/utils/resumeCommand.ts
  • test/renderer/utils/resumeCommand.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/renderer/utils/resumeCommand.test.ts
  • src/renderer/utils/resumeCommand.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

buildResumeCommand now safely quotes session IDs and project paths, normalizes Windows separators, and preserves the bare-command fallback. SessionContextMenu resolves the project path from the renderer store and uses it when copying the resume command.

Changes

Resume Command with Project Path

Layer / File(s) Summary
Safe resume command construction
src/renderer/utils/resumeCommand.ts, test/renderer/utils/resumeCommand.test.ts
buildResumeCommand now applies POSIX-safe quoting, normalizes backslashes in working directories, and preserves fallback behavior for missing or empty directories. Tests cover these cases.
SessionContextMenu project path wiring
src/renderer/components/sidebar/SessionContextMenu.tsx
SessionContextMenu reads the project path for projectId from the renderer store and passes it to buildResumeCommand when copying the resume command.

Suggested labels: feature request, bug

Merge Risk: ⚪ Minimal · up to 823d2

The copied resume command now includes the resolved project directory with shell-safe quoting while preserving the fallback command when no path is available. No current merge-blocking risk is established.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/renderer/utils/resumeCommand.ts

Oops! Something went wrong! :(

ESLint: 9.39.5

Error: Error while loading rule 'tailwindcss/no-contradicting-classname': Could not find tailwindcss
Occurred while linting /src/renderer/utils/resumeCommand.ts
at new TailwindUtils (/.eslint-tmp/node_modules/.pnpm/tailwind-api-utils@1.0.3_tailwindcss@3.4.19_tsx@4.23.13_/node_modules/tailwind-api-utils/dist/index.cjs:375:13)
at resolve (/.eslint-tmp/node_modules/.pnpm/eslint-plugin-tailwindcss@3.18.3_tailwindcss@3.4.19_tsx@4.23.13_/node_modules/eslint-plugin-tailwindcss/lib/util/customConfig.js:21:27)
at getTailwindConfig (/.eslint-tmp/node_modules/.pnpm/eslint-plugin-tailwindcss@3.18.3_tailwindcss@3.4.19_tsx@4.23.13_/node_modules/eslint-plugin-tailwindcss/lib/util/tailwindAPI.js:9:17)
at Object.create (/.eslint-tmp/node_modules/.pnpm/eslint-plugin-tailwindcss@3.18.3_tailwindcss@3.4.19_tsx@4.23.13_/node_modules/eslint-plugin-tailwindcss/lib/rules/no-contradicting-classname.js:71:26)
at createRuleListeners (/.eslint-tmp/node_modules/.pnpm/eslint@9.39.5_jiti@1.21.7_supports-color@7.2.0/node_modules/eslint/lib/linter/linter.js:1019:15)
at /.eslint-tmp/node_modules/.pnpm/eslint@9.39.5_jiti@1.21.7_supports-color@7.2.0/node_modules/eslint/lib/linter/linter.js:1151:7
at Array.forEach ()
at runRules (/.eslint-tmp/node_modules/.pnpm/eslint@9.39.5_jiti@1.21.7_supports-color@7.2.0/node_modules/eslint/lib/linter/linter.js:1085:31)
at #flatVerifyWithoutProcessors (/.eslint-tmp/node_modules/.pnpm/eslint@9.39.5_jiti@1.21.7_supports-color@7.2.0/node_modules/eslint/lib/linter/linter.js:2115:4)
at Linter._verifyWithFlatConfigArrayAndWithoutProcessors (/.eslint-tmp/node_modules/.pnpm/eslint@9.39.5_jiti@1.21.7_supports-color@7.2.0/node_modules/eslint/lib/linter/linter.js:2203:43)

test/renderer/utils/resumeCommand.test.ts

ESLint skipped: the matched ESLint configuration already failed (plugin-compatibility).


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/renderer/utils/resumeCommand.test.ts (1)

3-3: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the @renderer alias for this import.

Reaching into src via ../../../ makes the test brittle and sidesteps the repo's import convention. @renderer/utils/resumeCommand keeps this as a direct file import without coupling the test to directory depth.

Suggested change
-import { buildResumeCommand } from '../../../src/renderer/utils/resumeCommand';
+import { buildResumeCommand } from '`@renderer/utils/resumeCommand`';

As per coding guidelines, "Use path aliases for imports" and "Renderer utils, hooks, and types should NOT use barrel exports - import directly from specific files."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/renderer/utils/resumeCommand.test.ts` at line 3, The test import is
using a brittle relative path instead of the repo’s renderer alias. Update the
import in resumeCommand.test.ts to use `@renderer/utils/resumeCommand` directly,
matching the import convention for renderer utils and avoiding coupling the test
to directory depth.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/renderer/utils/resumeCommand.ts`:
- Around line 10-15: The buildResumeCommand helper is inserting both cwd and
sessionId directly into a shell command, which can break on special characters
and allow shell expansion; update buildResumeCommand to use POSIX-safe single
quoting for both arguments before assembling the resume command. Keep the
existing command structure, but ensure the quoted cwd is used in the cd step and
the quoted sessionId is passed to claude --resume.

---

Nitpick comments:
In `@test/renderer/utils/resumeCommand.test.ts`:
- Line 3: The test import is using a brittle relative path instead of the repo’s
renderer alias. Update the import in resumeCommand.test.ts to use
`@renderer/utils/resumeCommand` directly, matching the import convention for
renderer utils and avoiding coupling the test to directory depth.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7c366c4f-1b22-4afa-bcb4-759aaf8efd79

📥 Commits

Reviewing files that changed from the base of the PR and between 16cc3c8 and ba707a8.

📒 Files selected for processing (3)
  • src/renderer/components/sidebar/SessionContextMenu.tsx
  • src/renderer/utils/resumeCommand.ts
  • test/renderer/utils/resumeCommand.test.ts

Comment thread src/renderer/utils/resumeCommand.ts Outdated
Signed-off-by: 1fanwang <1fannnw@gmail.com>
@1fanwang 1fanwang changed the title feat(sidebar): include the session directory in the copied resume command feat(sidebar): copy resume command with session directory Sep 3, 2026
@coderabbitai coderabbitai Bot added the bug Something isn't working label Sep 3, 2026

This branch has not been deployed

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

Labels

bug Something isn't working feature request New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant