femo-plugin 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +627 -0
- package/femo2host/__init__.py +4 -0
- package/femo2host/femoToolcall/chronica.py +156 -0
- package/femo2host/femoToolcall/femo-chat.mjs +69 -0
- package/femo2host/femoToolcall/femo_debugger.py +1515 -0
- package/femo2host/femo_api.py +437 -0
- package/femo2host/femo_gen_api.jsx +77 -0
- package/femoBridges/ContextExample.py +555 -0
- package/femoBridges/MemoryExample.py +163 -0
- package/femoBridges/__init__.py +1 -0
- package/femoBridges/getDir/get_dir.py +56 -0
- package/femoBridges/getDir//344/275/240/345/217/257/344/273/245/350/256/276/345/256/232/344/273/273/346/204/217/346/226/207/344/273/266/345/244/271/344/270/272/347/224/250/346/210/267/346/225/260/346/215/256/346/226/207/344/273/266/345/244/271.txt +10 -0
- package/femoBridges/llmBridge.py +247 -0
- package/femoBridges/llmProviders.py +308 -0
- package/femoCompiler/FEMO_CLIrenderer.py +198 -0
- package/femoCompiler/FEMO_config.py +35 -0
- package/femoCompiler/FEMO_errors.py +278 -0
- package/femoCompiler/FEMO_interpreter.py +163 -0
- package/femoCompiler/FEMO_normalizer.py +396 -0
- package/femoCompiler/FEMO_parser.py +2468 -0
- package/femoCompiler/FEMO_runtime.py +3630 -0
- package/femoCompiler/FEMO_scope_resolver.py +209 -0
- package/femoCompiler/__init__.py +1 -0
- package/femoCompiler/actor_resolver.py +86 -0
- package/femoCompiler/block_collector.py +441 -0
- package/femoCompiler/db_utils.py +485 -0
- package/femoCompiler/femoAsync.py +401 -0
- package/femoCompiler/host_manifest.py +68 -0
- package/femoCompiler/job_manager.py +767 -0
- package/femoCompiler/protocol.py +126 -0
- package/femoCompiler/save_dialog.py +402 -0
- package/femoCompiler/task_world.py +544 -0
- package/femoCompiler/vars/__init__.py +19 -0
- package/femoCompiler/vars/checkpoint.py +113 -0
- package/femoCompiler/vars/env.py +686 -0
- package/femoCompiler/vars/evaluator.py +567 -0
- package/femoCompiler/vars/join.py +303 -0
- package/femoCompiler/vars/merge.py +157 -0
- package/femoCompiler/vars/model.py +245 -0
- package/femoExamples/AI/345/211/252/350/247/206/351/242/221/AI/345/211/252/350/247/206/351/242/221.femo +192 -0
- package/femoExamples/AI/350/201/212/345/244/251/345/256/244/group-chat.femo +42 -0
- package/femoExamples/AI/350/201/212/345/244/251/345/256/244/random_wait_time.py +10 -0
- package/femoExamples/LuxFiat/luxfiat.femo +38 -0
- package/femoExamples/LuxFiat/wait.py +29 -0
- package/femoExamples/debug/347/245/236/345/231/250/debug/347/245/236/345/231/250.femo +222 -0
- package/femoExamples/discussion.femo +70 -0
- package/femoExamples/goal-mode.femo +23 -0
- package/femoExamples//345/270/270/347/224/250/345/267/245/345/205/267python/wait.py +29 -0
- package/femoExamples//347/213/274/344/272/272/346/235/200/werewolf_utils.py +205 -0
- package/femoExamples//347/213/274/344/272/272/346/235/200/werewolf_utils2.py +324 -0
- package/femoExamples//347/213/274/344/272/272/346/235/200//347/213/274/344/272/272/346/235/200-/350/255/246/351/225/277/347/211/210.femo +544 -0
- package/femoExamples//347/213/274/344/272/272/346/235/200//347/213/274/344/272/272/346/235/200.femo +331 -0
- package/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225/undercover_utils.py +683 -0
- package/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225//350/260/201/346/230/257/345/215/247/345/272/225-/350/217/234/345/270/202/345/234/272/345/261/200.femo +348 -0
- package/femoExamples//350/260/201/346/230/257/345/215/247/345/272/225//350/260/201/346/230/257/345/215/247/345/272/225.femo +392 -0
- package/femoGen/document_ch.html +2352 -0
- package/femoGen/document_en.html +2279 -0
- package/femoGen/index.html +19 -0
- package/femoGen/intro_ch.html +942 -0
- package/femoGen/intro_en.html +932 -0
- package/femoGen/package-lock.json +1698 -0
- package/femoGen/package.json +19 -0
- package/femoGen/public/character_need.ttf +0 -0
- package/femoGen/public/favicon.ico +0 -0
- package/femoGen/public/femo-logo-slogan.svg +83 -0
- package/femoGen/public/femo-logo.svg +55 -0
- package/femoGen/public/logo-fullsize.ico +0 -0
- package/femoGen/src/FemoWorAuto.jsx +5444 -0
- package/femoGen/src/actionModal.jsx +358 -0
- package/femoGen/src/bubbleOverlay.jsx +701 -0
- package/femoGen/src/canvasNodes.jsx +608 -0
- package/femoGen/src/common.jsx +715 -0
- package/femoGen/src/debugPanel.jsx +530 -0
- package/femoGen/src/faIcons.jsx +84 -0
- package/femoGen/src/femoDiagnostics.js +122 -0
- package/femoGen/src/femoFileList.jsx +357 -0
- package/femoGen/src/femoGenerator.jsx +1198 -0
- package/femoGen/src/femoLog.js +107 -0
- package/femoGen/src/femoParser.jsx +2255 -0
- package/femoGen/src/femoPreview.jsx +297 -0
- package/femoGen/src/graphBuilder.jsx +358 -0
- package/femoGen/src/libPanel.jsx +519 -0
- package/femoGen/src/main.jsx +22 -0
- package/femoGen/src/mobileView.jsx +2796 -0
- package/femoGen/src/projectPanel.jsx +529 -0
- package/femoGen/src/soulModal.jsx +162 -0
- package/femoGen/src/styles/font.css +10 -0
- package/femoGen/src/themes.js +465 -0
- package/femoGen/src/useCanvasInteraction.jsx +319 -0
- package/femoGen/vite.config.js +28 -0
- package/femoGen//347/222/207/345/255/230/346/247/221.txt +15 -0
- package/hostAdapter/dshAdapter/README.md +68 -0
- package/hostAdapter/dshAdapter/build.mjs +75 -0
- package/hostAdapter/dshAdapter/client/client-ui/chat-node.tsx +339 -0
- package/hostAdapter/dshAdapter/client/client-ui/composer.tsx +997 -0
- package/hostAdapter/dshAdapter/client/client-ui/editor-page.tsx +726 -0
- package/hostAdapter/dshAdapter/client/client-ui/editor-view.tsx +88 -0
- package/hostAdapter/dshAdapter/client/client-ui/femo-stream-live.tsx +264 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/frame-router.ts +282 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/index.ts +44 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/ledger.ts +329 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/turn-view.tsx +211 -0
- package/hostAdapter/dshAdapter/client/client-ui/proj2/window-id.ts +28 -0
- package/hostAdapter/dshAdapter/client/client-ui/stream-store.ts +550 -0
- package/hostAdapter/dshAdapter/client/client-ui/styles.ts +144 -0
- package/hostAdapter/dshAdapter/client/client-ui/view-button.tsx +572 -0
- package/hostAdapter/dshAdapter/client/client-ui/view-state.ts +61 -0
- package/hostAdapter/dshAdapter/client/client.tsx +518 -0
- package/hostAdapter/dshAdapter/client/fa-icons.tsx +112 -0
- package/hostAdapter/dshAdapter/client/femo-reasoning-row.tsx +103 -0
- package/hostAdapter/dshAdapter/client/lineage-fork-native.jsx +624 -0
- package/hostAdapter/dshAdapter/client/lineage-fork.jsx +585 -0
- package/hostAdapter/dshAdapter/cordis.patch.yml +8 -0
- package/hostAdapter/dshAdapter/dshPatch/DSH-0.1.2-fork/344/277/256/346/224/271/351/234/200/346/261/202.md +184 -0
- package/hostAdapter/dshAdapter/dshPatch/MEOW_MODIFICATIONS.md +3105 -0
- package/hostAdapter/dshAdapter/dshPatch/patch-dsh-0.1.2-alpha.1.py +313 -0
- package/hostAdapter/dshAdapter/host/api-retry.ts +141 -0
- package/hostAdapter/dshAdapter/host/bridge.ts +224 -0
- package/hostAdapter/dshAdapter/host/config.ts +124 -0
- package/hostAdapter/dshAdapter/host/debug-log.ts +29 -0
- package/hostAdapter/dshAdapter/host/debug-run.ts +793 -0
- package/hostAdapter/dshAdapter/host/diag-feed.ts +56 -0
- package/hostAdapter/dshAdapter/host/engine-events.ts +891 -0
- package/hostAdapter/dshAdapter/host/engine-transcript.ts +122 -0
- package/hostAdapter/dshAdapter/host/femo-files.ts +210 -0
- package/hostAdapter/dshAdapter/host/god-mirror.ts +234 -0
- package/hostAdapter/dshAdapter/host/host-log.ts +101 -0
- package/hostAdapter/dshAdapter/host/http.ts +66 -0
- package/hostAdapter/dshAdapter/host/index.ts +633 -0
- package/hostAdapter/dshAdapter/host/list-cache.ts +183 -0
- package/hostAdapter/dshAdapter/host/main-actor.ts +853 -0
- package/hostAdapter/dshAdapter/host/main-delivery-queue.ts +115 -0
- package/hostAdapter/dshAdapter/host/native-state.ts +21 -0
- package/hostAdapter/dshAdapter/host/node-retry.ts +246 -0
- package/hostAdapter/dshAdapter/host/persona.ts +146 -0
- package/hostAdapter/dshAdapter/host/pre-step-gate.ts +95 -0
- package/hostAdapter/dshAdapter/host/proj-trace.ts +49 -0
- package/hostAdapter/dshAdapter/host/projection-input.ts +238 -0
- package/hostAdapter/dshAdapter/host/projection.ts +742 -0
- package/hostAdapter/dshAdapter/host/routes.ts +1196 -0
- package/hostAdapter/dshAdapter/host/run-control.ts +641 -0
- package/hostAdapter/dshAdapter/host/safe-steer.ts +33 -0
- package/hostAdapter/dshAdapter/host/section-gate.ts +108 -0
- package/hostAdapter/dshAdapter/host/session-events.ts +45 -0
- package/hostAdapter/dshAdapter/host/state-files.ts +301 -0
- package/hostAdapter/dshAdapter/host/stream-frames.ts +229 -0
- package/hostAdapter/dshAdapter/host/subagent-native.ts +997 -0
- package/hostAdapter/dshAdapter/host/subagent.ts +1205 -0
- package/hostAdapter/dshAdapter/host/tools.ts +486 -0
- package/hostAdapter/dshAdapter/host/windowing-native.ts +294 -0
- package/hostAdapter/dshAdapter/host.manifest.json +6 -0
- package/hostAdapter/dshAdapter/lib/client.js +19161 -0
- package/hostAdapter/dshAdapter/lib/client.js.map +7 -0
- package/hostAdapter/dshAdapter/lib/index.js +8173 -0
- package/hostAdapter/dshAdapter/lib/index.js.map +7 -0
- package/hostAdapter/dshAdapter/package-lock.json +500 -0
- package/hostAdapter/dshAdapter/package.json +55 -0
- package/hostAdapter/dshAdapter/pnpm-lock.yaml +596 -0
- package/hostAdapter/dshAdapter/pnpm-workspace.yaml +2 -0
- package/hostAdapter/dshAdapter/python/dev-bridge-test.py +43 -0
- package/hostAdapter/dshAdapter/python/femo_bridge.py +533 -0
- package/hostAdapter/dshAdapter/tsconfig.host.json +9 -0
- package/hostAdapter/dshAdapter/tsconfig.json +21 -0
- package/package.json +40 -0
- package//350/257/255/346/263/225/346/226/207/346/241/243.md +1136 -0
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState, } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { IconChevronDownOutline14, IconChevronRightOutline14, IconRefreshOutline14, StateDot, } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
5
|
+
|
|
6
|
+
// 2026-09-04 rc.1 接入:indexSubagentDescendants 原从 @deepseek-ai/dsh-client-runtime/client
|
|
7
|
+
// 导入——rc.1 已删除 client-runtime 包。该函数为自包含纯函数(与 rc.1 ui-subagent
|
|
8
|
+
// subagent-lineage.ts 同款语义:按 parentId/origin/running 聚合后代计数),本地化后
|
|
9
|
+
// lineage 组件在 rc.2/rc.1 双版本零外部依赖,无需 dual require。
|
|
10
|
+
function indexSubagentDescendants(summaries) {
|
|
11
|
+
const indexed = new Map()
|
|
12
|
+
for (const descendant of Object.values(summaries)) {
|
|
13
|
+
if (descendant.origin !== 'subagent') continue
|
|
14
|
+
const seen = new Set()
|
|
15
|
+
let current = descendant
|
|
16
|
+
while (current?.origin === 'subagent' && current.parentId !== undefined && !seen.has(current.id)) {
|
|
17
|
+
seen.add(current.id)
|
|
18
|
+
const aggregate = indexed.get(current.parentId)
|
|
19
|
+
if (aggregate === undefined) {
|
|
20
|
+
indexed.set(current.parentId, { count: 1, runningCount: descendant.running ? 1 : 0 })
|
|
21
|
+
} else {
|
|
22
|
+
aggregate.count += 1
|
|
23
|
+
if (descendant.running) aggregate.runningCount += 1
|
|
24
|
+
}
|
|
25
|
+
current = summaries[current.parentId]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return indexed
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ── femo-plugin fork 注入(2026-08-23)─────────────────────────────────────
|
|
32
|
+
// 本文件 fork 自 @deepseek-ai/dsh-client-ui-subagent/lib SubagentHeaderLineage.js
|
|
33
|
+
// (rc.2 快照),唯一改动=按名字约定隐藏 Femo 剧本机制产生的条目:
|
|
34
|
+
// 投影窗 id 前缀 'femo-proj-'(host projection.ts projectionId)
|
|
35
|
+
// 节点子代理 label 前缀 'femo-node-'(host subagent.ts runAiSubagent 的 start label)
|
|
36
|
+
// 主模型主动拉起的子代理不受影响(label 无此前缀)。升级 rc.2 时需对照重放此 fork。
|
|
37
|
+
const css = {
|
|
38
|
+
activitySlot: 'A-xaeG_activitySlot',
|
|
39
|
+
ancestorSwitcherTrigger: 'A-xaeG_ancestorSwitcherTrigger',
|
|
40
|
+
children: 'A-xaeG_children',
|
|
41
|
+
clickarea: 'A-xaeG_clickarea',
|
|
42
|
+
content: 'A-xaeG_content',
|
|
43
|
+
currentLabel: 'A-xaeG_currentLabel',
|
|
44
|
+
disabled: 'A-xaeG_disabled',
|
|
45
|
+
disclosure: 'A-xaeG_disclosure',
|
|
46
|
+
disclosureOpen: 'A-xaeG_disclosureOpen',
|
|
47
|
+
disclosureSpace: 'A-xaeG_disclosureSpace',
|
|
48
|
+
error: 'A-xaeG_error',
|
|
49
|
+
label: 'A-xaeG_label',
|
|
50
|
+
loadingRow: 'A-xaeG_loadingRow',
|
|
51
|
+
menu: 'A-xaeG_menu',
|
|
52
|
+
metricDuration: 'A-xaeG_metricDuration',
|
|
53
|
+
metricToken: 'A-xaeG_metricToken',
|
|
54
|
+
metrics: 'A-xaeG_metrics',
|
|
55
|
+
node: 'A-xaeG_node',
|
|
56
|
+
notice: 'A-xaeG_notice',
|
|
57
|
+
refresh: 'A-xaeG_refresh',
|
|
58
|
+
root: 'A-xaeG_root',
|
|
59
|
+
row: 'A-xaeG_row',
|
|
60
|
+
separator: 'A-xaeG_separator',
|
|
61
|
+
summary: 'A-xaeG_summary',
|
|
62
|
+
switcherRoot: 'A-xaeG_switcherRoot',
|
|
63
|
+
switcherTitle: 'A-xaeG_switcherTitle',
|
|
64
|
+
switcherTrigger: 'A-xaeG_switcherTrigger',
|
|
65
|
+
trigger: 'A-xaeG_trigger',
|
|
66
|
+
triggerOpen: 'A-xaeG_triggerOpen',
|
|
67
|
+
}
|
|
68
|
+
function femoHiddenId(id) { return typeof id === 'string' && id.startsWith('femo-proj-') }
|
|
69
|
+
// 【版本分流】原生 0.1.3+(window.__femoNative,服务端 /femo-plugin/native-flag
|
|
70
|
+
// 下发):子代理会话=角色视角窗(拍板 2026-09-09),femo-node-* 条目不再剥离,
|
|
71
|
+
// 仅去掉展示前缀;旧版(meow fork)保持原剥离——本体已镜像进投影窗,是杂物。
|
|
72
|
+
function femoNativeCatalog() { return window.__femoNative === true }
|
|
73
|
+
function femoHiddenLabel(label) {
|
|
74
|
+
if (femoNativeCatalog()) return false
|
|
75
|
+
return typeof label === 'string' && label.startsWith('femo-node-')
|
|
76
|
+
}
|
|
77
|
+
function femoStripEntries(entries) {
|
|
78
|
+
if (femoNativeCatalog()) {
|
|
79
|
+
return entries.map((entry) => (
|
|
80
|
+
typeof entry.label === 'string' && entry.label.startsWith('femo-node-')
|
|
81
|
+
? { ...entry, label: entry.label.slice('femo-node-'.length) }
|
|
82
|
+
: entry
|
|
83
|
+
))
|
|
84
|
+
}
|
|
85
|
+
return entries.filter((entry) => !femoHiddenId(entry.id) && !femoHiddenLabel(entry.label))
|
|
86
|
+
}
|
|
87
|
+
function femoStripSummaries(byId) {
|
|
88
|
+
const native = femoNativeCatalog()
|
|
89
|
+
const out = {}
|
|
90
|
+
for (const [id, summary] of Object.entries(byId ?? {})) {
|
|
91
|
+
if (femoHiddenId(id)) continue
|
|
92
|
+
if (!native && femoHiddenLabel(summary?.displayTitle)) continue
|
|
93
|
+
out[id] = summary
|
|
94
|
+
}
|
|
95
|
+
return out
|
|
96
|
+
}
|
|
97
|
+
// ── femo-plugin fork 注入结束 ──────────────────────────────────────────────
|
|
98
|
+
|
|
99
|
+
function diagnosticReason(entry, t) {
|
|
100
|
+
switch (entry.reason) {
|
|
101
|
+
case 'corrupt': return t('diagnostic.corrupt');
|
|
102
|
+
case 'unsupported': return t('diagnostic.unsupported');
|
|
103
|
+
case 'unavailable': return t('diagnostic.unavailable');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function treeItems(root) {
|
|
107
|
+
return root === null
|
|
108
|
+
? []
|
|
109
|
+
: Array.from(root.querySelectorAll('[role="treeitem"]:not([aria-disabled="true"])'));
|
|
110
|
+
}
|
|
111
|
+
/** Compact token count shared in shape with the conversation stats strip. */
|
|
112
|
+
function formatTokens(value) {
|
|
113
|
+
const scaled = (next) => next >= 100
|
|
114
|
+
? String(Math.round(next))
|
|
115
|
+
: String(Math.round(next * 10) / 10);
|
|
116
|
+
if (value < 1_000)
|
|
117
|
+
return String(value);
|
|
118
|
+
if (value < 1_000_000)
|
|
119
|
+
return `${scaled(value / 1_000)}K`;
|
|
120
|
+
return `${scaled(value / 1_000_000)}M`;
|
|
121
|
+
}
|
|
122
|
+
/** Sum the four disjoint durable provider-usage buckets. */
|
|
123
|
+
function tokenTotal(usage) {
|
|
124
|
+
return usage === undefined
|
|
125
|
+
? undefined
|
|
126
|
+
: usage.uncachedInputTokens + usage.outputTokens
|
|
127
|
+
+ usage.cacheReadTokens + usage.cacheWriteTokens;
|
|
128
|
+
}
|
|
129
|
+
/** Exact whole-second active-turn duration for one catalog row. */
|
|
130
|
+
function activityDuration(summary, activity, now) {
|
|
131
|
+
if (summary === undefined)
|
|
132
|
+
return undefined;
|
|
133
|
+
const timing = summary.projectionValues?.subagentTiming;
|
|
134
|
+
if (timing === undefined)
|
|
135
|
+
return undefined;
|
|
136
|
+
if (timing.active === undefined)
|
|
137
|
+
return timing.settledMs;
|
|
138
|
+
const end = activity === 'running'
|
|
139
|
+
? now
|
|
140
|
+
: timing.active.through;
|
|
141
|
+
return timing.settledMs + Math.max(0, end - timing.active.since);
|
|
142
|
+
}
|
|
143
|
+
function splitDuration(ms) {
|
|
144
|
+
const totalSeconds = Math.floor(Math.max(0, ms) / 1_000);
|
|
145
|
+
const totalMinutes = Math.floor(totalSeconds / 60);
|
|
146
|
+
const totalHours = Math.floor(totalMinutes / 60);
|
|
147
|
+
return {
|
|
148
|
+
seconds: totalSeconds % 60,
|
|
149
|
+
minutes: totalMinutes % 60,
|
|
150
|
+
hours: totalHours % 24,
|
|
151
|
+
days: Math.floor(totalHours / 24),
|
|
152
|
+
totalMinutes,
|
|
153
|
+
totalHours,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/** Format a duration with decreasing visual precision at larger scales. */
|
|
157
|
+
function formatDuration(ms, t) {
|
|
158
|
+
const { seconds, minutes, hours, days, totalMinutes, totalHours } = splitDuration(ms);
|
|
159
|
+
if (days >= 365) {
|
|
160
|
+
const years = Math.floor(days / 365);
|
|
161
|
+
const months = Math.floor((days % 365) / 30);
|
|
162
|
+
return months === 0
|
|
163
|
+
? t('duration.years', { years })
|
|
164
|
+
: t('duration.yearsMonths', { years, months });
|
|
165
|
+
}
|
|
166
|
+
if (days >= 30) {
|
|
167
|
+
const months = Math.floor(days / 30);
|
|
168
|
+
const remainingDays = days % 30;
|
|
169
|
+
return remainingDays === 0
|
|
170
|
+
? t('duration.months', { months })
|
|
171
|
+
: t('duration.monthsDays', { months, days: remainingDays });
|
|
172
|
+
}
|
|
173
|
+
if (days > 0) {
|
|
174
|
+
return hours === 0
|
|
175
|
+
? t('duration.days', { days })
|
|
176
|
+
: t('duration.daysHours', { days, hours });
|
|
177
|
+
}
|
|
178
|
+
if (totalHours > 0) {
|
|
179
|
+
return t('duration.hours', {
|
|
180
|
+
hours: totalHours,
|
|
181
|
+
minutes: String(minutes).padStart(2, '0'),
|
|
182
|
+
seconds: String(seconds).padStart(2, '0'),
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
if (totalMinutes > 0) {
|
|
186
|
+
return t('duration.minutes', {
|
|
187
|
+
minutes: totalMinutes,
|
|
188
|
+
seconds: String(seconds).padStart(2, '0'),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return t('duration.seconds', { seconds });
|
|
192
|
+
}
|
|
193
|
+
/** Preserve exact whole seconds for hover and accessible naming. */
|
|
194
|
+
function formatExactDuration(ms, t) {
|
|
195
|
+
const { seconds, minutes, hours, days } = splitDuration(ms);
|
|
196
|
+
return days === 0
|
|
197
|
+
? formatDuration(ms, t)
|
|
198
|
+
: t('duration.exactDays', {
|
|
199
|
+
days,
|
|
200
|
+
hours: String(hours).padStart(2, '0'),
|
|
201
|
+
minutes: String(minutes).padStart(2, '0'),
|
|
202
|
+
seconds: String(seconds).padStart(2, '0'),
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
const NO_DESCENDANTS = { count: 0, runningCount: 0 };
|
|
206
|
+
function SubagentSwitcherIcon() {
|
|
207
|
+
return (_jsxs("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: [_jsx("path", { d: "M5.99951 12.7L8.95546 14.9478C9.40011 15.2859 9.62244 15.455 9.87526 15.488C9.95774 15.4988 10.0413 15.4988 10.1238 15.488C10.3766 15.455 10.5989 15.2859 11.0436 14.9478L13.9995 12.7", stroke: "currentColor", strokeWidth: "1.5" }), _jsx("path", { d: "M13.9995 7.7417L11.0436 5.49387C10.5989 5.15574 10.3766 4.98668 10.1238 4.95362C10.0413 4.94283 9.95775 4.94283 9.87527 4.95362C9.62245 4.98668 9.40012 5.15574 8.95547 5.49387L5.99952 7.7417", stroke: "currentColor", strokeWidth: "1.5" })] }));
|
|
208
|
+
}
|
|
209
|
+
/** Render the known direct-child shape while its authoritative catalog hydrates. */
|
|
210
|
+
function CatalogLoadingRows({ parentSessionId, summaries, level, t, }) {
|
|
211
|
+
const children = Object.values(summaries).filter(summary => (summary.origin === 'subagent' && summary.parentId === parentSessionId)).filter((summary) => !femoHiddenId(summary.id) && !femoHiddenLabel(summary.displayTitle));
|
|
212
|
+
if (children.length === 0)
|
|
213
|
+
return _jsx("div", { className: css.notice, children: t('loading.label') });
|
|
214
|
+
return children.map(summary => (_jsx("div", { className: css.node, children: _jsxs("div", { role: "treeitem", "aria-disabled": "true", "aria-level": level, "aria-label": t('loading.aria'), className: `${css.row} ${css.disabled} ${css.loadingRow}`, children: [_jsx("span", { className: css.disclosureSpace }), _jsx(StateDot, { state: summary.running ? 'ongoing' : 'done' }), _jsx("span", { className: css.content, children: _jsx("span", { className: css.label, children: t('loading.label') }) })] }) }, summary.id)));
|
|
215
|
+
}
|
|
216
|
+
/** Render one catalog level and recurse only through explicitly expanded rows. */
|
|
217
|
+
function CatalogRows({ parentSessionId, currentSessionId, catalog, catalogs, summaries, expanded, level, now, openChild, refresh, toggleBranch, closeCatalog, t, }) {
|
|
218
|
+
const emptyLoading = catalog.state === 'loading' && catalog.entries.length === 0;
|
|
219
|
+
const reserveDisclosure = catalog.entries.some(entry => entry.kind === 'child' && entry.hasChildren);
|
|
220
|
+
return (_jsxs(_Fragment, { children: [emptyLoading && (_jsx(CatalogLoadingRows, { parentSessionId: parentSessionId, summaries: summaries, level: level, t: t })), catalog.state === 'error' && (_jsxs("div", { className: css.error, children: [_jsx("span", { children: catalog.error?.message ?? t('load.error') }), _jsxs("button", { type: "button", className: css.refresh, onClick: () => { refresh(parentSessionId); }, children: [_jsx(IconRefreshOutline14, {}), t('retry')] })] })), femoStripEntries(catalog.entries).map((entry) => {
|
|
221
|
+
if (entry.kind === 'diagnostic') {
|
|
222
|
+
const reason = diagnosticReason(entry, t);
|
|
223
|
+
return (_jsx("div", { className: css.node, children: _jsxs("div", { role: "treeitem", "aria-disabled": "true", "aria-level": level, "aria-label": `${entry.id} ${reason}`, className: `${css.row} ${css.disabled}`, title: reason, children: [reserveDisclosure && _jsx("span", { className: css.disclosureSpace }), _jsx(StateDot, { state: "error" }), _jsxs("span", { className: css.content, children: [_jsx("span", { className: css.label, children: entry.id }), _jsx("span", { className: css.summary, children: reason })] })] }) }, entry.id));
|
|
224
|
+
}
|
|
225
|
+
const childCatalog = catalogs[entry.id];
|
|
226
|
+
const isCurrent = entry.id === currentSessionId;
|
|
227
|
+
const isExpanded = expanded.has(entry.id);
|
|
228
|
+
const knownLeaf = !entry.hasChildren;
|
|
229
|
+
const childLoading = childCatalog === undefined
|
|
230
|
+
|| (childCatalog.state === 'loading' && childCatalog.entries.length === 0);
|
|
231
|
+
const summary = summaries[entry.id];
|
|
232
|
+
const label = entry.label ?? entry.id;
|
|
233
|
+
const mode = entry.mode === 'one-shot' ? t('mode.oneShot') : t('mode.continuable');
|
|
234
|
+
const activity = entry.activity === 'running' ? t('activity.running') : t('activity.inactive');
|
|
235
|
+
const secondary = [summary?.title, mode, activity]
|
|
236
|
+
.filter(value => value !== undefined)
|
|
237
|
+
.join(' 路 ');
|
|
238
|
+
const totalTokens = tokenTotal(summary?.projectionValues?.tokenUsage);
|
|
239
|
+
const durationMs = activityDuration(summary, entry.activity, now);
|
|
240
|
+
const tokenMetric = totalTokens === undefined
|
|
241
|
+
? undefined
|
|
242
|
+
: `${formatTokens(totalTokens)} tok`;
|
|
243
|
+
const durationMetric = durationMs === undefined
|
|
244
|
+
? undefined
|
|
245
|
+
: {
|
|
246
|
+
compact: formatDuration(durationMs, t),
|
|
247
|
+
exact: formatExactDuration(durationMs, t),
|
|
248
|
+
};
|
|
249
|
+
const metrics = [tokenMetric, durationMetric?.exact]
|
|
250
|
+
.filter(value => value !== undefined)
|
|
251
|
+
.join(' 路 ');
|
|
252
|
+
const open = () => {
|
|
253
|
+
openChild({ parentSessionId, childSessionId: entry.id, mode: entry.mode });
|
|
254
|
+
closeCatalog();
|
|
255
|
+
};
|
|
256
|
+
const handleKey = (event) => {
|
|
257
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
258
|
+
event.preventDefault();
|
|
259
|
+
event.stopPropagation();
|
|
260
|
+
open();
|
|
261
|
+
}
|
|
262
|
+
else if ((event.key === 'ArrowRight' && !knownLeaf && !isExpanded)
|
|
263
|
+
|| (event.key === 'ArrowLeft' && isExpanded)) {
|
|
264
|
+
event.preventDefault();
|
|
265
|
+
event.stopPropagation();
|
|
266
|
+
toggleBranch(entry.id);
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
const toggle = (event) => {
|
|
270
|
+
event.preventDefault();
|
|
271
|
+
event.stopPropagation();
|
|
272
|
+
toggleBranch(entry.id);
|
|
273
|
+
};
|
|
274
|
+
return (_jsxs("div", { className: css.node, children: [_jsxs("div", { role: "treeitem", tabIndex: 0, "aria-level": level, "aria-current": isCurrent || undefined, "aria-label": [label, secondary, metrics].filter(value => value !== '').join(' '), ...knownLeaf ? {} : { 'aria-expanded': isExpanded }, className: css.row, onClick: open, onKeyDown: handleKey, children: [knownLeaf
|
|
275
|
+
? reserveDisclosure && _jsx("span", { className: css.disclosureSpace })
|
|
276
|
+
: (_jsx("button", { type: "button", tabIndex: -1, className: `${css.disclosure} ${isExpanded ? css.disclosureOpen : ''}`, "aria-label": t(isExpanded ? 'branch.collapse' : 'branch.expand', { label }), onClick: toggle, children: _jsx(IconChevronRightOutline14, {}) })), _jsxs("div", { className: css.clickarea, children: [_jsx(StateDot, { state: entry.activity === 'running' ? 'ongoing' : 'done' }), _jsxs("span", { className: css.content, children: [_jsx("span", { className: `${css.label} ${isCurrent ? css.currentLabel : ''}`, children: label }), _jsx("span", { className: css.summary, children: secondary })] }), metrics !== '' && (_jsxs("span", { className: css.metrics, children: [tokenMetric !== undefined && _jsx("span", { className: css.metricToken, children: tokenMetric }), durationMetric !== undefined && (_jsx("span", { className: css.metricDuration, title: t('duration.exactTitle', { duration: durationMetric.exact }), children: durationMetric.compact }))] }))] })] }), isExpanded && !knownLeaf && (_jsx("div", { role: "group", className: css.children, "aria-busy": childLoading || undefined, children: childCatalog === undefined
|
|
277
|
+
? (_jsx(CatalogLoadingRows, { parentSessionId: entry.id, summaries: summaries, level: level + 1, t: t }))
|
|
278
|
+
: (_jsx(CatalogRows, { parentSessionId: entry.id, currentSessionId: currentSessionId, catalog: childCatalog, catalogs: catalogs, summaries: summaries, expanded: expanded, level: level + 1, now: now, openChild: openChild, refresh: refresh, toggleBranch: toggleBranch, closeCatalog: closeCatalog, t: t })) }))] }, entry.id));
|
|
279
|
+
})] }));
|
|
280
|
+
}
|
|
281
|
+
const MENU_VIEWPORT_MARGIN = 16;
|
|
282
|
+
/** Place a portaled catalog below its trigger without crossing the viewport edge. */
|
|
283
|
+
function catalogMenuPosition(trigger) {
|
|
284
|
+
const rect = trigger.getBoundingClientRect();
|
|
285
|
+
const width = Math.min(336, window.innerWidth - MENU_VIEWPORT_MARGIN * 2);
|
|
286
|
+
return {
|
|
287
|
+
top: rect.bottom + 5,
|
|
288
|
+
left: Math.min(Math.max(MENU_VIEWPORT_MARGIN, rect.left), window.innerWidth - width - MENU_VIEWPORT_MARGIN),
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
/** One trigger-plus-tree dropdown over the catalog rooted at `rootSessionId`. */
|
|
292
|
+
export function CatalogDropdown({ rootSessionId, currentSessionId, displayTitle, openTitle, variant, separator = false, showRunning = false, hideWhenZero = false, useSessions, openChild, refresh, setCatalogOpen, t, }) {
|
|
293
|
+
const ancestorSwitcher = variant === 'switcher' && openTitle !== undefined;
|
|
294
|
+
const catalogs = useSessions(state => state.subagentsByParent);
|
|
295
|
+
const summaries = useSessions(state => state.byId);
|
|
296
|
+
const catalog = catalogs[rootSessionId];
|
|
297
|
+
const [open, setOpen] = useState(false);
|
|
298
|
+
const [menuPosition, setMenuPosition] = useState();
|
|
299
|
+
const [now, setNow] = useState(() => Date.now());
|
|
300
|
+
const [expanded, setExpanded] = useState(() => new Set());
|
|
301
|
+
const rootRef = useRef(null);
|
|
302
|
+
const triggerRef = useRef(null);
|
|
303
|
+
const menuRef = useRef(null);
|
|
304
|
+
const hoverOpenTimer = useRef(undefined);
|
|
305
|
+
const hoverCloseTimer = useRef(undefined);
|
|
306
|
+
const observedCatalogs = useRef(new Set());
|
|
307
|
+
const requestedInitialCatalog = useRef();
|
|
308
|
+
const setCatalogOpenRef = useRef(setCatalogOpen);
|
|
309
|
+
setCatalogOpenRef.current = setCatalogOpen;
|
|
310
|
+
const currentEntry = currentSessionId === undefined
|
|
311
|
+
? undefined
|
|
312
|
+
: catalog?.entries.find(entry => entry.kind === 'child' && entry.id === currentSessionId);
|
|
313
|
+
const switcherDisplayTitle = currentEntry?.kind === 'child'
|
|
314
|
+
? currentEntry.label ?? currentEntry.id
|
|
315
|
+
: displayTitle;
|
|
316
|
+
const healthy = femoStripEntries(catalog?.entries.filter(entry => entry.kind === 'child') ?? []);
|
|
317
|
+
const descendants = useMemo(() => indexSubagentDescendants(femoStripSummaries(summaries)).get(rootSessionId) ?? NO_DESCENDANTS, [rootSessionId, summaries]);
|
|
318
|
+
// The catalog can arrive before the session-list baseline; never undercount
|
|
319
|
+
// the already-visible direct rows during that short bootstrap window.
|
|
320
|
+
const descendantCount = Math.max(healthy.length, descendants.count);
|
|
321
|
+
const totalCountKey = descendantCount === 1 ? 'count.total.one' : 'count.total.other';
|
|
322
|
+
const runningCountKey = descendants.runningCount === 1 ? 'count.running.one' : 'count.running.other';
|
|
323
|
+
// Session summaries can announce membership before the descriptor-backed catalog catches up.
|
|
324
|
+
// Keep that entry point visible through disabled loading rows; only catalog rows are navigable.
|
|
325
|
+
const summaryBackedLoading = (descendants.count > 0 || variant === 'switcher')
|
|
326
|
+
&& (catalog === undefined || (catalog.state === 'ready' && catalog.entries.length === 0));
|
|
327
|
+
const presentedCatalog = summaryBackedLoading
|
|
328
|
+
? {
|
|
329
|
+
entries: [],
|
|
330
|
+
parentAvailable: catalog?.parentAvailable ?? false,
|
|
331
|
+
state: 'loading',
|
|
332
|
+
error: null,
|
|
333
|
+
}
|
|
334
|
+
: catalog;
|
|
335
|
+
useEffect(() => {
|
|
336
|
+
if (variant !== 'switcher'
|
|
337
|
+
|| catalog !== undefined
|
|
338
|
+
|| requestedInitialCatalog.current === rootSessionId)
|
|
339
|
+
return;
|
|
340
|
+
requestedInitialCatalog.current = rootSessionId;
|
|
341
|
+
refresh(rootSessionId);
|
|
342
|
+
}, [catalog, refresh, rootSessionId, variant]);
|
|
343
|
+
const observeCatalog = (parentSessionId, next) => {
|
|
344
|
+
if (next)
|
|
345
|
+
observedCatalogs.current.add(parentSessionId);
|
|
346
|
+
else
|
|
347
|
+
observedCatalogs.current.delete(parentSessionId);
|
|
348
|
+
setCatalogOpen(parentSessionId, next);
|
|
349
|
+
};
|
|
350
|
+
const closeAllCatalogs = () => {
|
|
351
|
+
for (const parentSessionId of observedCatalogs.current) {
|
|
352
|
+
setCatalogOpen(parentSessionId, false);
|
|
353
|
+
}
|
|
354
|
+
observedCatalogs.current.clear();
|
|
355
|
+
setExpanded(new Set());
|
|
356
|
+
};
|
|
357
|
+
const cancelHoverClose = () => {
|
|
358
|
+
if (hoverCloseTimer.current === undefined)
|
|
359
|
+
return;
|
|
360
|
+
clearTimeout(hoverCloseTimer.current);
|
|
361
|
+
hoverCloseTimer.current = undefined;
|
|
362
|
+
};
|
|
363
|
+
const cancelHoverOpen = () => {
|
|
364
|
+
if (hoverOpenTimer.current === undefined)
|
|
365
|
+
return;
|
|
366
|
+
clearTimeout(hoverOpenTimer.current);
|
|
367
|
+
hoverOpenTimer.current = undefined;
|
|
368
|
+
};
|
|
369
|
+
const changeOpen = (next, restoreFocus = false) => {
|
|
370
|
+
cancelHoverOpen();
|
|
371
|
+
cancelHoverClose();
|
|
372
|
+
if (next) {
|
|
373
|
+
const trigger = triggerRef.current;
|
|
374
|
+
/* v8 ignore next -- a queued callback can outlive the trigger */
|
|
375
|
+
if (trigger === null)
|
|
376
|
+
return;
|
|
377
|
+
setOpen(true);
|
|
378
|
+
setMenuPosition(catalogMenuPosition(trigger));
|
|
379
|
+
setNow(Date.now());
|
|
380
|
+
observeCatalog(rootSessionId, true);
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
setOpen(false);
|
|
384
|
+
setMenuPosition(undefined);
|
|
385
|
+
closeAllCatalogs();
|
|
386
|
+
}
|
|
387
|
+
if (restoreFocus)
|
|
388
|
+
queueMicrotask(() => { triggerRef.current?.focus(); });
|
|
389
|
+
};
|
|
390
|
+
const scheduleHoverOpen = () => {
|
|
391
|
+
cancelHoverOpen();
|
|
392
|
+
cancelHoverClose();
|
|
393
|
+
if (open)
|
|
394
|
+
return;
|
|
395
|
+
hoverOpenTimer.current = setTimeout(() => {
|
|
396
|
+
hoverOpenTimer.current = undefined;
|
|
397
|
+
changeOpen(true);
|
|
398
|
+
}, 150);
|
|
399
|
+
};
|
|
400
|
+
const scheduleHoverClose = () => {
|
|
401
|
+
cancelHoverOpen();
|
|
402
|
+
cancelHoverClose();
|
|
403
|
+
hoverCloseTimer.current = setTimeout(() => {
|
|
404
|
+
hoverCloseTimer.current = undefined;
|
|
405
|
+
changeOpen(false);
|
|
406
|
+
}, 120);
|
|
407
|
+
};
|
|
408
|
+
const closeBranch = (root) => {
|
|
409
|
+
const closing = new Set();
|
|
410
|
+
const visit = (parentSessionId) => {
|
|
411
|
+
if (closing.has(parentSessionId) || !expanded.has(parentSessionId))
|
|
412
|
+
return;
|
|
413
|
+
closing.add(parentSessionId);
|
|
414
|
+
const branch = catalogs[parentSessionId];
|
|
415
|
+
for (const entry of branch?.entries ?? []) {
|
|
416
|
+
if (entry.kind === 'child')
|
|
417
|
+
visit(entry.id);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
visit(root);
|
|
421
|
+
for (const parentSessionId of closing)
|
|
422
|
+
observeCatalog(parentSessionId, false);
|
|
423
|
+
setExpanded(current => new Set([...current].filter(id => !closing.has(id))));
|
|
424
|
+
};
|
|
425
|
+
const toggleBranch = (childSessionId) => {
|
|
426
|
+
if (expanded.has(childSessionId)) {
|
|
427
|
+
closeBranch(childSessionId);
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
setExpanded(current => new Set(current).add(childSessionId));
|
|
431
|
+
observeCatalog(childSessionId, true);
|
|
432
|
+
};
|
|
433
|
+
useEffect(() => {
|
|
434
|
+
if (!open)
|
|
435
|
+
return;
|
|
436
|
+
const closeOutside = (event) => {
|
|
437
|
+
if (event.target instanceof Node
|
|
438
|
+
&& !rootRef.current?.contains(event.target)
|
|
439
|
+
&& !menuRef.current?.contains(event.target)) {
|
|
440
|
+
changeOpen(false);
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
document.addEventListener('pointerdown', closeOutside);
|
|
444
|
+
return () => { document.removeEventListener('pointerdown', closeOutside); };
|
|
445
|
+
}, [open]);
|
|
446
|
+
useEffect(() => {
|
|
447
|
+
if (!open)
|
|
448
|
+
return;
|
|
449
|
+
const placeMenu = () => {
|
|
450
|
+
const trigger = triggerRef.current;
|
|
451
|
+
/* v8 ignore next -- native resize or scroll can outlive the trigger */
|
|
452
|
+
if (trigger === null)
|
|
453
|
+
return;
|
|
454
|
+
setMenuPosition(catalogMenuPosition(trigger));
|
|
455
|
+
};
|
|
456
|
+
window.addEventListener('resize', placeMenu);
|
|
457
|
+
document.addEventListener('scroll', placeMenu, true);
|
|
458
|
+
return () => {
|
|
459
|
+
window.removeEventListener('resize', placeMenu);
|
|
460
|
+
document.removeEventListener('scroll', placeMenu, true);
|
|
461
|
+
};
|
|
462
|
+
}, [open]);
|
|
463
|
+
useEffect(() => {
|
|
464
|
+
if (!open || descendants.runningCount === 0)
|
|
465
|
+
return;
|
|
466
|
+
const timer = setInterval(() => { setNow(Date.now()); }, 1_000);
|
|
467
|
+
return () => { clearInterval(timer); };
|
|
468
|
+
}, [open, descendants.runningCount]);
|
|
469
|
+
useEffect(() => () => {
|
|
470
|
+
cancelHoverOpen();
|
|
471
|
+
cancelHoverClose();
|
|
472
|
+
for (const parentSessionId of observedCatalogs.current) {
|
|
473
|
+
setCatalogOpenRef.current(parentSessionId, false);
|
|
474
|
+
}
|
|
475
|
+
observedCatalogs.current.clear();
|
|
476
|
+
}, []);
|
|
477
|
+
// Visibility needs evidence of children (entries, summary-known descendants,
|
|
478
|
+
// or a failed load worth retrying). A bare loading catalog is not evidence:
|
|
479
|
+
// selecting any session schedules a refresh whose loading snapshot would
|
|
480
|
+
// otherwise flash the action in and out on childless sessions.
|
|
481
|
+
// hideWhenZero(femo-plugin count 座位专用,2026-08-23):官方 visible 看
|
|
482
|
+
// 过滤前的 catalog.entries.length——Femo 主会话的目录里躺着被 fork 剥掉的
|
|
483
|
+
// 投影窗/节点子代理条目,于是显示"0 个子代理"仍挂着。开启本开关后改看
|
|
484
|
+
// 过滤后的 descendantCount(= 屏显数字),0 则整个触发器(文字+箭头)隐藏,
|
|
485
|
+
// 与 dsh 真零子代理时的行为一致。默认关闭=官方路径逐字节不变。
|
|
486
|
+
const visible = presentedCatalog !== undefined
|
|
487
|
+
&& (variant === 'switcher'
|
|
488
|
+
|| presentedCatalog.state === 'error'
|
|
489
|
+
|| (!hideWhenZero && presentedCatalog.entries.length > 0)
|
|
490
|
+
|| descendantCount > 0);
|
|
491
|
+
useEffect(() => {
|
|
492
|
+
if (visible)
|
|
493
|
+
return;
|
|
494
|
+
cancelHoverOpen();
|
|
495
|
+
cancelHoverClose();
|
|
496
|
+
if (!open)
|
|
497
|
+
return;
|
|
498
|
+
setOpen(false);
|
|
499
|
+
closeAllCatalogs();
|
|
500
|
+
}, [visible, open]);
|
|
501
|
+
if (!visible)
|
|
502
|
+
return null;
|
|
503
|
+
const focusAt = (index) => {
|
|
504
|
+
const items = treeItems(menuRef.current);
|
|
505
|
+
if (items.length === 0)
|
|
506
|
+
return;
|
|
507
|
+
items[(index + items.length) % items.length]?.focus();
|
|
508
|
+
};
|
|
509
|
+
const navigate = (event) => {
|
|
510
|
+
const items = treeItems(menuRef.current);
|
|
511
|
+
const index = items.indexOf(document.activeElement);
|
|
512
|
+
if (event.key === 'Escape') {
|
|
513
|
+
event.preventDefault();
|
|
514
|
+
changeOpen(false, true);
|
|
515
|
+
}
|
|
516
|
+
else if (event.key === 'Home') {
|
|
517
|
+
event.preventDefault();
|
|
518
|
+
focusAt(0);
|
|
519
|
+
}
|
|
520
|
+
else if (event.key === 'End') {
|
|
521
|
+
event.preventDefault();
|
|
522
|
+
focusAt(items.length - 1);
|
|
523
|
+
}
|
|
524
|
+
else if (event.key === 'ArrowDown') {
|
|
525
|
+
event.preventDefault();
|
|
526
|
+
focusAt(index + 1);
|
|
527
|
+
}
|
|
528
|
+
else if (event.key === 'ArrowUp') {
|
|
529
|
+
event.preventDefault();
|
|
530
|
+
focusAt(index < 0 ? items.length - 1 : index - 1);
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
return (_jsxs("div", { className: `${css.root} ${variant === 'switcher' ? css.switcherRoot : ''}`, ref: rootRef, onKeyDown: navigate, onMouseEnter: scheduleHoverOpen, onMouseLeave: scheduleHoverClose, children: [separator && _jsx("span", { className: css.separator, children: "/" }), _jsxs("button", { ref: triggerRef, type: "button", className: variant === 'switcher'
|
|
534
|
+
? `${css.switcherTrigger} ${ancestorSwitcher ? css.ancestorSwitcherTrigger : ''}`
|
|
535
|
+
: css.trigger, "aria-haspopup": "tree", "aria-expanded": open, "aria-label": variant === 'switcher'
|
|
536
|
+
? t('switcher.aria', { title: switcherDisplayTitle })
|
|
537
|
+
: t(descendants.runningCount > 0 ? runningCountKey : totalCountKey, { count: descendants.runningCount > 0 ? descendants.runningCount : descendantCount }), onClick: openTitle === undefined
|
|
538
|
+
? undefined
|
|
539
|
+
: () => {
|
|
540
|
+
cancelHoverOpen();
|
|
541
|
+
if (open)
|
|
542
|
+
changeOpen(false);
|
|
543
|
+
openTitle();
|
|
544
|
+
}, onKeyDown: (event) => {
|
|
545
|
+
if (event.key !== 'ArrowDown')
|
|
546
|
+
return;
|
|
547
|
+
event.preventDefault();
|
|
548
|
+
if (!open)
|
|
549
|
+
changeOpen(true);
|
|
550
|
+
queueMicrotask(() => { focusAt(0); });
|
|
551
|
+
}, children: [variant === 'switcher'
|
|
552
|
+
? _jsx("span", { className: css.switcherTitle, children: switcherDisplayTitle })
|
|
553
|
+
: (_jsxs(_Fragment, { children: [descendants.runningCount > 0 && (_jsx("span", { className: css.activitySlot, children: _jsx(StateDot, { state: "ongoing" }) })), _jsx("span", { className: css.count, children: t(totalCountKey, { count: descendantCount }) }), showRunning && descendants.runningCount > 0 && (_jsx("span", { className: css.count, children: ` ${descendants.runningCount} 个在跑` }))] })), variant === 'switcher'
|
|
554
|
+
? _jsx(SubagentSwitcherIcon, {})
|
|
555
|
+
: _jsx(IconChevronDownOutline14, { className: open ? css.triggerOpen : undefined })] }), open && createPortal((_jsx("div", { ref: menuRef, className: css.menu, style: menuPosition, role: "tree", "aria-label": t('tree.aria'), onMouseEnter: cancelHoverClose, onMouseLeave: scheduleHoverClose, children: _jsx(CatalogRows, { parentSessionId: rootSessionId, currentSessionId: currentSessionId, catalog: presentedCatalog, catalogs: catalogs, summaries: summaries, expanded: expanded, level: 1, now: now, openChild: openChild, refresh: refresh, toggleBranch: toggleBranch, closeCatalog: () => { changeOpen(false); }, t: t }) })), document.body)] }));
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Render one breadcrumb title together with its subagent navigation.
|
|
559
|
+
* @param props - Breadcrumb title, session standard props, and catalog actions.
|
|
560
|
+
* @returns An ordinary-title descendant count, or a title-and-chevron sibling switcher.
|
|
561
|
+
*/
|
|
562
|
+
export function SubagentHeaderLineage({ lineageSessionId, displayTitle, openTitle, useSessions, openChild, refresh, setCatalogOpen, t, }) {
|
|
563
|
+
const summary = useSessions((state) => state.byId[lineageSessionId]);
|
|
564
|
+
const parentId = summary?.origin === 'subagent' ? summary.parentId : undefined;
|
|
565
|
+
// femo-plugin fork 让位(2026-08-23 布局重排 v2):Femo 剧本会话的面包屑区只留
|
|
566
|
+
// 斜杠与名字,子代理导航全部让给 actions 区——
|
|
567
|
+
// 投影窗(femo-proj- 前缀)→ 整个返回 null:骨架的段间 "/" 仍在,显示为
|
|
568
|
+
// 「母名 /」,随后是 actions 区 order -20 的视角按钮(单槽语义:占位
|
|
569
|
+
// 组件渲染 null 不触发 owner 的 fallback 子名 title)。
|
|
570
|
+
// Femo 主会话 → 只画一个 "/" 分隔符(主会话的斜杠是本组件 separator 自带
|
|
571
|
+
// 的,让位后需补上),计数菜单移到 client.tsx 的 femo-plugin-count 座位。
|
|
572
|
+
// 其余会话 → 与官方行为逐字一致。
|
|
573
|
+
const isFemoProj = femoHiddenId(lineageSessionId);
|
|
574
|
+
const isFemoMain = !isFemoProj && summary?.agentPreset === 'femo-plugin' && parentId === undefined;
|
|
575
|
+
if (isFemoProj)
|
|
576
|
+
return null;
|
|
577
|
+
if (isFemoMain)
|
|
578
|
+
return _jsx("span", { className: css.separator, children: "/" });
|
|
579
|
+
const shared = { useSessions, openChild, refresh, setCatalogOpen, t };
|
|
580
|
+
if (parentId === undefined) {
|
|
581
|
+
return (_jsx(CatalogDropdown, { rootSessionId: lineageSessionId, variant: "count", separator: true, ...shared }, lineageSessionId));
|
|
582
|
+
}
|
|
583
|
+
return (_jsxs(_Fragment, { children: [_jsx(CatalogDropdown, { rootSessionId: parentId, currentSessionId: lineageSessionId, variant: "switcher", displayTitle: displayTitle, ...openTitle === undefined ? {} : { openTitle }, ...shared }, lineageSessionId), openTitle === undefined && (_jsx(CatalogDropdown, { rootSessionId: lineageSessionId, variant: "count", ...shared }, lineageSessionId))] }));
|
|
584
|
+
}
|
|
585
|
+
//# sourceMappingURL=SubagentHeaderLineage.js.map
|