fix: link issue metadata before workspace launch (#1599)

This commit is contained in:
Jinjing
2026-05-08 14:58:13 -07:00
committed by GitHub
parent fc3b44b77f
commit cca7c83c80
3 changed files with 60 additions and 36 deletions
@@ -147,6 +147,17 @@ const WorktreeCard = React.memo(function WorktreeCard({
? issueEntry.data
: undefined
: null
const issueDisplay =
issue ??
(worktree.linkedIssue
? {
number: worktree.linkedIssue,
// Why: linked metadata is persisted immediately, but GitHub details
// arrive asynchronously. Show the durable link number instead of
// making the worktree look unlinked while the cache warms.
title: issue === null ? 'Issue details unavailable' : 'Loading issue...'
}
: null)
const isDeleting = deleteState?.isDeleting ?? false
@@ -554,12 +565,12 @@ const WorktreeCard = React.memo(function WorktreeCard({
{/* Meta section: Issue / PR Links / Comment
Layout coupling: spacing here is used to derive size estimates in
WorktreeList's estimateSize. Update that function if changing spacing. */}
{((cardProps.includes('issue') && issue) ||
{((cardProps.includes('issue') && issueDisplay) ||
(cardProps.includes('pr') && pr) ||
(cardProps.includes('comment') && worktree.comment)) && (
<div className="flex flex-col gap-[3px] mt-0.5">
{cardProps.includes('issue') && issue && (
<IssueSection issue={issue} onClick={handleEditIssue} />
{cardProps.includes('issue') && issueDisplay && (
<IssueSection issue={issueDisplay} onClick={handleEditIssue} />
)}
{cardProps.includes('pr') && pr && <PrSection pr={pr} onClick={handleEditIssue} />}
{cardProps.includes('comment') && worktree.comment && (
@@ -16,11 +16,20 @@ import type { PRInfo, IssueInfo } from '../../../../shared/types'
// ── Issue section ────────────────────────────────────────────────────
type IssueSectionProps = {
issue: IssueInfo
issue:
| IssueInfo
| {
number: number
title: string
state?: IssueInfo['state']
url?: string
labels?: string[]
}
onClick: (e: React.MouseEvent) => void
}
export function IssueSection({ issue, onClick }: IssueSectionProps): React.JSX.Element {
const labels = issue.labels ?? []
return (
<HoverCard openDelay={300}>
<HoverCardTrigger asChild>
@@ -41,26 +50,30 @@ export function IssueSection({ issue, onClick }: IssueSectionProps): React.JSX.E
<div className="font-semibold text-[13px]">
#{issue.number} {issue.title}
</div>
<div className="text-muted-foreground">
State: {issue.state === 'open' ? 'Open' : 'Closed'}
</div>
{issue.labels.length > 0 && (
{issue.state && (
<div className="text-muted-foreground">
State: {issue.state === 'open' ? 'Open' : 'Closed'}
</div>
)}
{labels.length > 0 && (
<div className="flex flex-wrap gap-1">
{issue.labels.map((l) => (
{labels.map((l) => (
<Badge key={l} variant="outline" className="h-4 px-1.5 text-[9px]">
{l}
</Badge>
))}
</div>
)}
<a
href={issue.url}
target="_blank"
rel="noreferrer"
className="text-muted-foreground underline underline-offset-2 hover:text-foreground"
>
View on GitHub
</a>
{issue.url && (
<a
href={issue.url}
target="_blank"
rel="noreferrer"
className="text-muted-foreground underline underline-offset-2 hover:text-foreground"
>
View on GitHub
</a>
)}
</HoverCardContent>
</HoverCard>
)
+19 -19
View File
@@ -223,6 +223,25 @@ export async function launchWorkItemDirect(args: LaunchWorkItemDirectArgs): Prom
)
worktreeId = result.worktree.id
const worktreePath = result.worktree.path
const meta: {
linkedIssue?: number
linkedPR?: number
linkedLinearIssue?: string
} = {}
if (item.type === 'issue' && item.number) {
meta.linkedIssue = item.number
} else if (item.type === 'pr' && item.number) {
meta.linkedPR = item.number
}
if (item.linearIdentifier) {
meta.linkedLinearIssue = item.linearIdentifier
}
if (Object.keys(meta).length > 0) {
// Why: the Project direct-launch path activates the new workspace
// immediately. Persist the link first so the first sidebar render can
// show the issue/PR association instead of briefly looking unlinked.
await store.updateWorktreeMeta(worktreeId, meta)
}
const detectedIds = new Set(await detectedAgentsPromise)
effectiveAgent = pickAgent(settings?.defaultTuiAgent, detectedIds)
@@ -301,25 +320,6 @@ export async function launchWorkItemDirect(args: LaunchWorkItemDirectArgs): Prom
return
}
const meta: {
linkedIssue?: number
linkedPR?: number
linkedLinearIssue?: string
} = {}
if (item.type === 'issue' && item.number) {
meta.linkedIssue = item.number
} else if (item.type === 'pr' && item.number) {
meta.linkedPR = item.number
}
if (item.linearIdentifier) {
meta.linkedLinearIssue = item.linearIdentifier
}
if (Object.keys(meta).length > 0) {
void store.updateWorktreeMeta(worktreeId, meta).catch(() => {
// Meta update is non-critical for the draft flow — continue.
})
}
store.setSidebarOpen(true)
if (settings?.rightSidebarOpenByDefault) {
store.setRightSidebarTab('explorer')