|
1 | 1 | import React, { useState, useEffect, useMemo, useRef } from 'react'; |
| 2 | +import { type Origin, getAgentName, getAgentBadge } from '@plannotator/shared/agents'; |
2 | 3 | import { parseMarkdownToBlocks, exportAnnotations, exportLinkedDocAnnotations, exportEditorAnnotations, extractFrontmatter, wrapFeedbackForAgent, Frontmatter } from '@plannotator/ui/utils/parser'; |
3 | 4 | import { Viewer, ViewerHandle } from '@plannotator/ui/components/Viewer'; |
4 | 5 | import { AnnotationPanel } from '@plannotator/ui/components/AnnotationPanel'; |
@@ -85,7 +86,7 @@ const App: React.FC = () => { |
85 | 86 | }); |
86 | 87 | const [uiPrefs, setUiPrefs] = useState(() => getUIPreferences()); |
87 | 88 | const [isApiMode, setIsApiMode] = useState(false); |
88 | | - const [origin, setOrigin] = useState<'claude-code' | 'opencode' | 'pi' | 'codex' | null>(null); |
| 89 | + const [origin, setOrigin] = useState<Origin | null>(null); |
89 | 90 | const [gitUser, setGitUser] = useState<string | undefined>(); |
90 | 91 | const [isWSL, setIsWSL] = useState(false); |
91 | 92 | const [globalAttachments, setGlobalAttachments] = useState<ImageAttachment[]>([]); |
@@ -388,7 +389,7 @@ const App: React.FC = () => { |
388 | 389 | if (!res.ok) throw new Error('Not in API mode'); |
389 | 390 | return res.json(); |
390 | 391 | }) |
391 | | - .then((data: { plan: string; origin?: 'claude-code' | 'opencode' | 'pi' | 'codex'; mode?: 'annotate' | 'annotate-last' | 'annotate-folder' | 'archive'; filePath?: string; sharingEnabled?: boolean; shareBaseUrl?: string; pasteApiUrl?: string; repoInfo?: { display: string; branch?: string }; previousPlan?: string | null; versionInfo?: { version: number; totalVersions: number; project: string }; archivePlans?: ArchivedPlan[]; projectRoot?: string; isWSL?: boolean; serverConfig?: { displayName?: string; gitUser?: string } }) => { |
| 392 | + .then((data: { plan: string; origin?: Origin; mode?: 'annotate' | 'annotate-last' | 'annotate-folder' | 'archive'; filePath?: string; sharingEnabled?: boolean; shareBaseUrl?: string; pasteApiUrl?: string; repoInfo?: { display: string; branch?: string }; previousPlan?: string | null; versionInfo?: { version: number; totalVersions: number; project: string }; archivePlans?: ArchivedPlan[]; projectRoot?: string; isWSL?: boolean; serverConfig?: { displayName?: string; gitUser?: string } }) => { |
392 | 393 | // Initialize config store with server-provided values (config file > cookie > default) |
393 | 394 | configStore.init(data.serverConfig); |
394 | 395 | // gitUser drives the "Use git name" button in Settings; stays undefined (button hidden) when unavailable |
@@ -986,14 +987,7 @@ const App: React.FC = () => { |
986 | 987 | return () => document.removeEventListener('pointerdown', handleClickOutside); |
987 | 988 | }, [showExportDropdown]); |
988 | 989 |
|
989 | | - const agentName = useMemo(() => { |
990 | | - if (origin === 'opencode') return 'OpenCode'; |
991 | | - if (origin === 'claude-code') return 'Claude Code'; |
992 | | - if (origin === 'copilot-cli') return 'Copilot CLI'; |
993 | | - if (origin === 'pi') return 'Pi'; |
994 | | - if (origin === 'codex') return 'Codex'; |
995 | | - return 'Coding Agent'; |
996 | | - }, [origin]); |
| 990 | + const agentName = useMemo(() => getAgentName(origin), [origin]); |
997 | 991 |
|
998 | 992 | const planMaxWidth = useMemo(() => { |
999 | 993 | const widths: Record<PlanWidth, number> = { compact: 832, default: 1040, wide: 1280 }; |
@@ -1024,15 +1018,7 @@ const App: React.FC = () => { |
1024 | 1018 | v{typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : '0.0.0'} |
1025 | 1019 | </a> |
1026 | 1020 | {origin && ( |
1027 | | - <span className={`text-[10px] px-1.5 py-0.5 rounded font-medium hidden md:inline ${ |
1028 | | - origin === 'claude-code' |
1029 | | - ? 'bg-orange-500/15 text-orange-400' |
1030 | | - : origin === 'pi' |
1031 | | - ? 'bg-violet-500/15 text-violet-400' |
1032 | | - : origin === 'copilot-cli' |
1033 | | - ? 'bg-blue-500/15 text-blue-400' |
1034 | | - : 'bg-zinc-500/20 text-zinc-400' |
1035 | | - }`}> |
| 1021 | + <span className={`text-[10px] px-1.5 py-0.5 rounded font-medium hidden md:inline ${getAgentBadge(origin)}`}> |
1036 | 1022 | {agentName} |
1037 | 1023 | </span> |
1038 | 1024 | )} |
|
0 commit comments