dsh-trajectory-traceview-plus 0.0.0-stage → 0.10.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.
@@ -0,0 +1,61 @@
1
+ //#region plugin entry point
2
+ /** Services required by apply(): the slot registry, the locale service, and the sessions service (for loadOlder history paging). */
3
+ const inject = ["slots", "locale", "sessions"];
4
+ /**
5
+ * Client plugin body: register the 轨迹视图 (Trace View) conversation tab,
6
+ * seated to the right of the trajectory tab (order 20 > trajectory's 10).
7
+ * @param ctx - client root context.
8
+ */
9
+ function apply(ctx) {
10
+ ctx.effect(() => ctx.locale.register(NS, { zh, en }), "traceview: dictionaries");
11
+ const t = ctx.locale.bind(NS);
12
+ // Register through a boundary so a failure in the shell (not just in one
13
+ // station) still leaves a readable notice instead of a blank tab.
14
+ const SafeTraceMapView = (props) => jsx(RenderBoundary, {
15
+ label: t("error.render"),
16
+ retryLabel: t("error.retry"),
17
+ hint: t("error.renderHint"),
18
+ wide: true,
19
+ render: () => jsx(TraceMapView, props)
20
+ }, "viewSafe");
21
+ ctx.slots.inject("conversation.view", () => ctx.slots.register({
22
+ name: "conversation.view",
23
+ id: "traceview-plus",
24
+ order: 21,
25
+ locale: NS,
26
+ label: () => t("view.label"),
27
+ inject: (sessionId) => {
28
+ const session = ctx.sessions.binding(sessionId)?.session;
29
+ if (session === void 0) return {};
30
+ return {
31
+ // The view resets its per-session UI state when this changes. Without it,
32
+ // switching conversations kept the previous one's replay position: the
33
+ // reveal counter survived, `R` was merely clamped to the new station
34
+ // count, so opening a fresh 5-station session while sitting on station
35
+ // 40 of another showed it fully expanded as if already replayed.
36
+ sessionKey: String(sessionId),
37
+ // "Did the window grow?" cannot be answered by comparing snapshots.
38
+ // The host's loadOlder SWALLOWS its own failures: it resolves normally
39
+ // and only flips `historyLoadStatus` to 'error' (verified in
40
+ // dsh-api-session-controller/src/client/sessions/session.ts:432). So a
41
+ // failed page still returns a NEW snapshot object and this comparison
42
+ // reported "progress":
43
+ // - the view's `.catch()` never fired, so a failed page showed no
44
+ // message at all — the button spun and came back unchanged;
45
+ // - the anchor paging loop treats `moved !== true` as "no progress"
46
+ // and breaks, so a failing page kept it retrying up to 40 times.
47
+ // Read the host status instead, and rethrow so callers can report it.
48
+ loadOlder: async () => {
49
+ const before = session.getSnapshot();
50
+ await session.loadOlder();
51
+ const after = session.getSnapshot();
52
+ const failed = after.historyLoadStatus === "error" && before.historyLoadStatus !== "error";
53
+ if (failed) throw new Error("loadOlder failed");
54
+ return after !== before;
55
+ }
56
+ };
57
+ }
58
+ }, SafeTraceMapView));
59
+ }
60
+ exports.apply = apply;
61
+ exports.inject = inject;