File tree Expand file tree Collapse file tree 3 files changed +36
-3
lines changed
Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ const widgetRegistry = new Map<WidgetItemType, Widget>([
2626 [ 'terminal-width' , new widgets . TerminalWidthWidget ( ) ] ,
2727 [ 'version' , new widgets . VersionWidget ( ) ] ,
2828 [ 'custom-text' , new widgets . CustomTextWidget ( ) ] ,
29- [ 'custom-command' , new widgets . CustomCommandWidget ( ) ]
29+ [ 'custom-command' , new widgets . CustomCommandWidget ( ) ] ,
30+ [ 'claude-session-id' , new widgets . ClaudeSessionIdWidget ( ) ]
3031] ) ;
3132
3233export function getWidget ( type : WidgetItemType ) : Widget | null {
@@ -51,4 +52,4 @@ export function isKnownWidgetType(type: string): boolean {
5152 return widgetRegistry . has ( type )
5253 || type === 'separator'
5354 || type === 'flex-separator' ;
54- }
55+ }
Original file line number Diff line number Diff line change 1+ import type { RenderContext } from '../types/RenderContext' ;
2+ import type { Settings } from '../types/Settings' ;
3+ import type {
4+ Widget ,
5+ WidgetEditorDisplay ,
6+ WidgetItem
7+ } from '../types/Widget' ;
8+
9+ export class ClaudeSessionIdWidget implements Widget {
10+ getDefaultColor ( ) : string { return 'cyan' ; }
11+ getDescription ( ) : string { return 'Shows the current Claude Code session ID reported in status JSON' ; }
12+ getDisplayName ( ) : string { return 'Claude Session ID' ; }
13+ getEditorDisplay ( item : WidgetItem ) : WidgetEditorDisplay {
14+ return { displayText : this . getDisplayName ( ) } ;
15+ }
16+
17+ render ( item : WidgetItem , context : RenderContext , settings : Settings ) : string | null {
18+ if ( context . isPreview ) {
19+ return item . rawValue ? 'preview-session-id' : 'Session ID: preview-session-id' ;
20+ } else {
21+ const sessionId = context . data ?. session_id ;
22+ if ( ! sessionId ) {
23+ return null ;
24+ }
25+ return item . rawValue ? sessionId : `Session ID: ${ sessionId } ` ;
26+ }
27+ }
28+
29+ supportsRawValue ( ) : boolean { return true ; }
30+ supportsColors ( item : WidgetItem ) : boolean { return true ; }
31+ }
Original file line number Diff line number Diff line change @@ -17,4 +17,5 @@ export { VersionWidget } from './Version';
1717export { CustomTextWidget } from './CustomText' ;
1818export { CustomCommandWidget } from './CustomCommand' ;
1919export { BlockTimerWidget } from './BlockTimer' ;
20- export { CurrentWorkingDirWidget } from './CurrentWorkingDir' ;
20+ export { CurrentWorkingDirWidget } from './CurrentWorkingDir' ;
21+ export { ClaudeSessionIdWidget } from './ClaudeSessionId' ;
You can’t perform that action at this time.
0 commit comments