dsh-cabinet-mode 0.7.0 → 0.7.1
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/CHANGELOG.md +9 -0
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/client.js +45 -16
- package/package.json +1 -1
- package/scripts/test-client.mjs +173 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.7.1] - 2026-11-09
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Count elapsed time for stopped members through the recorded active window end instead of letting an unclosed window grow.
|
|
10
|
+
- Keep blocker chips informational by stopping click propagation before task-row navigation.
|
|
11
|
+
- Include the lead in the team usage total and label the aggregation clearly.
|
|
12
|
+
- Verify that a ready projection load short-circuits on retry and that host-pushed frames update usage without another read.
|
|
13
|
+
|
|
5
14
|
## [0.7.0] - 2026-11-09
|
|
6
15
|
|
|
7
16
|
### Added
|
package/README.md
CHANGED
|
@@ -298,7 +298,7 @@ On failure, show the exact error. For $.format must be 1, replace the webpage so
|
|
|
298
298
|
Use this only when the market is unavailable or for local development. Fully quit desktop DSH first to release the profile lock, then install the release bundle:
|
|
299
299
|
|
|
300
300
|
```sh
|
|
301
|
-
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.7.
|
|
301
|
+
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.7.1/dsh-cabinet-mode-0.7.1.tgz
|
|
302
302
|
dsh plugin --profile desktop list
|
|
303
303
|
```
|
|
304
304
|
|
|
@@ -313,7 +313,7 @@ the same install command with the new version URL (or pick the new `.tgz` in the
|
|
|
313
313
|
plugin page), then fully quit and restart DeepSeek Harness:
|
|
314
314
|
|
|
315
315
|
```sh
|
|
316
|
-
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.7.
|
|
316
|
+
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.7.1/dsh-cabinet-mode-0.7.1.tgz
|
|
317
317
|
```
|
|
318
318
|
|
|
319
319
|
`dsh plugin --profile desktop list` should report the new version. Upgrades were
|
package/README.zh.md
CHANGED
|
@@ -229,7 +229,7 @@ https://raw.githubusercontent.com/luodaoyi/dsh-cabinet-mode/market-index/marketp
|
|
|
229
229
|
仅在商店不可用或本地开发时使用。先完全退出桌面 DSH,释放 profile 锁,再执行:
|
|
230
230
|
|
|
231
231
|
```sh
|
|
232
|
-
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.7.
|
|
232
|
+
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.7.1/dsh-cabinet-mode-0.7.1.tgz
|
|
233
233
|
dsh plugin --profile desktop list
|
|
234
234
|
```
|
|
235
235
|
|
|
@@ -240,7 +240,7 @@ dsh plugin --profile desktop list
|
|
|
240
240
|
若通过插件市场安装:刷新市场,先在**已安装**页卸载旧版本,再从**插件市场**安装新版本,然后重启——没有 tgz URL 要换,也没有一键更新。否则用同一条安装命令换新版本 URL(或在插件页选新 `.tgz`),然后完全退出并重启 DeepSeek Harness:
|
|
241
241
|
|
|
242
242
|
```sh
|
|
243
|
-
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.7.
|
|
243
|
+
dsh plugin --profile desktop add https://github.com/luodaoyi/dsh-cabinet-mode/releases/download/v0.7.1/dsh-cabinet-mode-0.7.1.tgz
|
|
244
244
|
```
|
|
245
245
|
|
|
246
246
|
`dsh plugin --profile desktop list` 应显示新版本。升级已在 Windows 实测:
|
package/client.js
CHANGED
|
@@ -2587,9 +2587,17 @@ window.__ModuleLoader__.load({
|
|
|
2587
2587
|
let cabinetSessions = null;
|
|
2588
2588
|
const cabinetSessionsListeners = new Set();
|
|
2589
2589
|
/**
|
|
2590
|
-
*
|
|
2591
|
-
*
|
|
2592
|
-
*
|
|
2590
|
+
* Bounded retry/re-render cadence for member usage while somebody runs.
|
|
2591
|
+
*
|
|
2592
|
+
* `refreshProjections` is NOT a polling read: the client manager returns the
|
|
2593
|
+
* in-flight promise while a load runs and resolves immediately once that
|
|
2594
|
+
* session's projections are `ready`
|
|
2595
|
+
* (dsh-api-session-controller/lib/types/client/sessions/manager.js:268-272),
|
|
2596
|
+
* so one connection really reads a session once. Later changes arrive as
|
|
2597
|
+
* Host frames — `ctx.sessionProjections.onChanged` → control stream
|
|
2598
|
+
* (lib/types/control.js:9-19) — and land in the projection store the panel
|
|
2599
|
+
* already subscribes to. The 5s tick therefore only re-renders the elapsed
|
|
2600
|
+
* clock; it neither re-reads the store nor spends any model token.
|
|
2593
2601
|
*/
|
|
2594
2602
|
const PROJECTION_REFRESH_MS = 5000;
|
|
2595
2603
|
/**
|
|
@@ -2977,9 +2985,10 @@ window.__ModuleLoader__.load({
|
|
|
2977
2985
|
});
|
|
2978
2986
|
}
|
|
2979
2987
|
|
|
2980
|
-
function Chip({ color, children, title }) {
|
|
2988
|
+
function Chip({ color, children, title, onClick }) {
|
|
2981
2989
|
return h('span', {
|
|
2982
2990
|
title,
|
|
2991
|
+
onClick,
|
|
2983
2992
|
style: {
|
|
2984
2993
|
display: 'inline-flex',
|
|
2985
2994
|
alignItems: 'center',
|
|
@@ -3125,7 +3134,7 @@ window.__ModuleLoader__.load({
|
|
|
3125
3134
|
* optional: a missing projection yields undefined (the card prints its dash),
|
|
3126
3135
|
* and a missing contextWindow keeps the token numbers but drops the ratio.
|
|
3127
3136
|
*/
|
|
3128
|
-
function usageFor(values, now) {
|
|
3137
|
+
function usageFor(values, now, running) {
|
|
3129
3138
|
const source = values !== undefined && values !== null && typeof values === 'object' ? values : {};
|
|
3130
3139
|
const tokens = tokenTotalOf(source.tokenUsage?.totals ?? source.tokenUsage);
|
|
3131
3140
|
let elapsedMs;
|
|
@@ -3134,8 +3143,14 @@ window.__ModuleLoader__.load({
|
|
|
3134
3143
|
const settled = typeof timing.settledMs === 'number' && Number.isFinite(timing.settledMs) ? timing.settledMs : 0;
|
|
3135
3144
|
const active = timing.active;
|
|
3136
3145
|
if (active !== undefined && active !== null && typeof active.since === 'number' && Number.isFinite(active.since)) {
|
|
3146
|
+
// Native parity (subagent catalog): a running turn ends at "now", an
|
|
3147
|
+
// inactive one at `active.through` — otherwise an unclosed active
|
|
3148
|
+
// window keeps growing while nobody is working.
|
|
3137
3149
|
const clock = typeof now === 'number' && Number.isFinite(now) ? now : active.since;
|
|
3138
|
-
|
|
3150
|
+
const end = running !== false
|
|
3151
|
+
? clock
|
|
3152
|
+
: (typeof active.through === 'number' && Number.isFinite(active.through) ? active.through : active.since);
|
|
3153
|
+
elapsedMs = settled + Math.max(0, end - active.since);
|
|
3139
3154
|
} else if (typeof timing.settledMs === 'number' && Number.isFinite(timing.settledMs)) {
|
|
3140
3155
|
elapsedMs = settled;
|
|
3141
3156
|
}
|
|
@@ -3370,7 +3385,9 @@ window.__ModuleLoader__.load({
|
|
|
3370
3385
|
...(openBlockers ? blockers.map((id) => {
|
|
3371
3386
|
const blocker = blockerOf(id);
|
|
3372
3387
|
const c = blocker ? (TASK_COLOR[blocker.status] || TASK_COLOR.pending) : 'rgba(127,127,127,.5)';
|
|
3373
|
-
|
|
3388
|
+
// A blocker chip is information, not navigation: stop the click so
|
|
3389
|
+
// the task row's opener does not fire when a chip is clicked.
|
|
3390
|
+
return h(Chip, { key: id, color: c, title: blocker ? blocker.subject : id, onClick: (event) => stopPropagation(event) }, [
|
|
3374
3391
|
h('span', { key: 'd', style: { width: 6, height: 6, borderRadius: '50%', background: c, flex: 'none' } }),
|
|
3375
3392
|
h('span', { key: 't', style: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, id)
|
|
3376
3393
|
]);
|
|
@@ -3864,13 +3881,24 @@ window.__ModuleLoader__.load({
|
|
|
3864
3881
|
const lead = members.find((member) => member.role === 'lead');
|
|
3865
3882
|
const leadShown = lead ?? { id: sessionId, name: 'lead', role: 'lead', phase: 'active' };
|
|
3866
3883
|
const mates = members.filter((member) => member.role !== 'lead');
|
|
3867
|
-
// Usage hooks stay above the empty-team return.
|
|
3868
|
-
//
|
|
3869
|
-
//
|
|
3884
|
+
// Usage hooks stay above the empty-team return.
|
|
3885
|
+
//
|
|
3886
|
+
// The numbers move because the Host pushes projection frames
|
|
3887
|
+
// (`sessionProjections.onChanged` → control stream, control.js:9-19) into
|
|
3888
|
+
// the store read by useSessions — NOT because this panel re-reads them:
|
|
3889
|
+
// `refreshProjections` really reads a session once and resolves without
|
|
3890
|
+
// reading once that load is `ready` (manager.js:268-272). What is left for
|
|
3891
|
+
// this panel is (a) one ensure call per member the first time we see it,
|
|
3892
|
+
// (b) a bounded retry for a session that never loaded or just changed
|
|
3893
|
+
// state, and (c) a 5s re-render so the elapsed clock advances.
|
|
3870
3894
|
const [usageTick, setUsageTick] = React.useState(0);
|
|
3871
3895
|
const usageNow = Date.now();
|
|
3872
3896
|
const usageOfMember = (member) => (member !== undefined && member !== null && typeof member.id === 'string' && member.id !== '')
|
|
3873
|
-
? usageFor(
|
|
3897
|
+
? usageFor(
|
|
3898
|
+
projections !== undefined && projections !== null ? projections[member.id]?.values : undefined,
|
|
3899
|
+
usageNow,
|
|
3900
|
+
runningOf(member.id)
|
|
3901
|
+
)
|
|
3874
3902
|
: null;
|
|
3875
3903
|
const leadUsage = usageOfMember(leadShown);
|
|
3876
3904
|
const mateUsages = mates.map((member) => usageOfMember(member));
|
|
@@ -3905,8 +3933,9 @@ window.__ModuleLoader__.load({
|
|
|
3905
3933
|
if (!due) continue;
|
|
3906
3934
|
const record = {live, at: Date.now(), pending: true};
|
|
3907
3935
|
states.set(id, record);
|
|
3908
|
-
//
|
|
3909
|
-
//
|
|
3936
|
+
// Ensure/retry only: the first call per member really reads; a `ready`
|
|
3937
|
+
// session resolves without reading, so this is not a re-read loop.
|
|
3938
|
+
// Live updates arrive through useSessions (host push frames).
|
|
3910
3939
|
try { Promise.resolve(usageService.refreshProjections(id)).catch(() => {}).finally(() => { record.pending = false; if (record.retry && !states.disposed) { states.delete(id); setUsageTick(tick => tick + 1); } }); }
|
|
3911
3940
|
catch (_) { record.pending = false; }
|
|
3912
3941
|
}
|
|
@@ -3980,7 +4009,7 @@ window.__ModuleLoader__.load({
|
|
|
3980
4009
|
t: tt,
|
|
3981
4010
|
onOpen: openMemberSession,
|
|
3982
4011
|
usage: leadUsage,
|
|
3983
|
-
teamUsage: teamUsageOf(mateUsages)
|
|
4012
|
+
teamUsage: teamUsageOf([leadUsage, ...mateUsages])
|
|
3984
4013
|
});
|
|
3985
4014
|
|
|
3986
4015
|
// Cells: every minister first, then 未分派 / 首辅自办 / 不在册 as
|
|
@@ -4641,7 +4670,7 @@ window.__ModuleLoader__.load({
|
|
|
4641
4670
|
'usage.tokens': 'token',
|
|
4642
4671
|
'usage.elapsed': '耗时',
|
|
4643
4672
|
'usage.context': '上下文',
|
|
4644
|
-
'usage.team': '
|
|
4673
|
+
'usage.team': '团队合计(含首辅)',
|
|
4645
4674
|
'usage.none': '—',
|
|
4646
4675
|
'task.leadOwn': '首辅自办',
|
|
4647
4676
|
'task.waits': '等待',
|
|
@@ -4734,7 +4763,7 @@ window.__ModuleLoader__.load({
|
|
|
4734
4763
|
'usage.tokens': 'tokens',
|
|
4735
4764
|
'usage.elapsed': 'elapsed',
|
|
4736
4765
|
'usage.context': 'context',
|
|
4737
|
-
'usage.team': 'team',
|
|
4766
|
+
'usage.team': 'team total (incl. lead)',
|
|
4738
4767
|
'usage.none': '—',
|
|
4739
4768
|
'task.leadOwn': 'lead-owned',
|
|
4740
4769
|
'task.waits': 'blocked by',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cabinet-mode",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Cabinet Mode (内阁模式) for DeepSeek Harness: a declarative DSH bundle that adds a dual-identity Lead/teammate agent preset for the Great Ming Research Bureau cabinet team.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"icon": "./icon.svg",
|
package/scripts/test-client.mjs
CHANGED
|
@@ -20,9 +20,19 @@ const React = {
|
|
|
20
20
|
useId: () => 'test-mask',
|
|
21
21
|
createElement: (type, props, ...children) => ({ type, props, children }),
|
|
22
22
|
useRef: () => ({ current: null }),
|
|
23
|
-
|
|
23
|
+
// Persistent state is opt-in like useRef: only the re-render chain test needs
|
|
24
|
+
// a setter that really changes the value the next render reads.
|
|
25
|
+
useState: (initial) => {
|
|
26
|
+
const value = typeof initial === 'function' ? initial() : initial;
|
|
27
|
+
if (persistentRefs === null) return [value, () => {}];
|
|
28
|
+
const index = hookStates.cursor++;
|
|
29
|
+
if (!(index in hookStates.slots)) hookStates.slots[index] = value;
|
|
30
|
+
return [hookStates.slots[index], (next) => {
|
|
31
|
+
hookStates.slots[index] = typeof next === 'function' ? next(hookStates.slots[index]) : next;
|
|
32
|
+
}];
|
|
33
|
+
},
|
|
24
34
|
useCallback: (callback) => callback,
|
|
25
|
-
useLayoutEffect: () => {}, useEffect: (fn) => { recordedEffects.push(fn); },
|
|
35
|
+
useLayoutEffect: () => {}, useEffect: (fn, deps) => { recordedEffects.push({ fn, deps }); },
|
|
26
36
|
};
|
|
27
37
|
// The panel decides whether to mount its usage ticker; the spy observes the real
|
|
28
38
|
// setInterval/clearInterval call the component makes (not a proxy assertion).
|
|
@@ -39,7 +49,13 @@ class RealmDate extends Date {
|
|
|
39
49
|
// renders of one component). Opt-in only: while `persistentRefs` is null every
|
|
40
50
|
// render keeps the fresh-ref default, so no other harness changes behaviour.
|
|
41
51
|
let persistentRefs = null;
|
|
42
|
-
const
|
|
52
|
+
const hookStates = { cursor: 0, slots: [] };
|
|
53
|
+
const resetHookCursor = () => {
|
|
54
|
+
if (persistentRefs !== null) {
|
|
55
|
+
persistentRefs.cursor = 0;
|
|
56
|
+
hookStates.cursor = 0;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
43
59
|
React.useRef = (initial) => {
|
|
44
60
|
if (persistentRefs === null) return { current: initial };
|
|
45
61
|
const index = persistentRefs.cursor++;
|
|
@@ -547,6 +563,10 @@ assert.deepEqual(Array.from(full.context.segments, (segment) => segment.key), ['
|
|
|
547
563
|
assert.deepEqual(Array.from(full.context.segments, (segment) => Math.round(segment.ratio * 100)), [20, 60, 20], 'segments follow the projection breakdown');
|
|
548
564
|
const settledOnly = client.usageFor({ ...fullValues, subagentTiming: { settledMs: 42000 } }, 112000);
|
|
549
565
|
assert.equal(settledOnly.elapsedMs, 42000, 'an inactive member shows settledMs');
|
|
566
|
+
const closedActive = client.usageFor({ subagentTiming: { settledMs: 5000, active: { since: 100000, through: 180000 } } }, 112000, false);
|
|
567
|
+
assert.equal(closedActive.elapsedMs, 85000, 'an inactive member ends the active window at active.through, not at now (native parity)');
|
|
568
|
+
const openActive = client.usageFor({ subagentTiming: { settledMs: 5000, active: { since: 100000, through: 180000 } } }, 112000, true);
|
|
569
|
+
assert.equal(openActive.elapsedMs, 17000, 'a running member keeps counting to now');
|
|
550
570
|
const noWindow = client.usageFor({ contextPressure: { projectedTokens: 120000 }, contextBreakdown: { systemTokens: 1 } }, 0);
|
|
551
571
|
assert.equal(noWindow.context.percent, undefined, 'no contextWindow → no ratio, numbers only');
|
|
552
572
|
assert.deepEqual(noWindow.context.segments.length, 1, 'breakdown still renders without a window');
|
|
@@ -614,17 +634,165 @@ const usagePanel = elements(client.CabinetPanel({
|
|
|
614
634
|
sessionId: 'lead-session',
|
|
615
635
|
useSession: (select) => select({}),
|
|
616
636
|
useSessions: (select) => select({ projectionsBySession: {
|
|
617
|
-
'lead-session': { values: { agentTeam: { members: [{ id: 'm-works', name: 'works', role: 'mate', phase: 'active' }], tasks: [] } } },
|
|
637
|
+
'lead-session': { values: { tokenUsage: { outputTokens: 1000 }, agentTeam: { members: [{ id: 'm-works', name: 'works', role: 'mate', phase: 'active' }], tasks: [] } } },
|
|
618
638
|
'm-works': { values: { tokenUsage: { outputTokens: 2000 }, subagentTiming: { settledMs: 42000 } } },
|
|
619
639
|
} }),
|
|
620
640
|
useSessionStatus: (select) => select(new Map()),
|
|
621
641
|
t: (key) => client.zh[key] || key,
|
|
622
642
|
}));
|
|
623
643
|
assert.ok(elements(usagePanel).some((node) => node.props?.key === 'usage'), 'the panel hands projections to the member cards');
|
|
644
|
+
const panelTeam = elements(usagePanel)
|
|
645
|
+
.filter((node) => node.props?.key === 'usage')
|
|
646
|
+
.map((node) => JSON.stringify(node))
|
|
647
|
+
.find((text) => text.includes(client.zh['usage.team']));
|
|
648
|
+
assert.ok(panelTeam, 'the lead card renders a team total');
|
|
649
|
+
assert.ok(panelTeam.includes(client.zh['usage.team'] + ' 3K'), 'the team total includes the lead itself (1K lead + 2K mate)');
|
|
650
|
+
|
|
651
|
+
// A blocker chip is information, not navigation: it must stop the click before
|
|
652
|
+
// the task row's opener runs.
|
|
653
|
+
const chipOpenLog = [];
|
|
654
|
+
const chipLine = client.TaskLine({
|
|
655
|
+
task: { id: 't-chip', subject: 'rows', ownerName: 'works', status: 'pending', blockedBy: ['t-blocker'] },
|
|
656
|
+
blockerOf: (id) => (id === 't-blocker' ? { subject: 'upstream work', status: 'pending' } : undefined),
|
|
657
|
+
t: (key) => key,
|
|
658
|
+
taskLabel: (status) => status,
|
|
659
|
+
onOpenOwner: (task) => { chipOpenLog.push(task); return true; },
|
|
660
|
+
});
|
|
661
|
+
const chipNode = elements(chipLine).find((node) => node.props?.title === 'upstream work');
|
|
662
|
+
assert.ok(chipNode, 'the blocker chip renders');
|
|
663
|
+
assert.equal(typeof chipNode.props.onClick, 'function', 'a blocker chip is its own click target');
|
|
664
|
+
const chipEvent = { stopped: false, stopPropagation() { this.stopped = true; } };
|
|
665
|
+
chipNode.props.onClick(chipEvent);
|
|
666
|
+
assert.equal(chipEvent.stopped, true, 'the chip stops the click so the task row does not navigate');
|
|
667
|
+
assert.deepEqual(chipOpenLog, [], 'clicking a blocker chip never opens the owner session');
|
|
668
|
+
|
|
669
|
+
// Facts: refreshProjections reads a session once and resolves without reading
|
|
670
|
+
// once that load is `ready` (manager.js:268-272); later changes come from Host
|
|
671
|
+
// pushed frames (control.js:9-19) into the store the panel renders from.
|
|
672
|
+
// React semantics for the double: an effect whose deps array is shallow-equal
|
|
673
|
+
// to the previous render's deps does not run again (the panel's request-state
|
|
674
|
+
// reset effect must not wipe its Map on every unrelated re-render).
|
|
675
|
+
const depSlots = [];
|
|
676
|
+
const sameDeps = (a, b) => Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((value, index) => Object.is(value, b[index]));
|
|
677
|
+
const factsRunEffects = () => {
|
|
678
|
+
const queued = recordedEffects.splice(0, recordedEffects.length);
|
|
679
|
+
const cleanups = [];
|
|
680
|
+
let index = 0;
|
|
681
|
+
for (const entry of queued) {
|
|
682
|
+
const previous = depSlots[index];
|
|
683
|
+
if (previous !== undefined && sameDeps(previous.deps, entry.deps)) {
|
|
684
|
+
if (typeof previous.cleanup === 'function') cleanups.push(previous.cleanup);
|
|
685
|
+
index += 1;
|
|
686
|
+
continue;
|
|
687
|
+
}
|
|
688
|
+
const cleanup = entry.fn();
|
|
689
|
+
depSlots[index] = { deps: entry.deps, cleanup };
|
|
690
|
+
if (typeof cleanup === 'function') cleanups.push(cleanup);
|
|
691
|
+
index += 1;
|
|
692
|
+
}
|
|
693
|
+
depSlots.length = index;
|
|
694
|
+
return () => { for (const cleanup of cleanups) cleanup(); };
|
|
695
|
+
};
|
|
696
|
+
const factsCalls = [];
|
|
697
|
+
const factsReads = [];
|
|
698
|
+
const factsReady = new Set();
|
|
699
|
+
const factsSessions = {
|
|
700
|
+
refreshProjections: (id) => {
|
|
701
|
+
factsCalls.push(id);
|
|
702
|
+
if (factsReady.has(id)) return Promise.resolve(); // ready → short circuit, no read
|
|
703
|
+
factsReady.add(id);
|
|
704
|
+
factsReads.push(id);
|
|
705
|
+
return Promise.resolve();
|
|
706
|
+
},
|
|
707
|
+
};
|
|
708
|
+
client.apply({
|
|
709
|
+
locale: { register: () => {}, bind: () => (key) => key },
|
|
710
|
+
effect: (fn) => { try { return fn(); } catch (error) { return undefined; } },
|
|
711
|
+
inject: (names, callback) => {
|
|
712
|
+
if (Array.isArray(names) && names.includes('sessions')) callback({ sessions: factsSessions, effect: (fn) => { try { return fn(); } catch (error) { return undefined; } } });
|
|
713
|
+
},
|
|
714
|
+
});
|
|
715
|
+
const factsPanel = (mateTokens, extra) => elements(client.CabinetPanel({
|
|
716
|
+
sessionId: 'lead-session',
|
|
717
|
+
useSession: (select) => select({}),
|
|
718
|
+
useSessions: (select) => select({ projectionsBySession: {
|
|
719
|
+
'lead-session': { values: { tokenUsage: { outputTokens: 1000 }, agentTeam: { members: [
|
|
720
|
+
{ id: 'm-works', name: 'works', role: 'mate', phase: 'active' },
|
|
721
|
+
...((extra && extra.members) || []),
|
|
722
|
+
], tasks: [] } } },
|
|
723
|
+
'm-works': { values: { tokenUsage: { outputTokens: mateTokens } } },
|
|
724
|
+
} }),
|
|
725
|
+
useSessionStatus: (select) => select(new Map((extra && extra.status) || [['m-works', { running: true }]])),
|
|
726
|
+
t: (key) => client.zh[key] || key,
|
|
727
|
+
}));
|
|
728
|
+
const factsUsageText = (nodes) => nodes
|
|
729
|
+
.filter((node) => node.props?.key === 'usage')
|
|
730
|
+
.map((node) => JSON.stringify(node))
|
|
731
|
+
.join('|');
|
|
732
|
+
|
|
733
|
+
clockState.now = 2000000;
|
|
734
|
+
recordedEffects.length = 0;
|
|
735
|
+
persistentRefs = { cursor: 0, slots: [] };
|
|
736
|
+
factsCalls.length = 0; factsReads.length = 0; factsReady.clear();
|
|
737
|
+
resetHookCursor();
|
|
738
|
+
const factsFirst = factsPanel(2000);
|
|
739
|
+
const factsStop = factsRunEffects();
|
|
740
|
+
assert.deepEqual(Array.from(factsReads).sort(), ['lead-session', 'm-works'], 'the first pass ensures every member once (an idle one included)');
|
|
741
|
+
assert.ok(factsUsageText(factsFirst).includes(' 2K'), 'the first read paints the member total');
|
|
742
|
+
const factsCallsAfterFirst = factsCalls.length;
|
|
743
|
+
const factsReadsAfterFirst = factsReads.length;
|
|
744
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
745
|
+
|
|
746
|
+
// One 5s tick: the bounded retry asks again, but the manager is `ready`, so
|
|
747
|
+
// nothing is read. This is the fact the old "every 5s re-read" story got wrong.
|
|
748
|
+
clockState.now += 5001;
|
|
749
|
+
intervalSpy.lastTimer.fn();
|
|
750
|
+
resetHookCursor();
|
|
751
|
+
factsPanel(2000);
|
|
752
|
+
factsRunEffects();
|
|
753
|
+
// The tick re-renders on the retry cadence; whatever it does, it must not read
|
|
754
|
+
// the session again — that is the ready short-circuit this suite used to miss.
|
|
755
|
+
assert.deepEqual(factsCalls.slice(factsCallsAfterFirst), ['m-works'], 'a tick retries only the running member');
|
|
756
|
+
assert.equal(factsReads.length, factsReadsAfterFirst, 'no re-read after a tick: the ready load short-circuits (manager.js:268-272)');
|
|
757
|
+
|
|
758
|
+
// A Host push frame changes the store the panel renders from: the number moves
|
|
759
|
+
// with no further read and no further ensure call.
|
|
760
|
+
clockState.now += 1000;
|
|
761
|
+
const factsCallsBeforePush = factsCalls.length;
|
|
762
|
+
resetHookCursor();
|
|
763
|
+
const factsPushed = factsPanel(5000);
|
|
764
|
+
factsRunEffects();
|
|
765
|
+
assert.ok(factsUsageText(factsPushed).includes(' 5K'), 'a Host-pushed projection frame updates the card to the new total');
|
|
766
|
+
assert.ok(!factsUsageText(factsPushed).includes(' 2K'), 'the card shows the pushed value, not the stale one');
|
|
767
|
+
assert.equal(factsReads.length, factsReadsAfterFirst, 'the update came from the push, not from re-reading the session');
|
|
768
|
+
assert.equal(factsCalls.length, factsCallsBeforePush, 'a push never re-reads or re-requests on its own');
|
|
769
|
+
factsStop();
|
|
770
|
+
|
|
771
|
+
// An idle member is ensured once when the panel first sees it (never-loaded
|
|
772
|
+
// stores get filled), then not re-requested inside the window.
|
|
773
|
+
factsCalls.length = 0; factsReads.length = 0; factsReady.clear();
|
|
774
|
+
clockState.now = 3000000;
|
|
775
|
+
recordedEffects.length = 0;
|
|
776
|
+
persistentRefs = { cursor: 0, slots: [] };
|
|
777
|
+
const idleFacts = () => factsPanel(2000, {
|
|
778
|
+
members: [{ id: 'm-dali', name: 'dali', role: 'mate', phase: 'active' }],
|
|
779
|
+
status: [['m-works', { running: true }]],
|
|
780
|
+
});
|
|
781
|
+
resetHookCursor();
|
|
782
|
+
idleFacts();
|
|
783
|
+
const idleStop = factsRunEffects();
|
|
784
|
+
assert.ok(factsCalls.includes('m-dali'), 'an idle, never-loaded member still gets one ensure call');
|
|
785
|
+
resetHookCursor();
|
|
786
|
+
clockState.now += 1000;
|
|
787
|
+
idleFacts();
|
|
788
|
+
factsRunEffects();
|
|
789
|
+
assert.equal(factsCalls.filter((id) => id === 'm-dali').length, 1, 'an idle member is not re-requested inside the window');
|
|
790
|
+
idleStop();
|
|
791
|
+
persistentRefs = null;
|
|
624
792
|
|
|
625
793
|
// Stateful lifecycle, initial/settled loads and timer cleanup are exercised
|
|
626
794
|
// with real React DOM by scripts/test-panel-browser.mjs, not this hook double.
|
|
627
|
-
console.log('PASS: member usage formatting, missing data and
|
|
795
|
+
console.log('PASS: member usage formatting, missing data, throttle helpers, active.through parity, blocker chips that do not navigate, team total including the lead, and the projection facts — a ready load short-circuits (the retry call reads nothing) while a Host push frame updates the card without another read; lifecycle is tested separately with real React DOM');
|
|
628
796
|
console.log('PASS: task dependency edges — data attributes, three states, missing-blocker tolerance, reduced-motion CSS, geometry refresh gate');
|
|
629
797
|
|
|
630
798
|
// IDs are opaque; delimiter-bearing pairs must not collide or inject markup.
|