diff --git a/apps/staged/src/lib/features/branches/BranchCard.svelte b/apps/staged/src/lib/features/branches/BranchCard.svelte index 246be108..15c5aa40 100644 --- a/apps/staged/src/lib/features/branches/BranchCard.svelte +++ b/apps/staged/src/lib/features/branches/BranchCard.svelte @@ -160,7 +160,7 @@ let commitDiffSha = $state(null); // Note modal (opened by clicking a note in the timeline) - let openNote = $state<{ title: string; content: string } | null>(null); + let openNote = $state<{ title: string; content: string; sessionId?: string } | null>(null); // Image viewer modal (opened by clicking an image in the timeline) let viewImageId = $state(null); @@ -351,12 +351,21 @@ // Timeline item interactions // ========================================================================= + /** Look up note info from timeline data by session ID (for cross-modal navigation). */ + function findNoteForSession( + sessionId: string + ): { id: string; title: string; content: string } | null { + const note = timeline?.notes.find((n) => n.sessionId === sessionId && n.content?.trim()); + if (!note) return null; + return { id: note.id, title: note.title, content: note.content }; + } + function handleCommitClick(sha: string) { commitDiffSha = sha; } - function handleNoteClick(_noteId: string, title: string, content: string) { - openNote = { title, content }; + function handleNoteClick(_noteId: string, title: string, content: string, sessionId?: string) { + openNote = { title, content, sessionId }; } async function handleReviewClick(reviewId: string) { @@ -803,7 +812,16 @@ {/if} {#if openNote} - (openNote = null)} /> + (openNote = null)} + onOpenSession={(sid) => { + openNote = null; + sessionMgr.openSessionId = sid; + }} + /> {/if} {#if viewImageId} @@ -847,6 +865,12 @@ repoDir={branch.worktreePath} branchId={branch.id} projectId={branch.projectId} + noteInfo={findNoteForSession(sessionMgr.openSessionId)} + onOpenNote={(noteId, title, content) => { + const sid = sessionMgr.openSessionId; + sessionMgr.openSessionId = null; + openNote = { title, content, sessionId: sid ?? undefined }; + }} onClose={async () => { const closedSessionId = sessionMgr.openSessionId; sessionMgr.openSessionId = null; diff --git a/apps/staged/src/lib/features/notes/NoteModal.svelte b/apps/staged/src/lib/features/notes/NoteModal.svelte index 9a1dffdf..b48845c3 100644 --- a/apps/staged/src/lib/features/notes/NoteModal.svelte +++ b/apps/staged/src/lib/features/notes/NoteModal.svelte @@ -21,9 +21,12 @@ title: string; content: string; onClose: () => void; + /** When set, shows a button to open the associated chat session. */ + sessionId?: string | null; + onOpenSession?: (sessionId: string) => void; } - let { title, content, onClose }: Props = $props(); + let { title, content, onClose, sessionId, onOpenSession }: Props = $props(); let copied = $state(false); const backdropDismiss = createBackdropDismissHandlers({ onDismiss: () => onClose() }); @@ -163,7 +166,9 @@