Skip to content

Set active workspace as default terminal cwd#8195

Open
maxicda wants to merge 1 commit into
usebruno:mainfrom
maxicda:terminal-default-workspace-cwd
Open

Set active workspace as default terminal cwd#8195
maxicda wants to merge 1 commit into
usebruno:mainfrom
maxicda:terminal-default-workspace-cwd

Conversation

@maxicda

@maxicda maxicda commented Jun 7, 2026

Copy link
Copy Markdown

This PR updates the Terminal tab so new sessions created with the + button start in the active workspace directory by default. Contextual Open in Terminal actions still pass their explicit cwd.
Tested manually by creating a new terminal session and verifying pwd points to the active workspace.

Summary by CodeRabbit

  • Bug Fixes
    • Terminal sessions now default to the active workspace directory when opened, ensuring commands run in the correct project context.
    • New terminals omit an empty working-directory setting when none is available, preventing unintended path behavior.
    • Terminal creation now responds to workspace changes so newly opened sessions reflect the current workspace.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 53c4f5a9-e426-43c8-8eb3-d9a81be9c579

📥 Commits

Reviewing files that changed from the base of the PR and between 59daa4c and d733129.

📒 Files selected for processing (1)
  • packages/bruno-app/src/components/Devtools/Console/TerminalTab/index.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/bruno-app/src/components/Devtools/Console/TerminalTab/index.js

Walkthrough

TerminalTab reads the active workspace pathname from Redux and uses it as the default cwd when creating new terminal sessions; createNewSession now resolves cwd with that fallback and its callback dependencies include activeWorkspacePathname.

Changes

Terminal working directory initialization

Layer / File(s) Summary
Workspace pathname to terminal working directory
packages/bruno-app/src/components/Devtools/Console/TerminalTab/index.js
Imports useSelector, derives activeWorkspacePathname from state.workspaces/activeWorkspaceUid, resolves `resolvedCwd = cwd

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • usebruno/bruno#6467: Both change how terminal sessions choose cwd; that PR adds an “Open in Terminal” action passing workspace pathname.
  • usebruno/bruno#7877: Adds workspace-level "Open in Terminal" action that relies on terminal session creation scoped to the workspace path.

Suggested reviewers

  • helloanoop
  • lohit-bruno

Poem

A terminal wakes, the path is known,
Redux hums and seeds its own—
New sessions start with proper ground,
cwd finds home where workspaces bound. 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: setting the active workspace as the default terminal working directory.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 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 `@packages/bruno-app/src/components/Devtools/Console/TerminalTab/index.js`:
- Around line 222-226: The selector assigned to activeWorkspacePathname assumes
state.workspaces is present and can throw; update the useSelector callback to
defensively guard when state.workspaces is undefined (e.g., return null early or
default to an empty object) before destructuring workspaces and
activeWorkspaceUid so the lookup (workspaces?.find(...)) never runs on
undefined; reference the activeWorkspacePathname constant, the useSelector
callback, and the state.workspaces / workspaces / activeWorkspaceUid fields when
making this change.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 014f3a1b-1cda-4301-b3a3-31e4d48c9c30

📥 Commits

Reviewing files that changed from the base of the PR and between 913214e and 59daa4c.

📒 Files selected for processing (1)
  • packages/bruno-app/src/components/Devtools/Console/TerminalTab/index.js

@maxicda maxicda force-pushed the terminal-default-workspace-cwd branch from 59daa4c to d733129 Compare June 8, 2026 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant