mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-28 09:23:08 +08:00
feat(hook): add display name to template ID mapping and improve translation fallback logic
This commit is contained in:
@@ -99,23 +99,57 @@ function getTriggerVariant(trigger: HookTriggerType): 'default' | 'secondary' |
|
|||||||
// ========== Component ==========
|
// ========== Component ==========
|
||||||
|
|
||||||
// ========== Hook Name Translation ==========
|
// ========== Hook Name Translation ==========
|
||||||
|
// Mapping from display name to template ID for translation lookup
|
||||||
|
const DISPLAY_NAME_TO_TEMPLATE_ID: Record<string, string> = {
|
||||||
|
// Notification hooks
|
||||||
|
'Session Start Notify': 'session-start-notify',
|
||||||
|
'Session State Watch': 'session-state-watch',
|
||||||
|
'Stop Notify': 'stop-notify',
|
||||||
|
// Automation hooks
|
||||||
|
'Auto Format on Write': 'auto-format-on-write',
|
||||||
|
'Auto Lint on Write': 'auto-lint-on-write',
|
||||||
|
'Block Sensitive Files': 'block-sensitive-files',
|
||||||
|
'Git Auto Stage': 'git-auto-stage',
|
||||||
|
// Indexing hooks
|
||||||
|
'Post Edit Index': 'post-edit-index',
|
||||||
|
'Session End Summary': 'session-end-summary',
|
||||||
|
'Project State Inject': 'project-state-inject',
|
||||||
|
// Memory V2 hooks
|
||||||
|
'Memory V2 Extract': 'memory-v2-extract',
|
||||||
|
'Memory V2 Auto Consolidate': 'memory-v2-auto-consolidate',
|
||||||
|
'Memory Sync Dashboard': 'memory-sync-dashboard',
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get translated hook name if available
|
* Get translated hook name if available
|
||||||
* Falls back to original name if no translation exists
|
* Falls back to original name if no translation exists
|
||||||
*/
|
*/
|
||||||
function getHookDisplayName(name: string, formatMessage: (msg: { id: string }) => string): string {
|
function getHookDisplayName(name: string, formatMessage: (msg: { id: string }) => string): string {
|
||||||
|
// First try direct translation with the name (for template IDs)
|
||||||
const translationKey = `cliHooks.templates.templates.${name}.name`;
|
const translationKey = `cliHooks.templates.templates.${name}.name`;
|
||||||
// Try to get translation, fallback to original name
|
|
||||||
try {
|
try {
|
||||||
const translated = formatMessage({ id: translationKey });
|
const translated = formatMessage({ id: translationKey });
|
||||||
// If translation returns the key itself, no translation exists
|
|
||||||
if (translated && !translated.includes('cliHooks.templates.templates')) {
|
if (translated && !translated.includes('cliHooks.templates.templates')) {
|
||||||
return translated;
|
return translated;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// Translation not found
|
// Direct translation not found
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try mapping display name to template ID
|
||||||
|
const templateId = DISPLAY_NAME_TO_TEMPLATE_ID[name];
|
||||||
|
if (templateId) {
|
||||||
|
const mappedKey = `cliHooks.templates.templates.${templateId}.name`;
|
||||||
|
try {
|
||||||
|
const translated = formatMessage({ id: mappedKey });
|
||||||
|
if (translated && !translated.includes('cliHooks.templates.templates')) {
|
||||||
|
return translated;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Mapping found but no translation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +200,7 @@ export function HookCard({
|
|||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
<div className="flex items-center gap-2 flex-wrap">
|
<div className="flex items-center gap-2 flex-wrap">
|
||||||
<span className="text-sm font-medium text-foreground truncate">
|
<span className="text-sm font-medium text-foreground truncate">
|
||||||
{hook.name}
|
{displayName}
|
||||||
</span>
|
</span>
|
||||||
<Badge
|
<Badge
|
||||||
variant={getTriggerVariant(hook.trigger)}
|
variant={getTriggerVariant(hook.trigger)}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export function useLoops(options: UseLoopsOptions = {}): UseLoopsReturn {
|
|||||||
return loops;
|
return loops;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// Group by status for Kanban
|
// Group by status for Kanban (use filteredLoops to respect search filter)
|
||||||
const loopsByStatus: Record<Loop['status'], Loop[]> = {
|
const loopsByStatus: Record<Loop['status'], Loop[]> = {
|
||||||
created: [],
|
created: [],
|
||||||
running: [],
|
running: [],
|
||||||
@@ -95,7 +95,7 @@ export function useLoops(options: UseLoopsOptions = {}): UseLoopsReturn {
|
|||||||
failed: [],
|
failed: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const loop of allLoops) {
|
for (const loop of filteredLoops) {
|
||||||
loopsByStatus[loop.status].push(loop);
|
loopsByStatus[loop.status].push(loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user