Hide Jump to Worktree for sessions in the current worktree (#6791)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Brennan Benson
2026-06-29 16:03:24 -07:00
committed by GitHub
co-authored by Orca
parent ab1aac2bda
commit 08e824dda9
5 changed files with 60 additions and 20 deletions
@@ -43,6 +43,7 @@ export function VaultSessionRow({
resumeDisabled,
onToggleDetails,
onJumpToOriginalPane,
showJumpToWorktree,
onJumpToWorktree,
onResume,
resumeLabel,
@@ -63,6 +64,7 @@ export function VaultSessionRow({
resumeDisabled: boolean
onToggleDetails: () => void
onJumpToOriginalPane?: () => void
showJumpToWorktree: boolean
onJumpToWorktree?: () => void
onResume: () => void
resumeLabel: string
@@ -146,6 +148,7 @@ export function VaultSessionRow({
worktreeInfo={worktreeInfo}
onToggleDetails={onToggleDetails}
onJumpToOriginalPane={onJumpToOriginalPane}
showJumpToWorktree={showJumpToWorktree}
onJumpToWorktree={onJumpToWorktree}
onResume={onResume}
onCopyResume={onCopyResume}
@@ -204,6 +207,7 @@ export function VaultSessionRow({
resumeDisabled={resumeDisabled}
resumeLabel={resumeLabel}
onJumpToOriginalPane={onJumpToOriginalPane}
showJumpToWorktree={showJumpToWorktree}
onJumpToWorktree={onJumpToWorktree}
onResume={onResume}
onCopyResume={onCopyResume}
@@ -224,6 +228,7 @@ export function SessionActionMenuItems({
resumeLabel,
onResume,
onJumpToOriginalPane,
showJumpToWorktree,
onJumpToWorktree,
onCopyResume,
onCopyId,
@@ -237,6 +242,7 @@ export function SessionActionMenuItems({
resumeLabel: string
onResume: () => void
onJumpToOriginalPane?: () => void
showJumpToWorktree: boolean
onJumpToWorktree?: () => void
onCopyResume: () => void
onCopyId: () => void
@@ -259,13 +265,15 @@ export function SessionActionMenuItems({
)}
</Item>
) : null}
<Item disabled={!onJumpToWorktree} onSelect={onJumpToWorktree}>
<PanelTopOpen className="size-3.5" />
{translate(
'auto.components.right.sidebar.AiVaultSessionRow.jumpToWorktree',
'Jump to Worktree'
)}
</Item>
{showJumpToWorktree ? (
<Item disabled={!onJumpToWorktree} onSelect={onJumpToWorktree}>
<PanelTopOpen className="size-3.5" />
{translate(
'auto.components.right.sidebar.AiVaultSessionRow.jumpToWorktree',
'Jump to Worktree'
)}
</Item>
) : null}
<Item disabled={resumeDisabled} onSelect={onResume}>
<Play className="size-3.5" />
{resumeLabel}
@@ -16,6 +16,7 @@ import {
} from './ai-vault-session-resume'
import {
canJumpToAiVaultSessionWorktree,
isAiVaultSessionInCurrentWorktree,
type AiVaultSessionWorktreeInfo
} from './ai-vault-session-worktree'
import {
@@ -263,9 +264,14 @@ function AiVaultVirtualRow({
const isActiveStickyHeader = row.type === 'group' && activeStickyHeaderIndex === index
const originalPaneTarget = row.type === 'session' ? getOriginalPaneTarget(row.session) : null
const worktreeInfo = row.type === 'session' ? getWorktreeInfo(row.session) : null
const worktreeJumpId = canJumpToAiVaultSessionWorktree(worktreeInfo)
? worktreeInfo?.worktreeId
: null
// Why: omit the jump affordance when the session already lives in the
// worktree on screen — jumping there is a no-op the "Current worktree" badge
// already conveys.
const showJumpToWorktree = !isAiVaultSessionInCurrentWorktree(worktreeInfo)
const worktreeJumpId =
showJumpToWorktree && canJumpToAiVaultSessionWorktree(worktreeInfo)
? worktreeInfo?.worktreeId
: null
const resumeState = row.type === 'session' ? getSessionResumeState(row.session) : null
const resumeActions = row.type === 'session' ? getSessionResumeActions(row.session) : null
const resumeLabel = resumeState ? aiVaultSessionResumeLabel(resumeState) : ''
@@ -304,6 +310,7 @@ function AiVaultVirtualRow({
onJumpToOriginalPane={
originalPaneTarget ? () => onJumpToOriginalPane(row.session) : undefined
}
showJumpToWorktree={showJumpToWorktree}
onJumpToWorktree={worktreeJumpId ? () => onJumpToWorktree(worktreeJumpId) : undefined}
onResume={() => {
if (resumeState?.worktreeId) {
@@ -42,6 +42,7 @@ export function SessionRowTrailingActions({
worktreeInfo,
onToggleDetails,
onJumpToOriginalPane,
showJumpToWorktree,
onJumpToWorktree,
onResume,
onCopyResume,
@@ -60,6 +61,7 @@ export function SessionRowTrailingActions({
worktreeInfo: AiVaultSessionWorktreeInfo | null
onToggleDetails: () => void
onJumpToOriginalPane?: () => void
showJumpToWorktree: boolean
onJumpToWorktree?: () => void
onResume: () => void
onCopyResume: () => void
@@ -109,16 +111,18 @@ export function SessionRowTrailingActions({
</TooltipContent>
</Tooltip>
) : null}
<Tooltip>
<WorktreeJumpTooltipTrigger
disabled={!onJumpToWorktree}
ariaLabel={jumpToWorktreeTooltip}
onJumpToWorktree={onJumpToWorktree}
/>
<TooltipContent side="top" sideOffset={4}>
{jumpToWorktreeTooltip}
</TooltipContent>
</Tooltip>
{showJumpToWorktree ? (
<Tooltip>
<WorktreeJumpTooltipTrigger
disabled={!onJumpToWorktree}
ariaLabel={jumpToWorktreeTooltip}
onJumpToWorktree={onJumpToWorktree}
/>
<TooltipContent side="top" sideOffset={4}>
{jumpToWorktreeTooltip}
</TooltipContent>
</Tooltip>
) : null}
<Tooltip>
<TooltipTrigger asChild>
<Button
@@ -208,6 +212,7 @@ export function SessionRowTrailingActions({
resumeLabel={resumeLabel}
onResume={onResume}
onJumpToOriginalPane={onJumpToOriginalPane}
showJumpToWorktree={showJumpToWorktree}
onJumpToWorktree={onJumpToWorktree}
onCopyResume={onCopyResume}
onCopyId={onCopyId}
@@ -5,6 +5,7 @@ import {
aiVaultWorktreeCompactPath,
aiVaultWorktreeJumpTooltip,
canJumpToAiVaultSessionWorktree,
isAiVaultSessionInCurrentWorktree,
extractWorktreePathFromSessionTitle,
resolveAiVaultSessionWorktreeDisplay,
resolveAiVaultSessionWorktreeInfo,
@@ -149,6 +150,16 @@ describe('canJumpToAiVaultSessionWorktree', () => {
})
})
describe('isAiVaultSessionInCurrentWorktree', () => {
it('flags only the worktree the user is already viewing', () => {
expect(isAiVaultSessionInCurrentWorktree(makeWorktreeInfo('current'))).toBe(true)
expect(isAiVaultSessionInCurrentWorktree(makeWorktreeInfo('active'))).toBe(false)
expect(isAiVaultSessionInCurrentWorktree(makeWorktreeInfo('archived'))).toBe(false)
expect(isAiVaultSessionInCurrentWorktree(makeWorktreeInfo('unavailable'))).toBe(false)
expect(isAiVaultSessionInCurrentWorktree(null)).toBe(false)
})
})
describe('extractWorktreePathFromSessionTitle', () => {
it('reads worktree paths embedded in session titles', () => {
expect(
@@ -150,6 +150,15 @@ export function canJumpToAiVaultSessionWorktree(
)
}
// Why: a session in the worktree you're already viewing has nowhere to jump,
// so we hide the affordance rather than offering a self-jump (the "Current
// worktree" badge already signals where it lives).
export function isAiVaultSessionInCurrentWorktree(
worktreeInfo: AiVaultSessionWorktreeInfo | null
): boolean {
return worktreeInfo?.status === 'current'
}
export function aiVaultWorktreeJumpTooltip(
worktreeInfo: AiVaultSessionWorktreeInfo | null
): string {