fix: clean up hook event labels in Activity panel

Replace raw SDK identifiers with human-friendly labels (e.g.
sessionStart → Session start) and drop the meaningless UUID detail.
Labels now read like 'Session start hook started' instead of
'Hook sessionStart started'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-03-28 14:06:21 +01:00
co-authored by Copilot
parent 1fbfdbbac4
commit ae56d55c85
+16 -2
View File
@@ -245,6 +245,20 @@ export interface TurnEventEntry {
export type TurnEventLog = readonly TurnEventEntry[];
export type TurnEventLogMap = Record<string, TurnEventLog | undefined>;
const hookTypeLabels: Record<string, string> = {
sessionStart: 'Session start',
sessionEnd: 'Session end',
userPromptSubmitted: 'Prompt submitted',
preToolUse: 'Pre-tool use',
postToolUse: 'Post-tool use',
errorOccurred: 'Error occurred',
};
function formatHookType(hookType: string | undefined): string {
if (!hookType) return 'Unknown';
return hookTypeLabels[hookType] ?? hookType;
}
function formatTurnEventEntry(event: SessionEventRecord): TurnEventEntry | undefined {
switch (event.kind) {
case 'subagent':
@@ -257,12 +271,12 @@ function formatTurnEventEntry(event: SessionEventRecord): TurnEventEntry | undef
success: event.subagentEventKind === 'completed' ? true : event.subagentEventKind === 'failed' ? false : undefined,
};
case 'hook-lifecycle': {
const hookLabel = formatHookType(event.hookType);
const phaseLabel = event.hookPhase === 'start' ? 'started' : event.hookPhase === 'end' ? 'completed' : undefined;
return {
kind: event.kind,
occurredAt: event.occurredAt,
label: phaseLabel ? `Hook ${event.hookType ?? 'unknown'} ${phaseLabel}` : `Hook ${event.hookType ?? 'unknown'}`,
detail: event.hookInvocationId,
label: phaseLabel ? `${hookLabel} hook ${phaseLabel}` : `${hookLabel} hook`,
phase: event.hookPhase,
success: event.hookSuccess,
};