dsh-better-display 0.3.8 → 0.3.10
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 +11 -0
- package/DESIGN.md +43 -3
- package/README.en.md +10 -2
- package/README.md +10 -2
- package/compat/harness-rc2.json +17 -13
- package/docs/dependency-update-policy.md +9 -0
- package/docs/extension-points.md +172 -0
- package/docs/official-rendering-bridge.md +49 -20
- package/docs/openapi.yaml +147 -0
- package/docs/runbooks/blank-reader.md +39 -0
- package/lib/client.js +1802 -872
- package/lib/client.js.map +1 -1
- package/lib/dsh-better-display.js +376 -151
- package/lib/types/client/AssistantNode.d.ts +20 -0
- package/lib/types/client/AssistantNode.d.ts.map +1 -0
- package/lib/types/client/AssistantNode.js +46 -0
- package/lib/types/client/AssistantNode.js.map +1 -0
- package/lib/types/client/Blocks.d.ts.map +1 -1
- package/lib/types/client/Blocks.js +33 -10
- package/lib/types/client/Blocks.js.map +1 -1
- package/lib/types/client/ChoreographedFlow.d.ts.map +1 -1
- package/lib/types/client/ChoreographedFlow.js +2 -0
- package/lib/types/client/ChoreographedFlow.js.map +1 -1
- package/lib/types/client/ClosedProcessSummary.d.ts.map +1 -1
- package/lib/types/client/ClosedProcessSummary.js +3 -1
- package/lib/types/client/ClosedProcessSummary.js.map +1 -1
- package/lib/types/client/McpAppFrame.d.ts.map +1 -1
- package/lib/types/client/McpAppFrame.js +5 -11
- package/lib/types/client/McpAppFrame.js.map +1 -1
- package/lib/types/client/OfficialContent.d.ts +17 -3
- package/lib/types/client/OfficialContent.d.ts.map +1 -1
- package/lib/types/client/OfficialContent.js +37 -12
- package/lib/types/client/OfficialContent.js.map +1 -1
- package/lib/types/client/Reader.d.ts.map +1 -1
- package/lib/types/client/Reader.js +45 -77
- package/lib/types/client/Reader.js.map +1 -1
- package/lib/types/client/SettingsSection.d.ts.map +1 -1
- package/lib/types/client/SettingsSection.js +0 -5
- package/lib/types/client/SettingsSection.js.map +1 -1
- package/lib/types/client/StickyLane.d.ts +12 -0
- package/lib/types/client/StickyLane.d.ts.map +1 -1
- package/lib/types/client/StickyLane.js +78 -2
- package/lib/types/client/StickyLane.js.map +1 -1
- package/lib/types/client/ToolActivity.js.map +1 -1
- package/lib/types/client/index.d.ts +3 -1
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +6 -0
- package/lib/types/client/index.js.map +1 -1
- package/lib/types/client/live-turn.d.ts +17 -5
- package/lib/types/client/live-turn.d.ts.map +1 -1
- package/lib/types/client/live-turn.js +106 -76
- package/lib/types/client/live-turn.js.map +1 -1
- package/lib/types/client/motion.d.ts +26 -2
- package/lib/types/client/motion.d.ts.map +1 -1
- package/lib/types/client/motion.js +136 -10
- package/lib/types/client/motion.js.map +1 -1
- package/lib/types/client/official-slots.d.ts +24 -3
- package/lib/types/client/official-slots.d.ts.map +1 -1
- package/lib/types/client/official-slots.js +59 -11
- package/lib/types/client/official-slots.js.map +1 -1
- package/lib/types/client/primitive-labels.d.ts.map +1 -1
- package/lib/types/client/primitive-labels.js +1 -0
- package/lib/types/client/primitive-labels.js.map +1 -1
- package/lib/types/client/projection.d.ts +15 -2
- package/lib/types/client/projection.d.ts.map +1 -1
- package/lib/types/client/projection.js +16 -4
- package/lib/types/client/projection.js.map +1 -1
- package/lib/types/client/rewind-cut.d.ts +131 -0
- package/lib/types/client/rewind-cut.d.ts.map +1 -0
- package/lib/types/client/rewind-cut.js +321 -0
- package/lib/types/client/rewind-cut.js.map +1 -0
- package/lib/types/client/text-transform.d.ts +93 -0
- package/lib/types/client/text-transform.d.ts.map +1 -0
- package/lib/types/client/text-transform.js +183 -0
- package/lib/types/client/text-transform.js.map +1 -0
- package/lib/types/client/timeline.d.ts.map +1 -1
- package/lib/types/client/timeline.js.map +1 -1
- package/lib/types/client/tool-activity.d.ts +9 -2
- package/lib/types/client/tool-activity.d.ts.map +1 -1
- package/lib/types/client/tool-activity.js +42 -2
- package/lib/types/client/tool-activity.js.map +1 -1
- package/lib/types/client/turn-slots.d.ts +29 -0
- package/lib/types/client/turn-slots.d.ts.map +1 -0
- package/lib/types/client/turn-slots.js +62 -0
- package/lib/types/client/turn-slots.js.map +1 -0
- package/lib/types/client/types.d.ts +18 -0
- package/lib/types/client/types.d.ts.map +1 -1
- package/lib/types/dsh-better-display.d.ts +4 -1
- package/lib/types/dsh-better-display.d.ts.map +1 -1
- package/lib/types/dsh-better-display.js +56 -7
- package/lib/types/dsh-better-display.js.map +1 -1
- package/lib/types/flags.d.ts +7 -0
- package/lib/types/flags.d.ts.map +1 -0
- package/lib/types/flags.js +37 -0
- package/lib/types/flags.js.map +1 -0
- package/lib/types/log.d.ts +17 -0
- package/lib/types/log.d.ts.map +1 -0
- package/lib/types/log.js +122 -0
- package/lib/types/log.js.map +1 -0
- package/lib/types/metrics.d.ts +18 -0
- package/lib/types/metrics.d.ts.map +1 -0
- package/lib/types/metrics.js +35 -0
- package/lib/types/metrics.js.map +1 -0
- package/package.json +55 -23
- package/scripts/changelog.mjs +20 -0
- package/scripts/check-agents-md.mjs +67 -0
- package/scripts/check-bundle-size.mjs +38 -0
- package/scripts/check-dead-flags.mjs +55 -0
- package/scripts/check-harness-compat.mjs +4 -2
- package/scripts/check-todo-debt.mjs +69 -0
- package/scripts/link-harness-dependencies.mjs +48 -11
- package/scripts/security-audit-report.mjs +92 -0
- package/scripts/verify-commentary-visible.mjs +627 -0
- package/src/client/AssistantNode.tsx +72 -0
- package/src/client/Blocks.tsx +49 -10
- package/src/client/ChoreographedFlow.tsx +3 -1
- package/src/client/ClosedProcessSummary.tsx +3 -1
- package/src/client/McpAppFrame.tsx +5 -13
- package/src/client/OfficialContent.tsx +52 -14
- package/src/client/Reader.module.css +68 -18
- package/src/client/Reader.tsx +38 -82
- package/src/client/SettingsSection.tsx +1 -7
- package/src/client/StickyLane.tsx +81 -2
- package/src/client/ToolActivity.tsx +1 -1
- package/src/client/index.tsx +8 -1
- package/src/client/live-turn.ts +100 -69
- package/src/client/motion.tsx +135 -7
- package/src/client/official-slots.tsx +61 -12
- package/src/client/primitive-labels.ts +1 -0
- package/src/client/projection.ts +16 -4
- package/src/client/rewind-cut.ts +340 -0
- package/src/client/text-transform.ts +265 -0
- package/src/client/timeline.ts +0 -2
- package/src/client/tool-activity.ts +49 -2
- package/src/client/turn-slots.ts +80 -0
- package/src/client/types.ts +19 -0
- package/src/dsh-better-display.ts +58 -7
- package/src/flags.ts +40 -0
- package/src/log.ts +137 -0
- package/src/metrics.ts +50 -0
- package/tests/browser-commentary.tsx +191 -0
- package/tests/browser-official-bridge.tsx +2 -1
- package/tests/chat-flow-hook.test.ts +1 -1
- package/tests/cloud-gate.test.ts +1 -1
- package/tests/context-tool-update.test.ts +1 -1
- package/tests/conversation-scroll.test.ts +1 -1
- package/tests/deliverables.test.ts +1 -1
- package/tests/entry.test.ts +1 -1
- package/tests/fixtures/reader-lane-owners.tsx +46 -0
- package/tests/fixtures/reader-official-users.tsx +64 -0
- package/tests/fixtures/reader-theme-overlap.html +80 -0
- package/tests/fixtures/reader-user-bubble.tsx +244 -0
- package/tests/flags.test.ts +66 -0
- package/tests/fold-choreography.test.ts +32 -8
- package/tests/fold-intensity.test.ts +11 -6
- package/tests/footer-precedence.test.ts +1 -1
- package/tests/history-word-regression.test.ts +1 -1
- package/tests/live-turn.test.ts +125 -54
- package/tests/log.test.ts +99 -0
- package/tests/mcp-apps.test.ts +1 -1
- package/tests/message-chrome.test.ts +1 -1
- package/tests/metrics.test.ts +52 -0
- package/tests/official-slots.test.ts +41 -2
- package/tests/open-file.test.ts +1 -1
- package/tests/pending-submission.test.ts +12 -1
- package/tests/pinned-selection.test.ts +16 -0
- package/tests/platform-media.test.ts +1 -1
- package/tests/projection.test.ts +66 -3
- package/tests/reader-glass-css.test.ts +1 -1
- package/tests/reader-official-users.test.ts +11 -1
- package/tests/reader-sticky-surface.test.ts +377 -0
- package/tests/reader-theme-lanes.test.ts +54 -0
- package/tests/reader-theme-overlap.test.ts +151 -0
- package/tests/reader-user-bubble.test.ts +138 -0
- package/tests/reasoning-follow.test.ts +1 -1
- package/tests/retiring-content.test.ts +98 -6
- package/tests/reveal.test.ts +3 -3
- package/tests/rewind-cut.test.ts +1090 -0
- package/tests/settings-copy.test.ts +1 -1
- package/tests/skill-status.test.ts +1 -1
- package/tests/stock-install.test.ts +11 -7
- package/tests/stream-buffer.test.ts +1 -1
- package/tests/styles.test.ts +30 -3
- package/tests/terminal-input-preview.test.ts +1 -1
- package/tests/text-transform.test.ts +272 -0
- package/tests/timeline.test.ts +1 -1
- package/tests/tool-clock.test.ts +1 -1
- package/tests/tool-diff.test.ts +1 -1
- package/tests/waiting-clock.test.ts +1 -1
- package/tests/word-timeline.test.ts +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** One turn lane: `live` while it is still in the visible order. */
|
|
2
|
+
export interface TurnSlot<T extends { readonly key: string }> {
|
|
3
|
+
readonly group: T;
|
|
4
|
+
readonly live: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Keep live turns in the incoming `groups` order, and keep a departing turn
|
|
9
|
+
* next to the live neighbour that preceded it.
|
|
10
|
+
*
|
|
11
|
+
* A rewind removes turn keys from the visible order. Unmounting them in that
|
|
12
|
+
* same commit snaps the transcript, so the lane retains the last group object
|
|
13
|
+
* until the collapse finishes. A re-render, a stream tick, or a reconnect that
|
|
14
|
+
* still contains the same keys only replaces the group object and leaves
|
|
15
|
+
* `live` true — those updates must not start a collapse. A key that returns
|
|
16
|
+
* is live again where `groups` places it. Loading older history therefore
|
|
17
|
+
* stays in transcript order instead of appending the older turns after the
|
|
18
|
+
* ones already on screen. A departing slot is inserted immediately after the
|
|
19
|
+
* nearest preceding slot that is still live, or at the front when it had none,
|
|
20
|
+
* so several departing neighbours keep their relative order.
|
|
21
|
+
*
|
|
22
|
+
* Returns `current` itself when nothing changed, so a React state update can
|
|
23
|
+
* bail out on `Object.is`.
|
|
24
|
+
*/
|
|
25
|
+
export function reconcileTurnSlots<T extends { readonly key: string }>(
|
|
26
|
+
current: readonly TurnSlot<T>[],
|
|
27
|
+
groups: readonly T[],
|
|
28
|
+
): readonly TurnSlot<T>[] {
|
|
29
|
+
const incoming = new Map(groups.map(group => [group.key, group]));
|
|
30
|
+
const next: TurnSlot<T>[] = groups.map(group => ({ group, live: true }));
|
|
31
|
+
for (const slot of current) {
|
|
32
|
+
if (incoming.has(slot.group.key)) continue;
|
|
33
|
+
insertDeparting(next, { group: slot.group, live: false }, precedingLiveKey(current, incoming, slot.group.key));
|
|
34
|
+
}
|
|
35
|
+
const same =
|
|
36
|
+
next.length === current.length &&
|
|
37
|
+
next.every(
|
|
38
|
+
(slot, index) => slot.live === current[index]!.live && slot.group === current[index]!.group,
|
|
39
|
+
);
|
|
40
|
+
return same ? current : next;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Nearest preceding slot that is still in the incoming order, if any. */
|
|
44
|
+
function precedingLiveKey<T extends { readonly key: string }>(
|
|
45
|
+
current: readonly TurnSlot<T>[],
|
|
46
|
+
incoming: ReadonlyMap<string, T>,
|
|
47
|
+
key: string,
|
|
48
|
+
): string | undefined {
|
|
49
|
+
const index = current.findIndex(slot => slot.group.key === key);
|
|
50
|
+
for (let cursor = index - 1; cursor >= 0; cursor--) {
|
|
51
|
+
const candidate = current[cursor]!.group.key;
|
|
52
|
+
if (incoming.has(candidate)) return candidate;
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Place a departing slot after `anchorKey`, or at the front when the slot had
|
|
59
|
+
* no preceding live neighbour. Slots that share an anchor keep `current` order
|
|
60
|
+
* because each one is inserted at the end of the departing run after that anchor.
|
|
61
|
+
*/
|
|
62
|
+
function insertDeparting<T extends { readonly key: string }>(
|
|
63
|
+
next: TurnSlot<T>[],
|
|
64
|
+
slot: TurnSlot<T>,
|
|
65
|
+
anchorKey: string | undefined,
|
|
66
|
+
): void {
|
|
67
|
+
if (anchorKey === undefined) {
|
|
68
|
+
const firstLive = next.findIndex(item => item.live);
|
|
69
|
+
next.splice(firstLive < 0 ? next.length : firstLive, 0, slot);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const anchorIndex = next.findIndex(item => item.group.key === anchorKey);
|
|
73
|
+
if (anchorIndex < 0) {
|
|
74
|
+
next.unshift(slot);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
let insertAt = anchorIndex + 1;
|
|
78
|
+
while (insertAt < next.length && next[insertAt]?.live === false) insertAt++;
|
|
79
|
+
next.splice(insertAt, 0, slot);
|
|
80
|
+
}
|
package/src/client/types.ts
CHANGED
|
@@ -10,10 +10,29 @@ import type { OfficialSeat } from './official-slots.js';
|
|
|
10
10
|
import type { OpenFileOptions, TurnTailOwnerProps } from '@deepseek-ai/dsh-client-ui-chat/client';
|
|
11
11
|
import type {} from '@deepseek-ai/dsh-client-ui-tool/client';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Display inputs the Reader already computed for this block.
|
|
15
|
+
* Older callers may omit the object. Registrants must tolerate that.
|
|
16
|
+
*/
|
|
17
|
+
export interface ReaderBlockPresentation {
|
|
18
|
+
/** Assistant step time, when the Reader has one. */
|
|
19
|
+
startedAt?: number;
|
|
20
|
+
/** True when this step was interrupted. */
|
|
21
|
+
interrupted?: boolean;
|
|
22
|
+
/** True when this block may run the live reveal. */
|
|
23
|
+
liveText?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
13
26
|
export interface ReaderBlockOwner {
|
|
14
27
|
block: AssistantBlock;
|
|
15
28
|
streaming: boolean;
|
|
16
29
|
source: 'assistant' | 'user' | 'tool';
|
|
30
|
+
/** Viewport and motion inputs. Absent on owners built before this field existed. */
|
|
31
|
+
presentation?: ReaderBlockPresentation;
|
|
32
|
+
/** Selection is holding Markdown formatting in place. */
|
|
33
|
+
holdFormatting?: boolean;
|
|
34
|
+
/** Same value as `presentation.liveText`, repeated so a registrant can read it directly. */
|
|
35
|
+
liveText?: boolean;
|
|
17
36
|
}
|
|
18
37
|
|
|
19
38
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import { loadFlags, type Flags } from './flags.js';
|
|
4
|
+
import { createLogger, requestIdOf } from './log.js';
|
|
5
|
+
import { metricsPayload, recordRouteDuration, recordRouteHit, ROUTE_METRICS, ROUTE_REVEAL, ROUTE_SKILL_STATUS } from './metrics.js';
|
|
6
|
+
import { createRevealHandler, revealRoots } from './reveal.js';
|
|
3
7
|
import { scanGenerativeMcpappsStatus } from './skill-roots.js';
|
|
4
8
|
import { skillsFromListResult, toPublicSkillStatus } from './skill-status.js';
|
|
5
|
-
import { createRevealHandler, revealRoots } from './reveal.js';
|
|
6
9
|
|
|
7
10
|
declare module '@deepseek-ai/cordis' {
|
|
8
11
|
interface Context {
|
|
@@ -19,6 +22,8 @@ declare module '@deepseek-ai/cordis' {
|
|
|
19
22
|
export const name = 'dsh-better-display';
|
|
20
23
|
export const inject = ['webServer'];
|
|
21
24
|
|
|
25
|
+
const log = createLogger({ base: { plugin: name } });
|
|
26
|
+
|
|
22
27
|
function writeJson(res: ServerResponse, status: number, body: unknown): void {
|
|
23
28
|
res.setHeader('Content-Type', 'application/json');
|
|
24
29
|
res.statusCode = status;
|
|
@@ -31,20 +36,48 @@ function skillLister(ctx: Context): (() => Promise<readonly { readonly name?: st
|
|
|
31
36
|
return async () => skillsFromListResult(await skills.list!({}));
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
function beginRequest(req: IncomingMessage, res: ServerResponse, route: string): string {
|
|
40
|
+
const requestId = requestIdOf(req);
|
|
41
|
+
res.setHeader('X-Request-ID', requestId);
|
|
42
|
+
recordRouteHit(route);
|
|
43
|
+
const started = performance.now();
|
|
44
|
+
res.on('finish', () => {
|
|
45
|
+
recordRouteDuration(route, performance.now() - started);
|
|
46
|
+
});
|
|
47
|
+
log.info('http request', {
|
|
48
|
+
requestId,
|
|
49
|
+
route,
|
|
50
|
+
method: req.method ?? '',
|
|
51
|
+
url: req.url ?? '',
|
|
52
|
+
headers: req.headers,
|
|
53
|
+
});
|
|
54
|
+
return requestId;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function apply(ctx: Context, options?: { readonly flags?: Flags }): void {
|
|
58
|
+
const flags = options?.flags ?? loadFlags();
|
|
59
|
+
log.info('[my-plugins/dsh-better-display] loaded', { readerEnabled: flags.readerEnabled });
|
|
60
|
+
if (!flags.readerEnabled) {
|
|
61
|
+
log.info('route registration skipped', { readerEnabled: false });
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
36
64
|
|
|
37
65
|
if (ctx.webServer) {
|
|
38
66
|
ctx.effect(() => {
|
|
67
|
+
const reveal = createRevealHandler({ roots: sessionId => revealRoots(ctx, sessionId) });
|
|
39
68
|
const disposeReveal = ctx.webServer!.register({
|
|
40
69
|
kind: 'exact',
|
|
41
|
-
path:
|
|
42
|
-
handler:
|
|
70
|
+
path: ROUTE_REVEAL,
|
|
71
|
+
handler: (req, res) => {
|
|
72
|
+
beginRequest(req, res, ROUTE_REVEAL);
|
|
73
|
+
reveal(req, res);
|
|
74
|
+
},
|
|
43
75
|
});
|
|
44
76
|
const disposeSkill = ctx.webServer!.register({
|
|
45
77
|
kind: 'exact',
|
|
46
|
-
path:
|
|
78
|
+
path: ROUTE_SKILL_STATUS,
|
|
47
79
|
handler: async (req, res) => {
|
|
80
|
+
const requestId = beginRequest(req, res, ROUTE_SKILL_STATUS);
|
|
48
81
|
if (req.method !== 'GET') {
|
|
49
82
|
res.statusCode = 405;
|
|
50
83
|
res.end();
|
|
@@ -59,14 +92,32 @@ export function apply(ctx: Context): void {
|
|
|
59
92
|
});
|
|
60
93
|
writeJson(res, 200, toPublicSkillStatus(status));
|
|
61
94
|
} catch (err) {
|
|
95
|
+
log.error('skill-status failed', {
|
|
96
|
+
requestId,
|
|
97
|
+
error: err instanceof Error ? err.message : String(err),
|
|
98
|
+
});
|
|
62
99
|
writeJson(res, 500, { ok: false, error: String(err) });
|
|
63
100
|
}
|
|
64
101
|
},
|
|
65
102
|
});
|
|
103
|
+
const disposeMetrics = ctx.webServer!.register({
|
|
104
|
+
kind: 'exact',
|
|
105
|
+
path: ROUTE_METRICS,
|
|
106
|
+
handler: (req, res) => {
|
|
107
|
+
beginRequest(req, res, ROUTE_METRICS);
|
|
108
|
+
if (req.method !== 'GET') {
|
|
109
|
+
res.statusCode = 405;
|
|
110
|
+
res.end();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
writeJson(res, 200, metricsPayload());
|
|
114
|
+
},
|
|
115
|
+
});
|
|
66
116
|
return () => {
|
|
67
117
|
disposeReveal();
|
|
68
118
|
disposeSkill();
|
|
119
|
+
disposeMetrics();
|
|
69
120
|
};
|
|
70
|
-
}, 'dsh-better-display: reveal
|
|
121
|
+
}, 'dsh-better-display: reveal, skill-status, and metrics routes');
|
|
71
122
|
}
|
|
72
123
|
}
|
package/src/flags.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
/** Startup kill switch loaded from flags.json. This is not the reader glass setting. */
|
|
6
|
+
export interface Flags {
|
|
7
|
+
readonly readerEnabled: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const defaultFlags: Flags = { readerEnabled: true };
|
|
11
|
+
|
|
12
|
+
function locateFlags(start = dirname(fileURLToPath(import.meta.url))): string | undefined {
|
|
13
|
+
let dir = start;
|
|
14
|
+
for (let depth = 0; depth < 6; depth += 1) {
|
|
15
|
+
const candidate = resolve(dir, 'flags.json');
|
|
16
|
+
if (existsSync(candidate)) return candidate;
|
|
17
|
+
const parent = dirname(dir);
|
|
18
|
+
if (parent === dir) return undefined;
|
|
19
|
+
dir = parent;
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function normalize(value: unknown): Flags {
|
|
25
|
+
const record = value !== null && typeof value === 'object' ? value as { readerEnabled?: unknown } : {};
|
|
26
|
+
return {
|
|
27
|
+
readerEnabled: typeof record.readerEnabled === 'boolean' ? record.readerEnabled : defaultFlags.readerEnabled,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function loadFlags(source?: string | Flags): Flags {
|
|
32
|
+
if (source !== undefined && typeof source !== 'string') return normalize(source);
|
|
33
|
+
try {
|
|
34
|
+
const path = typeof source === 'string' ? source : locateFlags();
|
|
35
|
+
if (path === undefined || !existsSync(path)) return { ...defaultFlags };
|
|
36
|
+
return normalize(JSON.parse(readFileSync(path, 'utf8')) as unknown);
|
|
37
|
+
} catch {
|
|
38
|
+
return { ...defaultFlags };
|
|
39
|
+
}
|
|
40
|
+
}
|
package/src/log.ts
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import type { IncomingMessage } from 'node:http';
|
|
3
|
+
|
|
4
|
+
export const REDACTED = '[REDACTED]';
|
|
5
|
+
|
|
6
|
+
const REQUEST_ID_HEADER = 'x-request-id';
|
|
7
|
+
const REQUEST_ID_PATTERN = /^[A-Za-z0-9._:-]{1,200}$/;
|
|
8
|
+
|
|
9
|
+
const SECRET_KEYS = new Set([
|
|
10
|
+
'authorization',
|
|
11
|
+
'proxyauthorization',
|
|
12
|
+
'cookie',
|
|
13
|
+
'setcookie',
|
|
14
|
+
'token',
|
|
15
|
+
'accesstoken',
|
|
16
|
+
'refreshtoken',
|
|
17
|
+
'idtoken',
|
|
18
|
+
'apikey',
|
|
19
|
+
'apisecret',
|
|
20
|
+
'secret',
|
|
21
|
+
'clientsecret',
|
|
22
|
+
'password',
|
|
23
|
+
'passwd',
|
|
24
|
+
'credential',
|
|
25
|
+
'credentials',
|
|
26
|
+
'signature',
|
|
27
|
+
'sig',
|
|
28
|
+
'jwt',
|
|
29
|
+
'bearer',
|
|
30
|
+
'privatekey',
|
|
31
|
+
'xapikey',
|
|
32
|
+
'xauthtoken',
|
|
33
|
+
'xaccesstoken',
|
|
34
|
+
'auth',
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
export type LogFields = Record<string, unknown>;
|
|
38
|
+
|
|
39
|
+
export interface Logger {
|
|
40
|
+
info(msg: string, fields?: LogFields): void;
|
|
41
|
+
warn(msg: string, fields?: LogFields): void;
|
|
42
|
+
error(msg: string, fields?: LogFields): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface LoggerOptions {
|
|
46
|
+
readonly write?: (line: string) => void;
|
|
47
|
+
readonly base?: LogFields;
|
|
48
|
+
readonly clock?: () => Date;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function normalizeKey(key: string): string {
|
|
52
|
+
return key.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function isSecretKey(key: string): boolean {
|
|
56
|
+
const normalized = normalizeKey(key);
|
|
57
|
+
if (SECRET_KEYS.has(normalized)) return true;
|
|
58
|
+
if (normalized === 'requestid' || normalized === 'xrequestid') return false;
|
|
59
|
+
return /(?:^|[^a-z])(?:token|secret|password|api[-_]?key)$/i.test(key);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function redactString(value: string): string {
|
|
63
|
+
const query = value.replace(/([?&#])([^&#=]+)=([^&#]*)/g, (match, sep: string, rawKey: string) => {
|
|
64
|
+
let key: string;
|
|
65
|
+
try {
|
|
66
|
+
key = decodeURIComponent(rawKey.replace(/\+/g, ' '));
|
|
67
|
+
} catch {
|
|
68
|
+
key = rawKey;
|
|
69
|
+
}
|
|
70
|
+
return isSecretKey(key) ? `${sep}${rawKey}=${REDACTED}` : match;
|
|
71
|
+
});
|
|
72
|
+
return query
|
|
73
|
+
.replace(/\b(Bearer|Basic)\s+\S+/gi, `$1 ${REDACTED}`)
|
|
74
|
+
.replace(
|
|
75
|
+
/\b((?:access[_-]?token|refresh[_-]?token|id[_-]?token|api[_-]?key|client[_-]?secret|password|passwd|authorization|token|secret))(\s*[:=]\s*)([^\s&]+)/gi,
|
|
76
|
+
`$1$2${REDACTED}`,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function redact(value: unknown): unknown {
|
|
81
|
+
return redactValue(undefined, value, 0, new WeakSet());
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function redactValue(key: string | undefined, value: unknown, depth: number, seen: WeakSet<object>): unknown {
|
|
85
|
+
if (key !== undefined && isSecretKey(key)) return REDACTED;
|
|
86
|
+
if (depth > 8) return REDACTED;
|
|
87
|
+
if (typeof value === 'string') return redactString(value);
|
|
88
|
+
if (typeof value === 'number' || typeof value === 'boolean' || value === null || value === undefined) return value;
|
|
89
|
+
if (typeof value !== 'object') return REDACTED;
|
|
90
|
+
if (value instanceof Date) return value.toISOString();
|
|
91
|
+
if (value instanceof Error) {
|
|
92
|
+
return redactValue(undefined, { name: value.name, message: value.message }, depth + 1, seen);
|
|
93
|
+
}
|
|
94
|
+
if (seen.has(value)) return REDACTED;
|
|
95
|
+
seen.add(value);
|
|
96
|
+
if (Array.isArray(value)) {
|
|
97
|
+
return value.map(item => redactValue(undefined, item, depth + 1, seen));
|
|
98
|
+
}
|
|
99
|
+
const output: Record<string, unknown> = {};
|
|
100
|
+
for (const [childKey, childValue] of Object.entries(value)) {
|
|
101
|
+
output[childKey] = redactValue(childKey, childValue, depth + 1, seen);
|
|
102
|
+
}
|
|
103
|
+
return output;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function createLogger(options: LoggerOptions = {}): Logger {
|
|
107
|
+
const write = options.write ?? ((line: string) => {
|
|
108
|
+
console.log(line);
|
|
109
|
+
});
|
|
110
|
+
const clock = options.clock ?? (() => new Date());
|
|
111
|
+
const emit = (level: 'info' | 'warn' | 'error', msg: string, fields?: LogFields): void => {
|
|
112
|
+
const details = redact({ ...options.base, ...fields });
|
|
113
|
+
const record = {
|
|
114
|
+
...(details !== null && typeof details === 'object' ? details as LogFields : {}),
|
|
115
|
+
time: clock().toISOString(),
|
|
116
|
+
level,
|
|
117
|
+
msg: redactString(msg),
|
|
118
|
+
};
|
|
119
|
+
try {
|
|
120
|
+
write(JSON.stringify(record));
|
|
121
|
+
} catch {
|
|
122
|
+
write(JSON.stringify({ time: record.time, level, msg: record.msg, error: 'log record was not serializable' }));
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
info: (msg, fields) => emit('info', msg, fields),
|
|
127
|
+
warn: (msg, fields) => emit('warn', msg, fields),
|
|
128
|
+
error: (msg, fields) => emit('error', msg, fields),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function requestIdOf(req: IncomingMessage): string {
|
|
133
|
+
const raw = req.headers[REQUEST_ID_HEADER];
|
|
134
|
+
const value = Array.isArray(raw) ? raw[0] : raw;
|
|
135
|
+
if (typeof value === 'string' && REQUEST_ID_PATTERN.test(value)) return value;
|
|
136
|
+
return randomUUID();
|
|
137
|
+
}
|
package/src/metrics.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export const ROUTE_REVEAL = '/better-display/reveal';
|
|
2
|
+
export const ROUTE_SKILL_STATUS = '/better-display/skill-status';
|
|
3
|
+
export const ROUTE_METRICS = '/better-display/metrics';
|
|
4
|
+
|
|
5
|
+
export const ROUTE_HITS = [ROUTE_REVEAL, ROUTE_SKILL_STATUS, ROUTE_METRICS] as const;
|
|
6
|
+
|
|
7
|
+
export interface RouteTiming {
|
|
8
|
+
count: number;
|
|
9
|
+
totalMs: number;
|
|
10
|
+
maxMs: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const hits = new Map<string, number>(ROUTE_HITS.map(route => [route, 0]));
|
|
14
|
+
const timings = new Map<string, RouteTiming>(ROUTE_HITS.map(route => [route, { count: 0, totalMs: 0, maxMs: 0 }]));
|
|
15
|
+
|
|
16
|
+
function snapshotHits(): Record<string, number> {
|
|
17
|
+
return Object.fromEntries(hits);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function snapshotTimings(): Record<string, RouteTiming> {
|
|
21
|
+
return Object.fromEntries([...timings].map(([route, timing]) => [route, { ...timing }]));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function recordRouteHit(route: string): number {
|
|
25
|
+
const next = (hits.get(route) ?? 0) + 1;
|
|
26
|
+
hits.set(route, next);
|
|
27
|
+
return next;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function recordRouteDuration(route: string, elapsedMs: number): RouteTiming {
|
|
31
|
+
const ms = Number.isFinite(elapsedMs) && elapsedMs > 0 ? Math.round(elapsedMs) : 0;
|
|
32
|
+
const current = timings.get(route) ?? { count: 0, totalMs: 0, maxMs: 0 };
|
|
33
|
+
const next = {
|
|
34
|
+
count: current.count + 1,
|
|
35
|
+
totalMs: current.totalMs + ms,
|
|
36
|
+
maxMs: Math.max(current.maxMs, ms),
|
|
37
|
+
};
|
|
38
|
+
timings.set(route, next);
|
|
39
|
+
return next;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function metricsPayload(): {
|
|
43
|
+
counters: { dsh_better_display_route_hits_total: Record<string, number> };
|
|
44
|
+
timingsMs: Record<string, RouteTiming>;
|
|
45
|
+
} {
|
|
46
|
+
return {
|
|
47
|
+
counters: { dsh_better_display_route_hits_total: snapshotHits() },
|
|
48
|
+
timingsMs: snapshotTimings(),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import React, { useSyncExternalStore } from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import type { ChatSnapshot } from '@deepseek-ai/dsh-client-ui-chat/client';
|
|
4
|
+
import { Reader } from '../src/client/Reader.js';
|
|
5
|
+
import { createReaderStore } from '../src/client/store.js';
|
|
6
|
+
import type { ReaderProps } from '../src/client/types.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Real Reader + real root/session stores; only conversation data is synthetic.
|
|
10
|
+
*
|
|
11
|
+
* This fixture isolates the "process report narration" bug: an assistant step
|
|
12
|
+
* that carries a long non-reasoning text block (正文) between thinking steps used
|
|
13
|
+
* to be classified as process content and folded away. Contract under test:
|
|
14
|
+
* body text is always visible; folds may only hold reasoning / tool / other
|
|
15
|
+
* process records.
|
|
16
|
+
*
|
|
17
|
+
* Turn layout:
|
|
18
|
+
* 1 closed/completed : step0 = reasoning + 正文A + tool-call ; step1 = reasoning + 最终回答B
|
|
19
|
+
* 2 open : step0 = reasoning + 进行中汇报正文C ; step1 = reasoning (latest)
|
|
20
|
+
* 3 closed/error : step0 = reasoning + 失败轮正文D
|
|
21
|
+
* 4 closed/interrupted: step0 = reasoning + 中断轮正文E
|
|
22
|
+
*/
|
|
23
|
+
const BODY_A = '过程汇报正文A';
|
|
24
|
+
const REASON_A = '历史思考:先查简报素材';
|
|
25
|
+
const FINAL_B = '最终回答B';
|
|
26
|
+
const REASON_B = '第二次思考:整理结论';
|
|
27
|
+
const TOOL_SUMMARY = '读取 简报素材.txt';
|
|
28
|
+
const BODY_C = '进行中汇报正文C';
|
|
29
|
+
const REASON_C0 = '第一轮思考';
|
|
30
|
+
const REASON_C1 = '第二轮思考';
|
|
31
|
+
const BODY_D = '失败轮正文D';
|
|
32
|
+
const REASON_D = '报错前的思考';
|
|
33
|
+
const BODY_E = '中断轮正文E';
|
|
34
|
+
const REASON_E = '中断前的思考';
|
|
35
|
+
// Turn 5 exercises the segmented-report case: two adjacent narration paragraphs
|
|
36
|
+
// (with folded reasoning between them) plus a final answer, all with long text.
|
|
37
|
+
const BODY_F = '第一段汇报:已完成需求梳理,确认改造点集中在投影层与阅读渲染层。这一步整理的是已经核实的事实,不包括猜测。\n\n第二段汇报:接下来核对折叠链边界,并验证正文在收起状态下仍然可见,同时保持思维链与工具行可以展开。';
|
|
38
|
+
const REASON_F0 = '汇报前的思考';
|
|
39
|
+
const BODY_G = '补充汇报:折叠只保留思维链与工具调用,正文块保持原位。';
|
|
40
|
+
const REASON_G = '补充说明前的思考';
|
|
41
|
+
const REASON_H = '收尾思考';
|
|
42
|
+
const FINAL_H = '最终回答H';
|
|
43
|
+
const TOOL_CALL_ID = 'call-read-1';
|
|
44
|
+
const TOOL_ARGS = '{"path":"/fixture/工作区/简报素材.txt"}';
|
|
45
|
+
|
|
46
|
+
const store = createReaderStore();
|
|
47
|
+
const prefs = store.create();
|
|
48
|
+
const session = store.create('commentary-fixture');
|
|
49
|
+
|
|
50
|
+
type Turn = {
|
|
51
|
+
turn: number; status: 'open' | 'closed';
|
|
52
|
+
start: { seq: number; time: number };
|
|
53
|
+
end?: { time: number; data: { reason: { kind: string } } };
|
|
54
|
+
data: Map<string, any>;
|
|
55
|
+
steps: any[];
|
|
56
|
+
};
|
|
57
|
+
const nodes = new Map<string, any>();
|
|
58
|
+
const turns = new Map<number, Turn>();
|
|
59
|
+
|
|
60
|
+
function newTurn(turn: number, status: 'open' | 'closed', seq: number, reason?: string): Turn {
|
|
61
|
+
const value: Turn = {
|
|
62
|
+
turn, status, start: { seq, time: 1 },
|
|
63
|
+
end: status === 'closed' ? { time: 1001, data: { reason: { kind: reason ?? 'completed' } } } : undefined,
|
|
64
|
+
data: new Map<string, any>(),
|
|
65
|
+
steps: [],
|
|
66
|
+
};
|
|
67
|
+
turns.set(turn, value);
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function addStep(turnNumber: number, step: number, seq: number, status: string, blocks: any[]): any {
|
|
72
|
+
const turn = turns.get(turnNumber)!;
|
|
73
|
+
const data = { turn: turnNumber, step, status, time: 1, blocks };
|
|
74
|
+
const location = { step, start: { seq }, data: new Map([['assistant-step', data]]) };
|
|
75
|
+
turn.steps.push(location);
|
|
76
|
+
nodes.set(`turn-${turnNumber}-step-${step}`, {
|
|
77
|
+
key: `turn-${turnNumber}-step-${step}`, kind: 'assistant-step', visibility: 'visible',
|
|
78
|
+
anchorSeq: seq, location: { kind: 'step', turn, step: location }, data,
|
|
79
|
+
});
|
|
80
|
+
return location;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function addToolCallNode(turnNumber: number, key: string, seq: number, location: any, callId: string, argsRaw: string): void {
|
|
84
|
+
const turn = turns.get(turnNumber)!;
|
|
85
|
+
const root = {
|
|
86
|
+
kind: 'tool-result', seq, time: 1, callId,
|
|
87
|
+
call: { name: 'read', argsRaw }, callTime: 1,
|
|
88
|
+
content: [{ kind: 'text', text: '简报素材的摘录内容' }], isError: false, subCalls: [],
|
|
89
|
+
};
|
|
90
|
+
nodes.set(key, {
|
|
91
|
+
key, kind: 'tool-call', visibility: 'visible', anchorSeq: seq,
|
|
92
|
+
location: { kind: 'step', turn, step: location }, data: { root },
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// --- turn 1: completed; narration sits between reasoning and the final answer.
|
|
97
|
+
const turn1 = newTurn(1, 'closed', 100);
|
|
98
|
+
turn1.data.set('turn-tail', { closing: { step: 1 } });
|
|
99
|
+
const t1s0 = addStep(1, 0, 101, 'settled', [
|
|
100
|
+
{ kind: 'reasoning', text: REASON_A },
|
|
101
|
+
{ kind: 'text', text: BODY_A },
|
|
102
|
+
{ kind: 'tool-call', callId: TOOL_CALL_ID, name: 'read', argsRaw: TOOL_ARGS },
|
|
103
|
+
]);
|
|
104
|
+
addToolCallNode(1, 'turn-1-tool-call-1', 102, t1s0, TOOL_CALL_ID, TOOL_ARGS);
|
|
105
|
+
addStep(1, 1, 103, 'settled', [
|
|
106
|
+
{ kind: 'reasoning', text: REASON_B },
|
|
107
|
+
{ kind: 'text', text: FINAL_B },
|
|
108
|
+
]);
|
|
109
|
+
|
|
110
|
+
// --- turn 2: open; second reasoning arrives after a process report.
|
|
111
|
+
const turn2 = newTurn(2, 'open', 200);
|
|
112
|
+
addStep(2, 0, 201, 'settled', [
|
|
113
|
+
{ kind: 'reasoning', text: REASON_C0 },
|
|
114
|
+
{ kind: 'text', text: BODY_C },
|
|
115
|
+
]);
|
|
116
|
+
addStep(2, 1, 202, 'running', [
|
|
117
|
+
{ kind: 'reasoning', text: REASON_C1 },
|
|
118
|
+
]);
|
|
119
|
+
|
|
120
|
+
// --- turn 3: failed turn; nothing may fold.
|
|
121
|
+
newTurn(3, 'closed', 300, 'error');
|
|
122
|
+
addStep(3, 0, 301, 'settled', [
|
|
123
|
+
{ kind: 'reasoning', text: REASON_D },
|
|
124
|
+
{ kind: 'text', text: BODY_D },
|
|
125
|
+
]);
|
|
126
|
+
|
|
127
|
+
// --- turn 4: interrupted turn; nothing may fold.
|
|
128
|
+
newTurn(4, 'closed', 400, 'interrupted');
|
|
129
|
+
addStep(4, 0, 401, 'settled', [
|
|
130
|
+
{ kind: 'reasoning', text: REASON_E },
|
|
131
|
+
{ kind: 'text', text: BODY_E },
|
|
132
|
+
]);
|
|
133
|
+
|
|
134
|
+
// --- turn 5: completed turn whose report is split into two narration paragraphs
|
|
135
|
+
// with folded reasoning between them; the rail must bridge them after collapsing.
|
|
136
|
+
const turn5 = newTurn(5, 'closed', 500);
|
|
137
|
+
turn5.data.set('turn-tail', { closing: { step: 2 } });
|
|
138
|
+
addStep(5, 0, 501, 'settled', [
|
|
139
|
+
{ kind: 'reasoning', text: REASON_F0 },
|
|
140
|
+
{ kind: 'text', text: BODY_F },
|
|
141
|
+
]);
|
|
142
|
+
addStep(5, 1, 502, 'settled', [
|
|
143
|
+
{ kind: 'reasoning', text: REASON_G },
|
|
144
|
+
{ kind: 'text', text: BODY_G },
|
|
145
|
+
]);
|
|
146
|
+
addStep(5, 2, 503, 'settled', [
|
|
147
|
+
{ kind: 'reasoning', text: REASON_H },
|
|
148
|
+
{ kind: 'text', text: FINAL_H },
|
|
149
|
+
]);
|
|
150
|
+
|
|
151
|
+
const chat = {
|
|
152
|
+
order: [
|
|
153
|
+
'turn-1-step-0', 'turn-1-tool-call-1', 'turn-1-step-1',
|
|
154
|
+
'turn-2-step-0', 'turn-2-step-1',
|
|
155
|
+
'turn-3-step-0', 'turn-4-step-0',
|
|
156
|
+
'turn-5-step-0', 'turn-5-step-1', 'turn-5-step-2',
|
|
157
|
+
],
|
|
158
|
+
nodes,
|
|
159
|
+
timeline: { turns },
|
|
160
|
+
} as unknown as ChatSnapshot;
|
|
161
|
+
const sessionSnapshot = { running: true, openState: 'ready', pendingSubmissions: [], hasMore: false, loadingOlder: false };
|
|
162
|
+
const sessionsSnapshot = { byId: { 'commentary-fixture': { cwd: '/fixture' } } };
|
|
163
|
+
const pending = new Map();
|
|
164
|
+
const host = { home: '/fixture' };
|
|
165
|
+
const useReaderStore: ReaderProps['useStore'] = selector => selector(useSyncExternalStore(session.subscribe, session.getSnapshot));
|
|
166
|
+
const props = {
|
|
167
|
+
sessionId: 'commentary-fixture', useChat: selector => selector(chat),
|
|
168
|
+
useSession: selector => selector(sessionSnapshot), useSessions: selector => selector(sessionsSnapshot),
|
|
169
|
+
useSessionStatus: selector => selector(new Map([['commentary-fixture', { running: true, pendingInteraction: pending.get('commentary-fixture'), completionUnread: false }]])),
|
|
170
|
+
useStore: useReaderStore, actions: session.actions, openPrefs: prefs,
|
|
171
|
+
t: key => key, renderSlot: (_name: string, _owner: any, options: any) => options?.fallback ?? null,
|
|
172
|
+
renderSlotChain: (_name: string, _owner: any, options: any) => options?.fallback ?? null,
|
|
173
|
+
loadImage: async () => ({ data: new Uint8Array(), mediaType: 'image/png' }),
|
|
174
|
+
officialImageLoader: Object.assign(async () => null, { peek: () => null }),
|
|
175
|
+
officialFileMentions: () => undefined, officialPreviewFile: () => {},
|
|
176
|
+
officialHost: { getSnapshot: () => host, subscribe: () => () => {} },
|
|
177
|
+
fillComposer: () => true, openFile: () => {}, loadOlder: async () => {}, openView: () => {},
|
|
178
|
+
} as unknown as ReaderProps;
|
|
179
|
+
|
|
180
|
+
Object.assign(window, {
|
|
181
|
+
commentaryFixture: {
|
|
182
|
+
// Exercise the same root preference the Settings panel uses.
|
|
183
|
+
preference: (value: boolean) => prefs.actions.setAutoFold(value),
|
|
184
|
+
state: () => session.getSnapshot(),
|
|
185
|
+
text: { BODY_A, REASON_A, FINAL_B, REASON_B, TOOL_SUMMARY, BODY_C, REASON_C0, REASON_C1, BODY_D, REASON_D, BODY_E, REASON_E, BODY_F, REASON_F0, BODY_G, REASON_G, REASON_H, FINAL_H, TOOL_CALL_ID },
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
createRoot(document.getElementById('app')!).render(
|
|
190
|
+
<div data-conversation-scroll style={{ height: '100vh', overflow: 'auto' }}><Reader {...props} /></div>,
|
|
191
|
+
);
|
|
@@ -78,7 +78,8 @@ slots.register({ name: 'root', children: {
|
|
|
78
78
|
'tool.call.toolview': { kind: 'keyed', scope: 'session' },
|
|
79
79
|
'conversation.chat.turnTail': { kind: 'list', scope: 'session' },
|
|
80
80
|
'conversation.chat.node': { kind: 'keyed', scope: 'session', inject: { hooks: { turnData: (_s: any, value: any) => () => value } } },
|
|
81
|
-
'conversation.message.images': { kind: 'single', scope: 'session' },
|
|
81
|
+
'conversation.chat.message.images': { kind: 'single', scope: 'session' },
|
|
82
|
+
'conversation.chat.user.images': { kind: 'single', scope: 'session' },
|
|
82
83
|
'conversation.input.overlay': { kind: 'list', scope: 'session' },
|
|
83
84
|
'fixture.reader': { kind: 'single', scope: 'session' },
|
|
84
85
|
} }, ({ SessionProvider, renderSlot }: any) => <SessionProvider>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from 'node:assert/strict';
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { dirname, resolve } from 'node:path';
|
|
4
|
-
import { test } from '
|
|
4
|
+
import { test } from 'vitest';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
|
|
7
7
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
package/tests/cloud-gate.test.ts
CHANGED