@@ -6,81 +6,82 @@ import {
66 renderSessionAttentionIcon ,
77 renderSessionState ,
88} from "./session-attention-presentation.ts" ;
9+ import {
10+ renderSessionGlyph ,
11+ renderSessionUnreadBadge ,
12+ type SessionGlyphContent ,
13+ } from "./session-glyph.ts" ;
914import { resolveSessionIcon } from "./session-icon-registry.ts" ;
1015import type { SessionPullRequestIndicatorState } from "./session-menu-work.ts" ;
1116import { renderSessionOwnerChip , type SessionCreatedActor } from "./session-owner-chip.ts" ;
1217
18+ function renderGlyphBadge (
19+ session : SidebarRecentSession ,
20+ pullRequestState : SessionPullRequestIndicatorState ,
21+ ) : SessionGlyphContent {
22+ if ( session . unread ) {
23+ return renderSessionUnreadBadge ( ) ;
24+ }
25+ if ( pullRequestState === "none" ) {
26+ return nothing ;
27+ }
28+ const label =
29+ pullRequestState === "open" ? t ( "sessionsView.openPullRequest" ) : t ( "chat.pullRequests.merged" ) ;
30+ return html `< span
31+ class ="session-glyph__badge sidebar-session-pr-indicator-- ${ pullRequestState } "
32+ data-session-pr-state =${ pullRequestState }
33+ role ="img"
34+ aria-label=${ label }
35+ title=${ label }
36+ > </ span > ` ;
37+ }
38+
1339export function renderSessionLeadingState (
1440 session : SidebarRecentSession ,
1541 pullRequestState : SessionPullRequestIndicatorState ,
1642 ownerActor : SessionCreatedActor | null | undefined ,
1743 attribution : "created" | "archived" ,
1844) {
1945 const running = session . hasActiveRun || session . status === "running" ;
20- const sessionState = renderSessionState ( session ) ;
21- // Pinned rows keep their custom icon in the fixed leading slot and place
22- // transient run/unread/terminal state at the row edge.
23- const pinnedState =
24- session . pinned && sessionState !== nothing
25- ? html `< span class ="nav-item__state "> ${ sessionState } </ span > `
26- : nothing ;
2746
2847 if ( session . attention . kind !== "none" ) {
2948 return {
3049 running,
31- pinnedState,
32- leadingIndicator : renderSessionAttentionIcon ( session . attention ) ,
50+ leadingIndicator : renderSessionGlyph ( {
51+ content : renderSessionAttentionIcon ( session . attention ) ,
52+ running,
53+ // Attention does not replace unread: a row waiting on the user can also
54+ // hold output the user has not seen.
55+ badge : renderGlyphBadge ( session , pullRequestState ) ,
56+ } ) ,
3357 } ;
3458 }
3559 if ( session . pinned ) {
3660 return {
3761 running,
38- pinnedState,
39- leadingIndicator : html `< span class ="sidebar-pinned-session__icon " aria-hidden ="true "
40- > ${ resolveSessionIcon ( session . icon ) } </ span
41- > ` ,
62+ leadingIndicator : renderSessionGlyph ( {
63+ content : html `< span class ="sidebar-pinned-session__icon " aria-hidden ="true "
64+ > ${ resolveSessionIcon ( session . icon ) } </ span
65+ > ` ,
66+ running,
67+ badge : renderGlyphBadge ( session , pullRequestState ) ,
68+ } ) ,
4269 } ;
4370 }
4471 if ( ! session . isChild && ownerActor ?. id ?. trim ( ) ) {
45- const label =
46- pullRequestState === "open"
47- ? t ( "sessionsView.openPullRequest" )
48- : t ( "chat.pullRequests.merged" ) ;
4972 return {
5073 running,
51- pinnedState,
52- leadingIndicator : html `< span
53- class ="sidebar-session-avatar ${ running ? "sidebar-session-avatar--running" : "" } "
54- >
55- ${ renderSessionOwnerChip ( ownerActor , "row" , attribution ) }
56- ${ running
57- ? html `< span
58- class ="sidebar-session-avatar__running-ring "
59- role ="img "
60- aria-label =${ t ( "sessionsView.activeRun" ) }
61- title =${ t ( "sessionsView.activeRun" ) }
62- > </ span > `
63- : nothing }
64- ${ session . unread
65- ? html `< span
66- class ="sidebar-session-avatar__badge sidebar-session-avatar__badge--unread "
67- role ="img "
68- aria-label =${ t ( "sessionsView.unread" ) }
69- > </ span > `
70- : pullRequestState !== "none"
71- ? html `< span
72- class ="sidebar-session-avatar__badge sidebar-session-pr-indicator-- ${ pullRequestState } "
73- data-session-pr-state =${ pullRequestState }
74- role ="img"
75- aria-label=${ label }
76- title=${ label }
77- > </ span > `
78- : nothing }
79- </ span > ` ,
74+ leadingIndicator : renderSessionGlyph ( {
75+ content : renderSessionOwnerChip ( ownerActor , "row" , attribution ) ,
76+ running,
77+ circular : true ,
78+ badge : renderGlyphBadge ( session , pullRequestState ) ,
79+ } ) ,
8080 } ;
8181 }
82+ // No artwork to ring: the bare spinner already sits in the leading slot.
8283 if ( running ) {
83- return { running, pinnedState , leadingIndicator : sessionState } ;
84+ return { running, leadingIndicator : renderSessionState ( session ) } ;
8485 }
8586 if ( pullRequestState !== "none" ) {
8687 const label =
@@ -89,7 +90,6 @@ export function renderSessionLeadingState(
8990 : t ( "chat.pullRequests.merged" ) ;
9091 return {
9192 running,
92- pinnedState,
9393 leadingIndicator : html `< span
9494 class ="sidebar-session-pr-indicator sidebar-session-pr-indicator-- ${ pullRequestState } "
9595 data-session-pr-state =${ pullRequestState }
@@ -100,9 +100,9 @@ export function renderSessionLeadingState(
100100 > ` ,
101101 } ;
102102 }
103+ const sessionState = renderSessionState ( session ) ;
103104 return {
104105 running,
105- pinnedState,
106106 leadingIndicator :
107107 sessionState !== nothing
108108 ? sessionState
0 commit comments