pi-mega-compact 0.8.15 → 0.8.16

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.
Files changed (40) hide show
  1. package/README.md +51 -486
  2. package/dist/extensions/dashboard-client/src/hooks/useApi.js +51 -0
  3. package/dist/extensions/dashboard-client/src/hooks/useSSE.js +63 -0
  4. package/dist/extensions/dashboard-server/html.js +15 -2
  5. package/dist/extensions/mega-runtime/state.js +66 -0
  6. package/dist/extensions/mega-runtime/state.test.js +37 -0
  7. package/dist/extensions/mega-runtime/widget.js +6 -2
  8. package/dist/extensions/mega-runtime/widget.test.js +47 -0
  9. package/extensions/dashboard-client/dist/assets/{AchievementTiles-BH26e95w.js → AchievementTiles-BozP_h3c.js} +2 -2
  10. package/extensions/dashboard-client/dist/assets/{AchievementTiles-BH26e95w.js.map → AchievementTiles-BozP_h3c.js.map} +1 -1
  11. package/extensions/dashboard-client/dist/assets/{AchievementsTab-B94wvRV_.js → AchievementsTab-DKgqx1RQ.js} +2 -2
  12. package/extensions/dashboard-client/dist/assets/{AchievementsTab-B94wvRV_.js.map → AchievementsTab-DKgqx1RQ.js.map} +1 -1
  13. package/extensions/dashboard-client/dist/assets/{CacheTab-DPmw3NHR.js → CacheTab-CPvso4-0.js} +2 -2
  14. package/extensions/dashboard-client/dist/assets/{CacheTab-DPmw3NHR.js.map → CacheTab-CPvso4-0.js.map} +1 -1
  15. package/extensions/dashboard-client/dist/assets/ConfigTab-DXD7zbqy.js +2 -0
  16. package/extensions/dashboard-client/dist/assets/ConfigTab-DXD7zbqy.js.map +1 -0
  17. package/extensions/dashboard-client/dist/assets/{EventsTab-B5PicfFw.js → EventsTab-BGeuYvM3.js} +2 -2
  18. package/extensions/dashboard-client/dist/assets/{EventsTab-B5PicfFw.js.map → EventsTab-BGeuYvM3.js.map} +1 -1
  19. package/extensions/dashboard-client/dist/assets/{GameTab-CsVwp78a.js → GameTab-Qj19W1Y-.js} +2 -2
  20. package/extensions/dashboard-client/dist/assets/{GameTab-CsVwp78a.js.map → GameTab-Qj19W1Y-.js.map} +1 -1
  21. package/extensions/dashboard-client/dist/assets/{MetricsTab-Cf72UewX.js → MetricsTab-DA27vA95.js} +2 -2
  22. package/extensions/dashboard-client/dist/assets/{MetricsTab-Cf72UewX.js.map → MetricsTab-DA27vA95.js.map} +1 -1
  23. package/extensions/dashboard-client/dist/assets/{OverviewTab-Dh6aG3gy.js → OverviewTab-lVGR1Jl_.js} +2 -2
  24. package/extensions/dashboard-client/dist/assets/{OverviewTab-Dh6aG3gy.js.map → OverviewTab-lVGR1Jl_.js.map} +1 -1
  25. package/extensions/dashboard-client/dist/assets/{ReposTab-HXf2dorl.js → ReposTab-_HNR3qYj.js} +2 -2
  26. package/extensions/dashboard-client/dist/assets/{ReposTab-HXf2dorl.js.map → ReposTab-_HNR3qYj.js.map} +1 -1
  27. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-kUnoospE.js → TimeSavedCard-B7aPcBMs.js} +2 -2
  28. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-kUnoospE.js.map → TimeSavedCard-B7aPcBMs.js.map} +1 -1
  29. package/extensions/dashboard-client/dist/assets/{index-DMntLu-8.js → index-B2JJExE9.js} +3 -3
  30. package/extensions/dashboard-client/dist/assets/{index-DMntLu-8.js.map → index-B2JJExE9.js.map} +1 -1
  31. package/extensions/dashboard-client/dist/index.html +1 -1
  32. package/extensions/dashboard-client/src/tabs/ConfigTab.tsx +19 -2
  33. package/extensions/dashboard-server/html.ts +15 -2
  34. package/extensions/mega-runtime/state.test.ts +33 -0
  35. package/extensions/mega-runtime/state.ts +64 -0
  36. package/extensions/mega-runtime/widget.test.ts +48 -0
  37. package/extensions/mega-runtime/widget.ts +6 -2
  38. package/package.json +1 -1
  39. package/extensions/dashboard-client/dist/assets/ConfigTab-C3g3smRL.js +0 -2
  40. package/extensions/dashboard-client/dist/assets/ConfigTab-C3g3smRL.js.map +0 -1
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>mega-compact dashboard</title>
7
- <script type="module" crossorigin src="./assets/index-DMntLu-8.js"></script>
7
+ <script type="module" crossorigin src="./assets/index-B2JJExE9.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="./assets/index-Cfxniu2R.css">
9
9
  </head>
10
10
  <body>
@@ -17,7 +17,7 @@ import type React from "react";
17
17
  import { useState, useEffect, useCallback } from "react";
18
18
  import type { SnapshotResponse, GameStatePatch } from "@contracts";
19
19
  import { fetchSnapshot, fetchGameState, putGameState } from "../api/client";
20
- import { THEMES } from "../../../../src/config/themes";
20
+ import { THEMES, THEME_IDS } from "../../../../src/config/themes";
21
21
 
22
22
  /** Actual flat game state returned by the server (the server returns a flat
23
23
  * { game_mode_on, theme, tui_display_mode } shape, NOT the contract's nested
@@ -168,6 +168,20 @@ export default function ConfigTab(): React.ReactElement {
168
168
  </option>
169
169
  ))}
170
170
  </select>
171
+ <button
172
+ type="button"
173
+ disabled={saving}
174
+ className="theme-cycle-btn"
175
+ title="Cycle to the next theme (P3)"
176
+ onClick={() => {
177
+ const i = THEME_IDS.indexOf(themeVal);
178
+ const next =
179
+ THEME_IDS[(i < 0 ? 0 : i + 1) % THEME_IDS.length];
180
+ if (next) void handlePatch({ theme: next });
181
+ }}
182
+ >
183
+ Next theme →
184
+ </button>
171
185
  </label>
172
186
  </div>
173
187
  <div className="settings-row">
@@ -184,7 +198,10 @@ export default function ConfigTab(): React.ReactElement {
184
198
  >
185
199
  <option value="full">Full</option>
186
200
  <option value="minimal">Minimal</option>
187
- </select>
201
+ </select>{" "}
202
+ <span className="tui-mode-hint">
203
+ (affects the in-app TUI widget; not shown here)
204
+ </span>
188
205
  </label>
189
206
  </div>
190
207
  </section>
@@ -179,8 +179,8 @@ export function dashboardHtml(tierName: string): string {
179
179
 
180
180
  <div class="settings-strip">
181
181
  <label title="Turn game mode on/off (themes the widget + dashboard)"><input type="checkbox" id="set-game-mode"> Game mode</label>
182
- <label title="Visual theme (applies instantly)">Theme <select id="set-theme">${THEME_OPTIONS}</select></label>
183
- <label title="TUI widget display density">TUI <select id="set-tui-mode"><option value="full">Full</option><option value="minimal">Minimal</option></select></label>
182
+ <label title="Visual theme (applies instantly)">Theme <select id="set-theme">${THEME_OPTIONS}</select> <button type="button" id="set-theme-next" title="Cycle to the next theme (P3)">Next theme →</button></label>
183
+ <label title="TUI widget display density">TUI <select id="set-tui-mode"><option value="full">Full</option><option value="minimal">Minimal</option></select> <span class="tui-mode-hint">(affects the in-app TUI widget; not shown here)</span></label>
184
184
  </div>
185
185
 
186
186
  <nav class="tabs">
@@ -872,6 +872,19 @@ export function dashboardHtml(tierName: string): string {
872
872
  }
873
873
  if (gmCheckbox) gmCheckbox.addEventListener('change', function() { putGameState({ game_mode_on: gmCheckbox.checked }); });
874
874
  if (gmTheme) gmTheme.addEventListener('change', function() { putGameState({ theme: gmTheme.value }); });
875
+ // P3: client-side theme cycling (no new endpoint). Reads the already-fetched
876
+ // <option> values from the theme select, so it stays in sync with the server's
877
+ // THEMES list without a second fetch.
878
+ var gmThemeNext = document.getElementById('set-theme-next');
879
+ if (gmThemeNext) gmThemeNext.addEventListener('click', function() {
880
+ var opts = gmTheme ? gmTheme.options : [];
881
+ var n = opts.length;
882
+ var cur = gmTheme ? gmTheme.value : 'transparent';
883
+ var idx = -1;
884
+ for (var i = 0; i < n; i++) { if (opts[i].value === cur) { idx = i; break; } }
885
+ var next = n > 0 ? opts[(idx < 0 ? 0 : (idx + 1) % n)].value : 'transparent';
886
+ putGameState({ theme: next });
887
+ });
875
888
  if (gmTui) gmTui.addEventListener('change', function() { putGameState({ tui_display_mode: gmTui.value }); });
876
889
  pollGameState();
877
890
  setInterval(pollGameState, 5000);
@@ -116,6 +116,39 @@ describe("MegaRuntime setEffect lifecycle (v0.8.3)", () => {
116
116
  });
117
117
  });
118
118
 
119
+ describe("MegaRuntime pushTicker dedupe (P1)", () => {
120
+ const dirs: string[] = [];
121
+ after(() => {
122
+ for (const d of dirs) {
123
+ try { closeStore(d); } catch { /* */ }
124
+ }
125
+ delete process.env.MEGACOMPACT_STATE_DIR;
126
+ for (const d of dirs) rmSync(d, { recursive: true, force: true });
127
+ });
128
+
129
+ it("pushTicker skips consecutive identical entries (keeps ring at capacity for variety)", () => {
130
+ const dir = freshDir(); dirs.push(dir);
131
+ process.env.MEGACOMPACT_STATE_DIR = dir;
132
+ const rt = new MegaRuntime(minimalConfig(dir));
133
+ rt.pushTicker("compact");
134
+ rt.pushTicker("compact"); // dedup — skipped
135
+ rt.pushTicker("compact"); // dedup — skipped
136
+ rt.pushTicker("recall");
137
+ assert.equal(rt.ticker.length, 2, "only 2 unique entries kept");
138
+ assert.equal(rt.ticker[0].text, "compact");
139
+ assert.equal(rt.ticker[1].text, "recall");
140
+ });
141
+
142
+ it("pushTicker keeps distinct entries and respects TICKER_MAX", () => {
143
+ const dir = freshDir(); dirs.push(dir);
144
+ process.env.MEGACOMPACT_STATE_DIR = dir;
145
+ const rt = new MegaRuntime(minimalConfig(dir));
146
+ for (let i = 0; i < rt.TICKER_MAX + 3; i++) rt.pushTicker(`t${i}`);
147
+ assert.equal(rt.ticker.length, rt.TICKER_MAX, "capped at TICKER_MAX");
148
+ assert.equal(rt.ticker[rt.TICKER_MAX - 1].text, `t${rt.TICKER_MAX + 2}`);
149
+ });
150
+ });
151
+
119
152
  describe("MegaRuntime game-state cache (S31)", () => {
120
153
  const dirs: string[] = [];
121
154
  after(() => {
@@ -213,6 +213,11 @@ export class MegaRuntime {
213
213
  // getCachedGameState() snapshot re-queries the DB anyway.
214
214
  private gameStateWatcher?: FSWatcher;
215
215
  private gameStateWatchDir?: string;
216
+ // P2: the last ExtensionContext handed to snapshot()/renderWidget(), stashed
217
+ // so the fs.watch game-state callback can force a widget re-render without
218
+ // a context event (cross-process dashboard edits while pi is idle). Cleared
219
+ // implicitly on construction (undefined → watcher skips until first snap).
220
+ private lastWidgetCtx?: ExtensionContext;
216
221
 
217
222
  /**
218
223
  * DIAG counters for the "team run doesn't relieve context" investigation.
@@ -379,6 +384,7 @@ export class MegaRuntime {
379
384
 
380
385
  /** Collect live state and write it to disk (+ paint the above-editor widget). */
381
386
  snapshot(ctx?: ExtensionContext): void {
387
+ if (ctx) this.lastWidgetCtx = ctx;
382
388
  if (ctx) this.bindRepo(ctx.cwd);
383
389
  // v0.8.5: gate the expensive body (6 sync SQLite opens +
384
390
  // writeFileSync(dashboard.json)) behind a cheap material-change signature.
@@ -999,6 +1005,29 @@ export class MegaRuntime {
999
1005
  if (typeof filename === "string" && filename.startsWith("sqlite.db")) {
1000
1006
  this.cachedGameState = undefined;
1001
1007
  this.gameStateBump++;
1008
+ // P2: force a widget re-render so a dashboard-made theme/toggle/
1009
+ // tui-mode change reflects in the live TUI immediately, even when
1010
+ // pi is idle (no context event to drive snapshot()). Use the
1011
+ // LIGHTWEIGHT refreshWidgetGameState() — NOT the full snapshot():
1012
+ // snapshot() recomputes 6 sync SQLite opens + writes dashboard.json
1013
+ // + writes to the store, and those store writes RETRIGGER this
1014
+ // same fs.watch callback (it fires on every sqlite.db* write) →
1015
+ // re-entrant thrash → 190s test timeout under mega-compact.test.js
1016
+ // / mega-teamrun.test.js. The lightweight path re-reads ONLY the
1017
+ // game_state row and patches the three game-mode fields on the
1018
+ // existing widgetData, then re-registers the factory via
1019
+ // renderWidget() — it writes nothing to the store or
1020
+ // dashboard.json, so it cannot retrigger itself. Guard: skip until
1021
+ // the first snapshot stashed a ctx (no widget registered yet →
1022
+ // nothing to refresh). Non-fatal: next context event re-snapshots.
1023
+ const ctx = this.lastWidgetCtx;
1024
+ if (ctx) {
1025
+ try {
1026
+ this.refreshWidgetGameState(ctx);
1027
+ } catch {
1028
+ /* non-fatal */
1029
+ }
1030
+ }
1002
1031
  }
1003
1032
  },
1004
1033
  );
@@ -1076,6 +1105,33 @@ export class MegaRuntime {
1076
1105
  return this.cachedGameState;
1077
1106
  }
1078
1107
 
1108
+ /** P2 cross-process re-render: lightweight game-state refresh for the
1109
+ * fs.watch callback. Eviction of cachedGameState + gameStateBump++ happens
1110
+ * in the caller BEFORE this runs. Here we re-read ONLY the game_state row
1111
+ * via getCachedGameState() (one SELECT; the cache is already evicted) and
1112
+ * patch ONLY the three game-mode fields on the EXISTING widgetData, then
1113
+ * re-register the widget factory via renderWidget() so pi redraws next
1114
+ * frame.
1115
+ *
1116
+ * WHY a lightweight path: the full snapshot(ctx) recomputes 6 synchronous
1117
+ * SQLite opens + writeFileSync(dashboard.json) + store writes, and those
1118
+ * store writes RETRIGGER this same fs.watch callback → re-entrant thrash
1119
+ * (the watcher fires on every sqlite.db* write, including context-event
1120
+ * checkpoint writes) → 190s test timeout under mega-compact.test.js /
1121
+ * mega-teamrun.test.js. This path writes NOTHING to the store or
1122
+ * dashboard.json, so it cannot retrigger itself.
1123
+ *
1124
+ * Guard: no-op when widgetData is null (no snapshot has run yet → nothing
1125
+ * to patch) or ctx is undefined. Field values mirror snapshot() exactly. */
1126
+ refreshWidgetGameState(ctx: ExtensionContext): void {
1127
+ if (!this.widgetData || !ctx) return;
1128
+ const gs = this.getCachedGameState();
1129
+ this.widgetData.gameMode = gs.game_mode_on;
1130
+ this.widgetData.theme = getTheme(gs.theme) ? gs.theme : "transparent";
1131
+ this.widgetData.tuiMode = gs.tui_display_mode;
1132
+ this.renderWidget(ctx);
1133
+ }
1134
+
1079
1135
  /** S31: evict the cached game-mode state so the next widget render re-reads
1080
1136
  * the game_state row. Called by /mega-game after every setGameState() so
1081
1137
  * the panel picks up theme/mode/toggle changes live. */
@@ -1164,6 +1220,14 @@ export class MegaRuntime {
1164
1220
 
1165
1221
  // Phase 3 — recall/activity ticker ring buffer.
1166
1222
  pushTicker(text: string): void {
1223
+ // P1: dedupe consecutive identical entries — skip the append when the
1224
+ // last entry's text matches, so a re-fired compact/recall/dedup event
1225
+ // doesn't flood the ring (keeps it at TICKER_MAX for real variety).
1226
+ // `at` is NOT refreshed on a skip (the original event time stands).
1227
+ if (this.ticker[this.ticker.length - 1]?.text === text) {
1228
+ this.lastActivityAt = Date.now();
1229
+ return;
1230
+ }
1167
1231
  this.ticker.push({ text, at: Date.now() });
1168
1232
  while (this.ticker.length > this.TICKER_MAX) this.ticker.shift();
1169
1233
  this.lastActivityAt = Date.now();
@@ -212,6 +212,54 @@ describe("buildWidgetLines ambient border effect (v0.8.3)", () => {
212
212
  });
213
213
  });
214
214
 
215
+ describe("buildWidgetLines footer stability (P1 — no 250ms rotation)", () => {
216
+ // P1: the L5 ticker branch used to re-pick the head text every 250ms via
217
+ // `step = floor(Date.now()/250)`, flipping the footer line on a 250·N ms
218
+ // cycle. After the fix it pins to the most-recent entry, so two renders of
219
+ // the SAME WidgetData at t and t+500ms (well past one rotation slot) must
220
+ // produce byte-identical footer lines. Proves the metronome is gone.
221
+ const stabBase = (overrides: Partial<WidgetData> = {}): WidgetData => baseWd({
222
+ theme: DEFAULT_THEME, tuiMode: "full", gameMode: false, level: 1, cachePct: 42, ...overrides,
223
+ });
224
+
225
+ it("ticker footer is byte-identical across simulated frames 500ms apart", () => {
226
+ const wd = stabBase({
227
+ ticker: [
228
+ { text: "first", at: 1000 },
229
+ { text: "second", at: 2000 },
230
+ { text: "third", at: 3000 },
231
+ ],
232
+ lastWhy: "because",
233
+ });
234
+ const realNow = Date.now;
235
+ try {
236
+ Date.now = () => 1_000_000; // t
237
+ const a = buildWidgetLines(wd, WIDTH, 0);
238
+ Date.now = () => 1_000_500; // t+500ms (would have rotated twice under the old code)
239
+ const b = buildWidgetLines(wd, WIDTH, 0);
240
+ assert.deepEqual(a, b, "footer byte-identical across 500ms with no state change");
241
+ // And the pinned head is the most-recent entry (third), not a rotation:
242
+ assert.ok(a.some((l) => l.includes("third")), "shows most-recent ticker entry");
243
+ assert.ok(a.some((l) => l.includes("(+2 more)")), "(+N more) suffix preserved");
244
+ assert.ok(a.some((l) => l.includes("because")), "lastWhy preserved");
245
+ } finally {
246
+ Date.now = realNow;
247
+ }
248
+ });
249
+
250
+ it("footer still flips when the ticker actually changes (new pushTicker)", () => {
251
+ const realNow = Date.now;
252
+ try {
253
+ Date.now = () => 1_000_000;
254
+ const before = buildWidgetLines(stabBase({ ticker: [{ text: "a", at: 1 }] }), WIDTH, 0);
255
+ const after = buildWidgetLines(stabBase({ ticker: [{ text: "a", at: 1 }, { text: "b", at: 2 }] }), WIDTH, 0);
256
+ assert.notDeepEqual(before, after, "footer changes when ticker grows");
257
+ } finally {
258
+ Date.now = realNow;
259
+ }
260
+ });
261
+ });
262
+
215
263
  describe("buildWidgetLines achievement flare (S35)", () => {
216
264
  const achBase = (overrides: Partial<WidgetData> = {}): WidgetData => baseWd({
217
265
  theme: DEFAULT_THEME, tuiMode: "full", gameMode: true, level: 1, cachePct: 42, ...overrides,
@@ -388,8 +388,12 @@ export function buildWidgetLines(
388
388
  if (wd.tierTrace && wd.fresh) {
389
389
  lines.push(panelLine(` ${pulse}${wd.tierTrace}`, width, panelBg));
390
390
  } else if (wd.ticker.length > 0) {
391
- const step = Math.floor(Date.now() / 250);
392
- const idx = wd.ticker.length - 1 - (step % wd.ticker.length);
391
+ // P1: pin to the most-recent entry (no 250ms rotation). The old
392
+ // `step = floor(Date.now()/250)` re-picked the head every TUI frame,
393
+ // flipping the footer line on a 250·N ms cycle. Pinning makes the
394
+ // footer hold stable until a real state change (new pushTicker /
395
+ // tierTrace / pulsing transition). (+N more) + lastWhy are preserved.
396
+ const idx = wd.ticker.length - 1;
393
397
  const head = wd.ticker[idx].text;
394
398
  const why = wd.lastWhy ? ` ${C.gray}· ${wd.lastWhy}${C.reset}` : "";
395
399
  const more =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-mega-compact",
3
- "version": "0.8.15",
3
+ "version": "0.8.16",
4
4
  "description": "Layered, local, vector-backed context compressor for pi — supersede/collapse/cluster compaction with deduped inline recall.",
5
5
  "type": "module",
6
6
  "license": "BSD-2-Clause",
@@ -1,2 +0,0 @@
1
- import{r as i,p as j,j as e,b as N,c as w}from"./index-DMntLu-8.js";const u=[{id:"transparent",label:"Transparent (accents only)",css:{bg:null,fg:"#c9d1d9",accent:"#3fb950",mega:"#f0883e"},ansi:{bg:null,fg:"39",accent:"32",mega:"33"}},{id:"retro",label:"Retro 8-bit green",css:{bg:"#003300",fg:"#33ff33",accent:"#00ff41",mega:"#39ff14"},ansi:{bg:"40",fg:"92",accent:"92",mega:"1;92"}},{id:"orange-bold",label:"Orange bold",css:{bg:"#1a0f00",fg:"#ff8c00",accent:"#ff6b00",mega:"#ff4500"},ansi:{bg:"48;5;52",fg:"38;5;208",accent:"38;5;208",mega:"1;38;5;202"}},{id:"cyan-neon",label:"Cyan neon",css:{bg:"#001a1a",fg:"#00ffff",accent:"#22d3ee",mega:"#7df9ff"},ansi:{bg:"48;5;23",fg:"38;5;51",accent:"38;5;51",mega:"1;38;5;51"}},{id:"amber-mono",label:"Amber phosphor",css:{bg:"#1a1200",fg:"#ffb000",accent:"#ff8c00",mega:"#ff5500"},ansi:{bg:"48;5;58",fg:"38;5;214",accent:"38;5;214",mega:"1;38;5;208"}},{id:"grayscale",label:"Grayscale minimal",css:{bg:"#161616",fg:"#b0b0b0",accent:"#8b949e",mega:"#e6edf3"},ansi:{bg:"48;5;235",fg:"38;5;249",accent:"38;5;249",mega:"1;38;5;255"}}];u.map(a=>a.id);const c={gameMode:"Turn game mode on/off (themes the widget + dashboard)",theme:"Visual theme (applies instantly)",tuiMode:"TUI widget display density",tier:"Live pressure band — climbs low→mega as context fills the window.",preset:"The env-resolved base compaction preset (low/medium/high/ultra/mega) that set the token threshold.",pressure:"Live pressure = currentTokens / threshold — % of the model context window (threshold fires at the tier's % of window).",threshold:"Compaction threshold = tierPct × model context window — mega-compact trims BELOW pi's native ~80% auto-compact for any model size.",fastGate:"Fast-gate arming floor — the live trim arms once context passes this % of the window."};function y(a,d,l){let o=a.toLocaleString();return d!=null&&l>0&&(o+=` (${Math.round(d*100)}% of ${l.toLocaleString()})`),o}function T(a){return`${Math.round((a||0)*100)}%`}function M(){const[a,d]=i.useState(null),[l,o]=i.useState(null),[m,g]=i.useState(!1);i.useEffect(()=>{let s=!0;const t=async()=>{try{const r=await N();s&&d(r)}catch{}};t();const f=setInterval(()=>void t(),5e3);return()=>{s=!1,clearInterval(f)}},[]),i.useEffect(()=>{let s=!0;const t=async()=>{try{const r=await w();s&&(o(r),r.theme&&(document.documentElement.dataset.theme=r.theme))}catch{}};t();const f=setInterval(()=>void t(),5e3);return()=>{s=!1,clearInterval(f)}},[]);const h=i.useCallback(async s=>{g(!0);try{const t=await j(s);o(t),t.theme&&(document.documentElement.dataset.theme=t.theme)}catch{}g(!1)},[]),p=l?.game_mode_on??!1,b=l?.theme??"transparent",x=l?.tui_display_mode??"full",n=a?.config,v=a?.context.contextWindow??0;return e.jsxs("div",{className:"config-tab",children:[e.jsxs("section",{className:"config-settings",children:[e.jsx("h3",{children:"Settings"}),e.jsx("div",{className:"settings-row",children:e.jsxs("label",{title:c.gameMode,children:[e.jsx("input",{type:"checkbox",checked:p,onChange:s=>h({game_mode_on:s.currentTarget.checked}),disabled:m}),"Game Mode"]})}),e.jsx("div",{className:"settings-row",children:e.jsxs("label",{title:c.theme,children:["Theme",e.jsx("select",{value:b,onChange:s=>h({theme:s.currentTarget.value}),disabled:m,children:u.map(s=>e.jsx("option",{value:s.id,children:s.label},s.id))})]})}),e.jsx("div",{className:"settings-row",children:e.jsxs("label",{title:c.tuiMode,children:["TUI Mode",e.jsxs("select",{value:x,onChange:s=>h({tui_display_mode:s.currentTarget.value}),disabled:m,children:[e.jsx("option",{value:"full",children:"Full"}),e.jsx("option",{value:"minimal",children:"Minimal"})]})]})})]}),e.jsxs("section",{className:"config-display",children:[e.jsx("h3",{children:"Configuration"}),e.jsxs("div",{className:"config-grid",children:[e.jsxs("div",{className:"config-item",children:[e.jsx("span",{className:"config-label",title:c.tier,children:"Tier"}),e.jsx("span",{className:"config-value",children:a?`${a.tier} (live)`:"—"})]}),e.jsxs("div",{className:"config-item",children:[e.jsx("span",{className:"config-label",title:c.preset,children:"Preset"}),e.jsx("span",{className:"config-value",children:a?.presetTier??"—"})]}),e.jsxs("div",{className:"config-item",children:[e.jsx("span",{className:"config-label",title:c.pressure,children:"Pressure"}),e.jsx("span",{className:"config-value",children:a?T(a.pressure):"—"})]}),e.jsxs("div",{className:"config-item",children:[e.jsx("span",{className:"config-label",title:c.threshold,children:"Threshold"}),e.jsx("span",{className:"config-value",children:n?y(n.thresholdTokens,n.tierPct,v):"—"})]}),e.jsxs("div",{className:"config-item",children:[e.jsx("span",{className:"config-label",title:c.fastGate,children:"Fast Gate"}),e.jsx("span",{className:"config-value",children:n?`${n.fastGatePct}%`:"—"})]}),e.jsxs("div",{className:"config-item",children:[e.jsx("span",{className:"config-label",children:"Auto"}),e.jsx("span",{className:"config-value",children:n?n.auto?"enabled":"disabled":"—"})]}),e.jsxs("div",{className:"config-item",children:[e.jsx("span",{className:"config-label",children:"Anchor"}),e.jsx("span",{className:"config-value",children:n?.anchorUserMessages??"—"})]})]})]})]})}export{M as default};
2
- //# sourceMappingURL=ConfigTab-C3g3smRL.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConfigTab-C3g3smRL.js","sources":["../../../../src/config/themes.ts","../../src/tabs/ConfigTab.tsx"],"sourcesContent":["/**\n * themes.ts — SINGLE SOURCE OF TRUTH for game-mode visual-effect themes (S30).\n *\n * Each theme defines BOTH an HTML/CSS palette (dashboard) AND an ANSI accent\n * mapping (TUI widget), since the TUI is ANSI and the dashboard is HTML.\n *\n * Theme scope (QA1 correction): themes restyle the mega-compact statusbar\n * widget + the whole dashboard HTML page. We do NOT theme pi's chrome.\n *\n * `transparent` (default) semantics: no background fill, colored accents only —\n * so game-mode stays visible against any terminal background.\n *\n * PREVENT-PI-004: pure config, no network. Pi-agnostic: no pi runtime types.\n */\n\n/** HTML/CSS palette for the dashboard (hex strings, or `null` for \"no bg\"). */\nexport interface ThemeCss {\n /** Page/cell background hex, or `null` for transparent (no bg fill). */\n bg: string | null;\n /** Default foreground (text) hex. */\n fg: string;\n /** Accent hex (bars, highlights, level numbers). */\n accent: string;\n /** MEGA CACHE highlight hex (fires at cache >= 100%). */\n mega: string;\n}\n\n/** ANSI accent mapping for the TUI widget (SGR parameter strings, no `\\x1b[`).\n * `bg` is `null` for transparent themes (no background fill). */\nexport interface ThemeAnsi {\n /** Background SGR params (e.g. \"48;5;23\"), or `null` for no bg fill. */\n bg: string | null;\n /** Foreground SGR params (e.g. \"39\" for default, \"92\" for bright green). */\n fg: string;\n /** Accent SGR params. */\n accent: string;\n /** MEGA CACHE SGR params (fires at cache >= 100%). */\n mega: string;\n}\n\n/** A complete theme = CSS palette + ANSI mapping + display metadata. */\nexport interface Theme {\n id: string;\n label: string;\n css: ThemeCss;\n ansi: ThemeAnsi;\n}\n\nexport const DEFAULT_THEME = \"transparent\";\n\nexport const THEMES: readonly Theme[] = [\n {\n id: \"transparent\",\n label: \"Transparent (accents only)\",\n css: { bg: null, fg: \"#c9d1d9\", accent: \"#3fb950\", mega: \"#f0883e\" },\n ansi: { bg: null, fg: \"39\", accent: \"32\", mega: \"33\" },\n },\n {\n id: \"retro\",\n label: \"Retro 8-bit green\",\n css: { bg: \"#003300\", fg: \"#33ff33\", accent: \"#00ff41\", mega: \"#39ff14\" },\n ansi: { bg: \"40\", fg: \"92\", accent: \"92\", mega: \"1;92\" },\n },\n {\n id: \"orange-bold\",\n label: \"Orange bold\",\n css: { bg: \"#1a0f00\", fg: \"#ff8c00\", accent: \"#ff6b00\", mega: \"#ff4500\" },\n ansi: { bg: \"48;5;52\", fg: \"38;5;208\", accent: \"38;5;208\", mega: \"1;38;5;202\" },\n },\n {\n id: \"cyan-neon\",\n label: \"Cyan neon\",\n css: { bg: \"#001a1a\", fg: \"#00ffff\", accent: \"#22d3ee\", mega: \"#7df9ff\" },\n ansi: { bg: \"48;5;23\", fg: \"38;5;51\", accent: \"38;5;51\", mega: \"1;38;5;51\" },\n },\n {\n id: \"amber-mono\",\n label: \"Amber phosphor\",\n css: { bg: \"#1a1200\", fg: \"#ffb000\", accent: \"#ff8c00\", mega: \"#ff5500\" },\n ansi: { bg: \"48;5;58\", fg: \"38;5;214\", accent: \"38;5;214\", mega: \"1;38;5;208\" },\n },\n {\n id: \"grayscale\",\n label: \"Grayscale minimal\",\n css: { bg: \"#161616\", fg: \"#b0b0b0\", accent: \"#8b949e\", mega: \"#e6edf3\" },\n ansi: { bg: \"48;5;235\", fg: \"38;5;249\", accent: \"38;5;249\", mega: \"1;38;5;255\" },\n },\n] as const;\n\n/** All valid theme ids, in definition order (used for `theme next` cycling). */\nexport const THEME_IDS: readonly string[] = THEMES.map((t) => t.id);\n\n/** Look up a theme by id; returns `undefined` for an unknown id (caller\n * validates + falls back to DEFAULT_THEME). */\nexport function getTheme(id: string): Theme | undefined {\n return THEMES.find((t) => t.id === id);\n}\n\n/** True if `id` is a known theme id. */\nexport function isValidTheme(id: string): boolean {\n return THEME_IDS.includes(id);\n}\n\n/** Cycle to the next theme id (wraps at the end). Falls back to DEFAULT_THEME\n * if `current` is unknown (defensive — the stored id should always be valid). */\nexport function nextTheme(current: string): string {\n const i = THEME_IDS.indexOf(current);\n if (i < 0) return DEFAULT_THEME;\n return THEME_IDS[(i + 1) % THEME_IDS.length]!;\n}\n\n/** CSS variable declarations for a theme's CSS palette. `bg` is `null` for the\n * transparent theme → `--bg: transparent` (no page fill, accents only). Pure,\n * no pi types. */\nexport function themeCssVars(theme: Theme): string {\n const bg = theme.css.bg ?? \"transparent\";\n return `--bg: ${bg}; --fg: ${theme.css.fg}; --accent: ${theme.css.accent}; --mega: ${theme.css.mega};`;\n}\n\n/** A `:root[data-theme=\"<id>\"]` override block carrying the theme's CSS vars,\n * for client-side instant theme switching. Pure, no pi types. */\nexport function themeDataBlock(theme: Theme): string {\n return `:root[data-theme=\"${theme.id}\"]{ ${themeCssVars(theme)} }`;\n}\n","/**\n * dashboard-client/src/tabs/ConfigTab.tsx — Config tab (C3).\n *\n * Full configuration editor:\n * (1) Game mode toggle (checkbox)\n * (2) Theme selector (dropdown) from src/config/themes.ts THEMES array\n * (3) TUI mode selector (Full/Minimal dropdown)\n * (4) Read-only config display section from snapshot (Tier, Preset, Pressure,\n * Threshold, Fast Gate, Auto, Anchor) with verbatim tooltips from html.ts.\n *\n * Uses fetchGameState() to load current state, putGameState() to save changes.\n * Polls gameState and snapshot every 5s. Applies theme by setting\n * document.documentElement.dataset.theme.\n */\n\nimport type React from \"react\";\nimport { useState, useEffect, useCallback } from \"react\";\nimport type { SnapshotResponse, GameStatePatch } from \"@contracts\";\nimport { fetchSnapshot, fetchGameState, putGameState } from \"../api/client\";\nimport { THEMES } from \"../../../../src/config/themes\";\n\n/** Actual flat game state returned by the server (the server returns a flat\n * { game_mode_on, theme, tui_display_mode } shape, NOT the contract's nested\n * { config: { enabled, theme, displayMode }, activeRitual } shape). */\ninterface FlatGameState {\n\tgame_mode_on: boolean;\n\ttheme: string;\n\ttui_display_mode: \"full\" | \"minimal\";\n}\ntype FlatGameStatePatch = Partial<FlatGameState>;\n\n/** Extended snapshot config — the runtime includes tierPct (not in contract). */\ninterface ConfigExt extends SnapshotResponse[\"config\"] {\n\ttierPct?: number | null;\n}\n\n/* Tooltips copied verbatim from extensions/dashboard-server/html.ts */\nconst TOOLTIPS = {\n\tgameMode: \"Turn game mode on/off (themes the widget + dashboard)\",\n\ttheme: \"Visual theme (applies instantly)\",\n\ttuiMode: \"TUI widget display density\",\n\ttier: \"Live pressure band — climbs low\\u2192mega as context fills the window.\",\n\tpreset:\n\t\t\"The env-resolved base compaction preset (low/medium/high/ultra/mega) that set the token threshold.\",\n\tpressure:\n\t\t\"Live pressure = currentTokens / threshold \\u2014 % of the model context window (threshold fires at the tier's % of window).\",\n\tthreshold:\n\t\t\"Compaction threshold = tierPct \\u00d7 model context window \\u2014 mega-compact trims BELOW pi's native ~80% auto-compact for any model size.\",\n\tfastGate:\n\t\t\"Fast-gate arming floor \\u2014 the live trim arms once context passes this % of the window.\",\n} as const;\n\nfunction formatThreshold(\n\ttokens: number,\n\ttierPct: number | null | undefined,\n\tcw: number,\n): string {\n\tlet txt = tokens.toLocaleString();\n\tif (tierPct != null && cw > 0) {\n\t\ttxt += ` (${Math.round(tierPct * 100)}% of ${cw.toLocaleString()})`;\n\t}\n\treturn txt;\n}\n\nfunction formatPressure(pressure: number): string {\n\t/* Runtime sends 0\\u20131 fraction despite contract saying 0\\u2013100. */\n\treturn `${Math.round((pressure || 0) * 100)}%`;\n}\n\nexport default function ConfigTab(): React.ReactElement {\n\tconst [snapshot, setSnapshot] = useState<SnapshotResponse | null>(null);\n\tconst [gameState, setGameState] = useState<FlatGameState | null>(null);\n\tconst [saving, setSaving] = useState(false);\n\n\t/* Poll snapshot every 5s for config display section. */\n\tuseEffect(() => {\n\t\tlet active = true;\n\t\tconst doFetch = async (): Promise<void> => {\n\t\t\ttry {\n\t\t\t\tconst s = await fetchSnapshot();\n\t\t\t\tif (active) setSnapshot(s);\n\t\t\t} catch {\n\t\t\t\t/* non-fatal */\n\t\t\t}\n\t\t};\n\t\tvoid doFetch();\n\t\tconst timer = setInterval(() => void doFetch(), 5000);\n\t\treturn () => {\n\t\t\tactive = false;\n\t\t\tclearInterval(timer);\n\t\t};\n\t}, []);\n\n\t/* Poll game state every 5s. */\n\tuseEffect(() => {\n\t\tlet active = true;\n\t\tconst doFetch = async (): Promise<void> => {\n\t\t\ttry {\n\t\t\t\tconst gs = (await fetchGameState()) as unknown as FlatGameState;\n\t\t\t\tif (active) {\n\t\t\t\t\tsetGameState(gs);\n\t\t\t\t\tif (gs.theme)\n\t\t\t\t\t\tdocument.documentElement.dataset.theme = gs.theme;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t/* non-fatal */\n\t\t\t}\n\t\t};\n\t\tvoid doFetch();\n\t\tconst timer = setInterval(() => void doFetch(), 5000);\n\t\treturn () => {\n\t\t\tactive = false;\n\t\t\tclearInterval(timer);\n\t\t};\n\t}, []);\n\n\t/* PUT a patch to the server immediately on change. */\n\tconst handlePatch = useCallback(async (patch: FlatGameStatePatch) => {\n\t\tsetSaving(true);\n\t\ttry {\n\t\t\tconst result = (await putGameState(\n\t\t\t\tpatch as unknown as GameStatePatch,\n\t\t\t)) as unknown as FlatGameState;\n\t\t\tsetGameState(result);\n\t\t\tif (result.theme)\n\t\t\t\tdocument.documentElement.dataset.theme = result.theme;\n\t\t} catch {\n\t\t\t/* non-fatal */\n\t\t}\n\t\tsetSaving(false);\n\t}, []);\n\n\tconst gmOn = gameState?.game_mode_on ?? false;\n\tconst themeVal = gameState?.theme ?? \"transparent\";\n\tconst tuiVal = gameState?.tui_display_mode ?? \"full\";\n\n\tconst cfg = snapshot?.config as ConfigExt | undefined;\n\tconst cw = snapshot?.context.contextWindow ?? 0;\n\n\treturn (\n\t\t<div className=\"config-tab\">\n\t\t\t<section className=\"config-settings\">\n\t\t\t\t<h3>Settings</h3>\n\t\t\t\t<div className=\"settings-row\">\n\t\t\t\t\t<label title={TOOLTIPS.gameMode}>\n\t\t\t\t\t\t<input\n\t\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\t\tchecked={gmOn}\n\t\t\t\t\t\t\tonChange={(e) =>\n\t\t\t\t\t\t\t\thandlePatch({ game_mode_on: e.currentTarget.checked })\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdisabled={saving}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\tGame Mode\n\t\t\t\t\t</label>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"settings-row\">\n\t\t\t\t\t<label title={TOOLTIPS.theme}>\n\t\t\t\t\t\tTheme\n\t\t\t\t\t\t<select\n\t\t\t\t\t\t\tvalue={themeVal}\n\t\t\t\t\t\t\tonChange={(e) => handlePatch({ theme: e.currentTarget.value })}\n\t\t\t\t\t\t\tdisabled={saving}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{THEMES.map((t) => (\n\t\t\t\t\t\t\t\t<option key={t.id} value={t.id}>\n\t\t\t\t\t\t\t\t\t{t.label}\n\t\t\t\t\t\t\t\t</option>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t</select>\n\t\t\t\t\t</label>\n\t\t\t\t</div>\n\t\t\t\t<div className=\"settings-row\">\n\t\t\t\t\t<label title={TOOLTIPS.tuiMode}>\n\t\t\t\t\t\tTUI Mode\n\t\t\t\t\t\t<select\n\t\t\t\t\t\t\tvalue={tuiVal}\n\t\t\t\t\t\t\tonChange={(e) =>\n\t\t\t\t\t\t\t\thandlePatch({\n\t\t\t\t\t\t\t\t\ttui_display_mode: e.currentTarget.value as \"full\" | \"minimal\",\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdisabled={saving}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<option value=\"full\">Full</option>\n\t\t\t\t\t\t\t<option value=\"minimal\">Minimal</option>\n\t\t\t\t\t\t</select>\n\t\t\t\t\t</label>\n\t\t\t\t</div>\n\t\t\t</section>\n\n\t\t\t<section className=\"config-display\">\n\t\t\t\t<h3>Configuration</h3>\n\t\t\t\t<div className=\"config-grid\">\n\t\t\t\t\t<div className=\"config-item\">\n\t\t\t\t\t\t<span className=\"config-label\" title={TOOLTIPS.tier}>\n\t\t\t\t\t\t\tTier\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"config-value\">\n\t\t\t\t\t\t\t{snapshot ? `${snapshot.tier} (live)` : \"\\u2014\"}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"config-item\">\n\t\t\t\t\t\t<span className=\"config-label\" title={TOOLTIPS.preset}>\n\t\t\t\t\t\t\tPreset\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"config-value\">\n\t\t\t\t\t\t\t{snapshot?.presetTier ?? \"\\u2014\"}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"config-item\">\n\t\t\t\t\t\t<span className=\"config-label\" title={TOOLTIPS.pressure}>\n\t\t\t\t\t\t\tPressure\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"config-value\">\n\t\t\t\t\t\t\t{snapshot ? formatPressure(snapshot.pressure) : \"\\u2014\"}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"config-item\">\n\t\t\t\t\t\t<span className=\"config-label\" title={TOOLTIPS.threshold}>\n\t\t\t\t\t\t\tThreshold\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"config-value\">\n\t\t\t\t\t\t\t{cfg ? formatThreshold(cfg.thresholdTokens, cfg.tierPct, cw) : \"\\u2014\"}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"config-item\">\n\t\t\t\t\t\t<span className=\"config-label\" title={TOOLTIPS.fastGate}>\n\t\t\t\t\t\t\tFast Gate\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span className=\"config-value\">\n\t\t\t\t\t\t\t{cfg ? `${cfg.fastGatePct}%` : \"\\u2014\"}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"config-item\">\n\t\t\t\t\t\t<span className=\"config-label\">Auto</span>\n\t\t\t\t\t\t<span className=\"config-value\">\n\t\t\t\t\t\t\t{cfg ? (cfg.auto ? \"enabled\" : \"disabled\") : \"\\u2014\"}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"config-item\">\n\t\t\t\t\t\t<span className=\"config-label\">Anchor</span>\n\t\t\t\t\t\t<span className=\"config-value\">\n\t\t\t\t\t\t\t{cfg?.anchorUserMessages ?? \"\\u2014\"}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</section>\n\t\t</div>\n\t);\n}\n"],"names":["THEMES","t","TOOLTIPS","formatThreshold","tokens","tierPct","cw","txt","formatPressure","pressure","ConfigTab","snapshot","setSnapshot","useState","gameState","setGameState","saving","setSaving","useEffect","active","doFetch","s","fetchSnapshot","timer","gs","fetchGameState","handlePatch","useCallback","patch","result","putGameState","gmOn","themeVal","tuiVal","cfg","jsxs","jsx","e"],"mappings":"oEAkDO,MAAMA,EAA2B,CACtC,CACE,GAAI,cACJ,MAAO,6BACP,IAAK,CAAE,GAAI,KAAM,GAAI,UAAW,OAAQ,UAAW,KAAM,SAAA,EACzD,KAAM,CAAE,GAAI,KAAM,GAAI,KAAM,OAAQ,KAAM,KAAM,IAAA,CAAK,EAEvD,CACE,GAAI,QACJ,MAAO,oBACP,IAAK,CAAE,GAAI,UAAW,GAAI,UAAW,OAAQ,UAAW,KAAM,SAAA,EAC9D,KAAM,CAAE,GAAI,KAAM,GAAI,KAAM,OAAQ,KAAM,KAAM,MAAA,CAAO,EAEzD,CACE,GAAI,cACJ,MAAO,cACP,IAAK,CAAE,GAAI,UAAW,GAAI,UAAW,OAAQ,UAAW,KAAM,SAAA,EAC9D,KAAM,CAAE,GAAI,UAAW,GAAI,WAAY,OAAQ,WAAY,KAAM,YAAA,CAAa,EAEhF,CACE,GAAI,YACJ,MAAO,YACP,IAAK,CAAE,GAAI,UAAW,GAAI,UAAW,OAAQ,UAAW,KAAM,SAAA,EAC9D,KAAM,CAAE,GAAI,UAAW,GAAI,UAAW,OAAQ,UAAW,KAAM,WAAA,CAAY,EAE7E,CACE,GAAI,aACJ,MAAO,iBACP,IAAK,CAAE,GAAI,UAAW,GAAI,UAAW,OAAQ,UAAW,KAAM,SAAA,EAC9D,KAAM,CAAE,GAAI,UAAW,GAAI,WAAY,OAAQ,WAAY,KAAM,YAAA,CAAa,EAEhF,CACE,GAAI,YACJ,MAAO,oBACP,IAAK,CAAE,GAAI,UAAW,GAAI,UAAW,OAAQ,UAAW,KAAM,SAAA,EAC9D,KAAM,CAAE,GAAI,WAAY,GAAI,WAAY,OAAQ,WAAY,KAAM,YAAA,CAAa,CAEnF,EAG4CA,EAAO,IAAKC,GAAMA,E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