Skip to content

fix(desktop): fallback to worktree branch name in notifications#198

Merged
Kitenite merged 1 commit intomainfrom
silver-thunder-89
Dec 1, 2025
Merged

fix(desktop): fallback to worktree branch name in notifications#198
Kitenite merged 1 commit intomainfrom
silver-thunder-89

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Dec 1, 2025

When workspace name is not set, notifications now fall back to the worktree's branch name instead of a generic "Workspace" label.

🤖 Generated with Claude Code

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved terminal workspace naming resolution to better identify workspace context in terminal sessions.

✏️ Tip: You can customize this high-level summary in your review settings.

When workspace name is not set, notifications now fall back to the
worktree's branch name instead of a generic "Workspace" label.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
website Ready Ready Preview Comment Dec 1, 2025 1:23am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 1, 2025

Walkthrough

The createOrAttach function in the terminal router now uses a three-level fallback mechanism to resolve workspaceName: first checking workspace.name, then looking up and using worktree.branch via workspace.worktreeId, and finally defaulting to "Workspace" if neither is available.

Changes

Cohort / File(s) Summary
Terminal Router Workspace Name Resolution
apps/desktop/src/lib/trpc/routers/terminal/terminal.ts
Modified createOrAttach to implement fallback chain for workspaceName: uses workspace.name if available, otherwise fetches worktree and uses its branch, falling back to "Workspace" if both unavailable.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Focus on the worktree lookup logic and its integration into the workspace name resolution chain
  • Verify that the worktree fetch is efficient and handles cases where workspace.worktreeId may not exist

Poem

🐰 A workspace name blooms in layers deep,
First workspace.name we try to keep,
Then worktree.branch we fetch with care,
Or "Workspace" waits—a fallback spare!
Three levels of naming, oh what a treat,
Our terminal setup is now complete! 🌿

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description provides a clear summary of changes but leaves most template sections empty (Related Issues, Type of Change, Testing, etc.) without filling them out. Complete the template by selecting the appropriate Type of Change (likely 'Bug fix'), linking related issues if applicable, and describing testing performed to verify the worktree branch fallback behavior.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: implementing a fallback to worktree branch name in notifications when workspace name is unavailable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch silver-thunder-89

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c486937 and 8e26e79.

📒 Files selected for processing (1)
  • apps/desktop/src/lib/trpc/routers/terminal/terminal.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
apps/desktop/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc

Files:

  • apps/desktop/src/lib/trpc/routers/terminal/terminal.ts
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: Please use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary

Files:

  • apps/desktop/src/lib/trpc/routers/terminal/terminal.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Avoid using any type - use explicit types instead for type safety
Use camelCase for variable and function names following existing codebase patterns
Keep diffs minimal with targeted edits only - avoid unnecessary changes when making modifications
Follow existing patterns and match the codebase style when writing new code

Files:

  • apps/desktop/src/lib/trpc/routers/terminal/terminal.ts
apps/desktop/src/lib/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

Never import Node.js modules in shared code like src/lib/electron-router-dom.ts - this code runs in both main and renderer processes

Files:

  • apps/desktop/src/lib/trpc/routers/terminal/terminal.ts
🧬 Code graph analysis (1)
apps/desktop/src/lib/trpc/routers/terminal/terminal.ts (1)
apps/desktop/src/main/lib/db/index.ts (1)
  • db (18-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (1)
apps/desktop/src/lib/trpc/routers/terminal/terminal.ts (1)

50-54: Fallback chain for workspaceName looks correct; confirm empty‑string behavior is desired

Using workspace?.name || worktree?.branch || "Workspace" gives you the intended priority: explicit workspace name, then worktree branch, then the generic label. The guarded worktree lookup is safe and consistent with how getWorkspaceCwd resolves worktrees below.

Note that || treats empty strings as “not set”, so a workspace with name === "" will also fall back to the branch (and an empty branch would fall back to "Workspace"). If that’s intentional for your “not set” semantics, this change is spot on; if you ever need to distinguish empty from undefined, you might switch to ?? instead.


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.

@Kitenite Kitenite merged commit 3957e8c into main Dec 1, 2025
7 checks passed
@Kitenite Kitenite deleted the silver-thunder-89 branch December 1, 2025 19:26
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.

1 participant