11import type { ProgressCard } from "@openclaw/gateway-protocol" ;
22import { bucketRelativeTimeMs , type RelativeTimeUnit } from "@openclaw/normalization-core" ;
3- import { html , nothing } from "lit" ;
3+ import { html , nothing , type TemplateResult } from "lit" ;
44import type {
55 ControlUiSessionPullRequest ,
66 ControlUiSessionPullRequestSnapshot ,
77} from "../../../src/gateway/control-ui-contract.js" ;
8+ import { activityPersonLocation } from "../app-route-paths.ts" ;
89import { i18n , t } from "../i18n/index.ts" ;
10+ import { shouldHandleNavigationClick } from "../lib/navigation-click.ts" ;
911import type { SidebarSessionHovercardRow } from "./app-sidebar-session-types.ts" ;
1012import { icons } from "./icons.ts" ;
11- import { sessionOwnerInitials } from "./session-owner-chip.ts" ;
13+ import { sessionOwnerInitials , type SessionCreatedActor } from "./session-owner-chip.ts" ;
1214import { renderSessionProgressCard } from "./session-progress-card.ts" ;
1315import "./viewer-facepile.ts" ;
1416
1517const MAX_VISIBLE_PULL_REQUESTS = 4 ;
1618const MAX_VISIBLE_PARTICIPANTS = 3 ;
1719
20+ function participantLabel ( participant : SessionCreatedActor ) : string {
21+ return participant . label ?. trim ( ) || participant . id ?. trim ( ) || "" ;
22+ }
23+
1824type SessionAgeUnit = RelativeTimeUnit | "week" | "month" | "year" ;
1925
2026type SessionHovercardAvatarAuth = {
2127 authTokens : readonly string [ ] ;
2228 authReady : boolean ;
2329} ;
2430
31+ /** Opens the Activity feed for one identity; supplied by the hovercard host that owns routing. */
32+ export type SessionHovercardPersonActivity = {
33+ basePath : string ;
34+ navigate : ( personId : string ) => void ;
35+ } ;
36+
37+ type SessionHovercardInput = {
38+ row ?: SidebarSessionHovercardRow ;
39+ selfUserId ?: string ;
40+ avatarAuth ?: SessionHovercardAvatarAuth ;
41+ personActivity ?: SessionHovercardPersonActivity ;
42+ pullRequests ?: ControlUiSessionPullRequestSnapshot ;
43+ progressCard ?: ProgressCard | null ;
44+ } ;
45+
2546let channelAvatarElementLoad : Promise < unknown > | undefined ;
2647function ensureChannelAvatarElement ( ) : void {
2748 channelAvatarElementLoad ??= import ( "./channel-avatar.ts" ) ;
@@ -158,11 +179,80 @@ function renderHeader(row: SidebarSessionHovercardRow) {
158179 </ header > ` ;
159180}
160181
161- function renderSessionContext (
162- row : SidebarSessionHovercardRow | undefined ,
163- selfUserId ?: string ,
164- avatarAuth ?: SessionHovercardAvatarAuth ,
182+ type PersonActivityLink = { href : string ; open : ( event : MouseEvent ) => void } ;
183+
184+ function personActivityLink (
185+ personId : string ,
186+ personActivity : SessionHovercardPersonActivity | undefined ,
187+ ) : PersonActivityLink | null {
188+ if ( ! personActivity ) {
189+ return null ;
190+ }
191+ return {
192+ href : activityPersonLocation ( personId , personActivity . basePath ) . href ,
193+ open : ( event : MouseEvent ) => {
194+ if ( ! shouldHandleNavigationClick ( event ) ) {
195+ return ;
196+ }
197+ event . preventDefault ( ) ;
198+ personActivity . navigate ( personId ) ;
199+ } ,
200+ } ;
201+ }
202+
203+ function renderPersonName ( label : string , link : PersonActivityLink | null , className : string ) {
204+ return link
205+ ? html `< a
206+ class ="${ className } session-hovercard__identity-link "
207+ href =${ link . href }
208+ @click =${ link . open }
209+ > ${ label } </ a
210+ > `
211+ : html `< span class =${ className } > ${ label } </ span > ` ;
212+ }
213+
214+ /**
215+ * Keeps the locale's own "with {name}" phrasing and list separators while making each
216+ * name its own link. A translation that lost its placeholder falls back to plain text
217+ * rather than dropping the names.
218+ */
219+ function renderParticipantNames (
220+ participants : readonly SessionCreatedActor [ ] ,
221+ formattedNames : string ,
222+ personActivity : SessionHovercardPersonActivity | undefined ,
165223) {
224+ const [ prefix , suffix ] = t ( "sessionsView.withParticipant" ) . split ( "{name}" ) ;
225+ if ( suffix === undefined ) {
226+ return t ( "sessionsView.withParticipant" , { name : formattedNames } ) ;
227+ }
228+ const links = participants . map ( ( participant ) =>
229+ participant . id ? personActivityLink ( participant . id , personActivity ) : null ,
230+ ) ;
231+ const parts = new Intl . ListFormat ( i18n . getLocale ( ) , {
232+ style : "long" ,
233+ type : "unit" ,
234+ } ) . formatToParts ( participants . map ( participantLabel ) ) ;
235+ const names : ( TemplateResult | string ) [ ] = [ ] ;
236+ let index = 0 ;
237+ for ( const part of parts ) {
238+ if ( part . type === "literal" ) {
239+ names . push ( part . value ) ;
240+ continue ;
241+ }
242+ names . push (
243+ renderPersonName ( part . value , links [ index ] ?? null , "session-hovercard__participant-name" ) ,
244+ ) ;
245+ index += 1 ;
246+ }
247+ return html `${ prefix } ${ names } ${ suffix } ` ;
248+ }
249+
250+ function renderSessionContext ( {
251+ row,
252+ selfUserId,
253+ avatarAuth,
254+ personActivity,
255+ } : SessionHovercardInput ) {
166256 const creator = row ?. createdActor ;
167257 const creatorLabel = creator ?. label ?. trim ( ) || creator ?. id ?. trim ( ) ;
168258 const creatorInitials = creator ? sessionOwnerInitials ( creator ) : "" ;
@@ -187,9 +277,7 @@ function renderSessionContext(
187277 return true ;
188278 } ) ;
189279 const visibleParticipants = participants . slice ( 0 , MAX_VISIBLE_PARTICIPANTS ) ;
190- const participantNames = visibleParticipants . map (
191- ( participant ) => participant . label || participant . id || "" ,
192- ) ;
280+ const participantNames = visibleParticipants . map ( participantLabel ) ;
193281 const formattedParticipantNames = new Intl . ListFormat ( i18n . getLocale ( ) , {
194282 style : "long" ,
195283 type : "unit" ,
@@ -213,40 +301,53 @@ function renderSessionContext(
213301 if ( row ?. channelAvatarUrl ) {
214302 ensureChannelAvatarElement ( ) ;
215303 }
304+ const creatorId = creator ?. id ;
305+ const creatorActivity = creatorId ? personActivityLink ( creatorId , personActivity ) : null ;
306+ const creatorAvatar = row ?. channelAvatarUrl
307+ ? html `< openclaw-channel-avatar
308+ class ="session-hovercard__creator-avatar "
309+ .routeUrl =${ row . channelAvatarUrl }
310+ .authTokens =${ avatarAuth ?. authTokens ?? [ ] }
311+ .authReady=${ avatarAuth ?. authReady ?? false }
312+ .fallback=${ avatarFallback }
313+ aria-hidden="true"
314+ > </ openclaw-channel-avatar > `
315+ : creatorId
316+ ? html `< openclaw-viewer-avatar
317+ class ="session-hovercard__creator-avatar "
318+ .user =${ {
319+ id : creatorId ,
320+ name : creator ?. label ,
321+ avatarUrl : creator ?. avatarUrl ,
322+ watchedSessions : [ ] ,
323+ } }
324+ .markAsViewer =${ false }
325+ variant="session"
326+ aria-hidden="true"
327+ > </ openclaw-viewer-avatar > `
328+ : html `< span class ="session-hovercard__context-icon " aria-hidden ="true "
329+ > ${ icons . users } </ span
330+ > ` ;
216331 return html `< div class ="session-hovercard__context ">
217332 ${ creatorLabel || visibleParticipants . length > 0
218333 ? html `< div
219334 class ="session-hovercard__context-row session-hovercard__identity-row "
220335 aria-label =${ [ creatorLabel , participantSummary ] . filter ( Boolean ) . join ( ", " ) }
221336 >
222- ${ row ?. channelAvatarUrl
223- ? html `< openclaw-channel-avatar
224- class ="session-hovercard__creator-avatar "
225- .routeUrl =${ row . channelAvatarUrl }
226- .authTokens =${ avatarAuth ?. authTokens ?? [ ] }
227- .authReady=${ avatarAuth ?. authReady ?? false }
228- .fallback=${ avatarFallback }
337+ ${ creatorActivity
338+ ? // Decorative twin of the name link: the name below carries the accessible target.
339+ html `< a
340+ class ="session-hovercard__identity-avatar-link "
341+ href =${ creatorActivity . href }
342+ tabindex ="-1"
229343 aria-hidden="true"
230- > </ openclaw-channel-avatar > `
231- : creator ?. id
232- ? html `< openclaw-viewer-avatar
233- class ="session-hovercard__creator-avatar "
234- .user =${ {
235- id : creator . id ,
236- name : creator . label ,
237- avatarUrl : creator . avatarUrl ,
238- watchedSessions : [ ] ,
239- } }
240- .markAsViewer =${ false }
241- variant="session"
242- aria-hidden="true"
243- > </ openclaw-viewer-avatar > `
244- : html `< span class ="session-hovercard__context-icon " aria-hidden ="true "
245- > ${ icons . users } </ span
246- > ` }
344+ @click=${ creatorActivity . open }
345+ > ${ creatorAvatar } </ a
346+ > `
347+ : creatorAvatar }
247348 < span class ="session-hovercard__identity-copy ">
248349 ${ creatorLabel
249- ? html ` < span class = "session-hovercard__identity-name "> ${ creatorLabel } </ span > `
350+ ? renderPersonName ( creatorLabel , creatorActivity , "session-hovercard__identity-name" )
250351 : nothing }
251352 ${ creatorLabel && visibleParticipants . length > 0
252353 ? html `< span class ="session-hovercard__identity-separator " aria-hidden ="true "
@@ -256,9 +357,11 @@ function renderSessionContext(
256357 ${ visibleParticipants . length > 0
257358 ? html `< span class ="session-hovercard__participants ">
258359 < span class ="session-hovercard__participant "
259- > ${ t ( "sessionsView.withParticipant" , {
260- name : formattedParticipantNames ,
261- } ) } </ span
360+ > ${ renderParticipantNames (
361+ visibleParticipants ,
362+ formattedParticipantNames ,
363+ personActivity ,
364+ ) } </ span
262365 >
263366 ${ hiddenParticipantCount > 0
264367 ? html `< span class ="session-hovercard__participants-more "
@@ -386,13 +489,7 @@ function renderPullRequestDetails(snapshot: ControlUiSessionPullRequestSnapshot
386489 ` ;
387490}
388491
389- export function renderSessionHovercard ( input : {
390- row ?: SidebarSessionHovercardRow ;
391- selfUserId ?: string ;
392- avatarAuth ?: SessionHovercardAvatarAuth ;
393- pullRequests ?: ControlUiSessionPullRequestSnapshot ;
394- progressCard ?: ProgressCard | null ;
395- } ) {
492+ export function renderSessionHovercard ( input : SessionHovercardInput ) {
396493 const hasPullRequestDetails = Boolean (
397494 input . pullRequests && ( input . pullRequests . pullRequests . length > 0 || input . pullRequests . branch ) ,
398495 ) ;
@@ -421,7 +518,7 @@ export function renderSessionHovercard(input: {
421518 : nothing }
422519 ${ hasContext
423520 ? html `< section class ="session-hovercard__section session-hovercard__section--metadata ">
424- ${ renderSessionContext ( input . row , input . selfUserId , input . avatarAuth ) }
521+ ${ renderSessionContext ( input ) }
425522 </ section > `
426523 : nothing }
427524 ${ hasPullRequestDetails
0 commit comments