diff --git a/apps/staged/src/lib/features/diff/DiffCommentsSection.svelte b/apps/staged/src/lib/features/diff/DiffCommentsSection.svelte index 0a4c64948..034cb377c 100644 --- a/apps/staged/src/lib/features/diff/DiffCommentsSection.svelte +++ b/apps/staged/src/lib/features/diff/DiffCommentsSection.svelte @@ -4,14 +4,12 @@ import Check from '@lucide/svelte/icons/check'; import ChevronRight from '@lucide/svelte/icons/chevron-right'; import Copy from '@lucide/svelte/icons/copy'; - import FileText from '@lucide/svelte/icons/file-text'; - import GitCommitVertical from '@lucide/svelte/icons/git-commit-vertical'; import MessageSquare from '@lucide/svelte/icons/message-square'; import Trash2 from '@lucide/svelte/icons/trash-2'; import Undo2 from '@lucide/svelte/icons/undo-2'; import { Button } from '$lib/components/ui/button'; import type { Comment, CommentSessionState } from '../../types'; - import Spinner from '../../shared/Spinner.svelte'; + import { getCommentSessionDisplay } from './commentSessionDisplay'; import { formatLineRange, truncateText } from './diffModalHelpers'; interface Props { @@ -61,27 +59,17 @@ warning/message icons, mirroring the stateful inline-diff buttons. --> {#if noteState !== 'idle'} - - {#if noteState === 'running'} - - {:else} - - {/if} + {@const noteDisplay = getCommentSessionDisplay('note', noteState, 'badge')} + {@const NoteIcon = noteDisplay.icon} + + {/if} {#if commitState !== 'idle'} - - {#if commitState === 'running'} - - {:else} - - {/if} + {@const commitDisplay = getCommentSessionDisplay('commit', commitState, 'badge')} + {@const CommitIcon = commitDisplay.icon} + + {/if} diff --git a/apps/staged/src/lib/features/diff/DiffModal.svelte b/apps/staged/src/lib/features/diff/DiffModal.svelte index 6951d57b7..2c2cdec5c 100644 --- a/apps/staged/src/lib/features/diff/DiffModal.svelte +++ b/apps/staged/src/lib/features/diff/DiffModal.svelte @@ -49,6 +49,7 @@ BranchSessionLaunchStatus, Comment, CommentActionContext, + CommentSessionState, CommitTimelineItem, SessionStatus, SmartDiffAnnotation, @@ -517,10 +518,10 @@ } function handleNewNote(comment: Comment, event: MouseEvent) { - // Route by the linked note session's state (idle → start, running → open - // session, completed → open note). + // Route by the linked note session's state (idle → start, queued/running → + // open session, completed → open note). const state = getCommentNoteState(comment); - if (state === 'running' && comment.noteSessionId) { + if ((state === 'queued' || state === 'running') && comment.noteSessionId) { openSessionId = comment.noteSessionId; return; } @@ -539,10 +540,10 @@ } function handleNewCommit(comment: Comment, event: MouseEvent) { - // Route by the linked commit session's state (idle → start, running → open - // session, completed → show the commit in the open diff viewer). + // Route by the linked commit session's state (idle → start, queued/running → + // open session, completed → show the commit in the open diff viewer). const state = getCommentCommitState(comment); - if (state === 'running' && comment.commitSessionId) { + if ((state === 'queued' || state === 'running') && comment.commitSessionId) { openSessionId = comment.commitSessionId; return; } @@ -699,10 +700,13 @@ } /** Map a linked session id's status to the Note/Commit button state. */ - function sessionStateFor(sessionId: string | null): 'idle' | 'running' | 'completed' { + function sessionStateFor(sessionId: string | null): CommentSessionState { if (!sessionId) return 'idle'; switch (sessionStatusById.get(sessionId)) { + // Keep `queued` distinct from `running` so the UI can show the same + // Clock icon the timeline rows use for queued sessions. case 'queued': + return 'queued'; case 'running': return 'running'; case 'completed': @@ -714,11 +718,11 @@ } } - function getCommentNoteState(comment: Comment): 'idle' | 'running' | 'completed' { + function getCommentNoteState(comment: Comment): CommentSessionState { return sessionStateFor(comment.noteSessionId); } - function getCommentCommitState(comment: Comment): 'idle' | 'running' | 'completed' { + function getCommentCommitState(comment: Comment): CommentSessionState { return sessionStateFor(comment.commitSessionId); } diff --git a/apps/staged/src/lib/features/diff/ReviewCommentActions.svelte b/apps/staged/src/lib/features/diff/ReviewCommentActions.svelte index 0f8c84058..549474d89 100644 --- a/apps/staged/src/lib/features/diff/ReviewCommentActions.svelte +++ b/apps/staged/src/lib/features/diff/ReviewCommentActions.svelte @@ -1,10 +1,9 @@