MCPcopy
hub / github.com/xintaofei/codeg / StatusBarConnection

Function StatusBarConnection

src/components/layout/status-bar-connection.tsx:41–131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39}
40
41export function StatusBarConnection() {
42 const t = useTranslations("Folder.statusBar.connection")
43 const store = useConnectionStore()
44 const { tabs, activeTabId } = useTabContext()
45 const { conversations } = useAppWorkspace()
46
47 // Subscribe to activeKey changes
48 const subscribeActiveKey = useCallback(
49 (cb: () => void) => store.subscribeActiveKey(cb),
50 [store]
51 )
52 const getActiveKey = useCallback(() => store.getActiveKey(), [store])
53 const activeKey = useSyncExternalStore(
54 subscribeActiveKey,
55 getActiveKey,
56 getActiveKey
57 )
58
59 // Subscribe to the active connection's changes
60 const subscribeConn = useCallback(
61 (cb: () => void) => {
62 if (!activeKey) return () => {}
63 return store.subscribeKey(activeKey, cb)
64 },
65 [store, activeKey]
66 )
67 const getConnSnapshot = useCallback(
68 () => (activeKey ? store.getConnection(activeKey) : undefined),
69 [store, activeKey]
70 )
71 const activeConn = useSyncExternalStore(
72 subscribeConn,
73 getConnSnapshot,
74 getConnSnapshot
75 )
76
77 const status = activeConn?.status ?? null
78 const agentType = activeConn?.agentType ?? null
79
80 const model = useMemo(() => {
81 const tab = tabs.find((t) => t.id === activeTabId)
82 if (!tab || tab.kind !== "conversation") return null
83 const conv = conversations.find(
84 (c) => c.id === tab.conversationId && c.agent_type === tab.agentType
85 )
86 return conv?.model ?? null
87 }, [tabs, activeTabId, conversations])
88
89 if (!agentType || !status || status === "disconnected") {
90 return (
91 <TooltipProvider>
92 <Tooltip>
93 <TooltipTrigger asChild>
94 <div className="flex items-center gap-1.5">
95 <Unplug className="h-3.5 w-3.5 text-muted-foreground/50" />
96 {model && <span>{model}</span>}
97 </div>
98 </TooltipTrigger>

Callers

nothing calls this directly

Calls 9

useConnectionStoreFunction · 0.90
useTabContextFunction · 0.90
useAppWorkspaceFunction · 0.90
cnFunction · 0.90
subscribeActiveKeyMethod · 0.80
getActiveKeyMethod · 0.80
subscribeKeyMethod · 0.80
getConnectionMethod · 0.80
tFunction · 0.50

Tested by

no test coverage detected