counterparts 0.3.2 → 0.3.4

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 (153) hide show
  1. package/CHANGELOG.md +153 -0
  2. package/docs/module-map.md +3 -2
  3. package/package.json +1 -1
  4. package/src/adapters/claude-code/NOTES.md +28 -0
  5. package/src/adapters/claude-code/bin/hook.ts +85 -22
  6. package/src/adapters/claude-code/config.ts +7 -0
  7. package/src/adapters/claude-code/doctor.ts +166 -4
  8. package/src/adapters/claude-code/hooks.ts +185 -6
  9. package/src/adapters/claude-code/index.ts +3 -0
  10. package/src/adapters/claude-code/transcript.ts +7 -0
  11. package/src/adapters/cli/CONTRACT.md +11 -0
  12. package/src/adapters/cli/INTERFACE-GAPS.md +16 -0
  13. package/src/adapters/cli/NOTES.md +25 -0
  14. package/src/adapters/cli/commands.ts +184 -4
  15. package/src/adapters/cli/dream-core.ts +126 -0
  16. package/src/adapters/cli/help.ts +17 -0
  17. package/src/adapters/cli/mechanisms.ts +199 -106
  18. package/src/adapters/dashboard/CONTRACT.md +5 -0
  19. package/src/adapters/dashboard/INTERFACE-GAPS.md +12 -0
  20. package/src/adapters/dashboard/NOTES.md +38 -0
  21. package/src/adapters/dashboard/registries.ts +35 -1
  22. package/src/adapters/dashboard/web/README.md +63 -26
  23. package/src/adapters/dashboard/web/app.html +2 -0
  24. package/src/adapters/dashboard/web/flow.ts +14 -0
  25. package/src/adapters/dashboard/web/lanes.ts +141 -0
  26. package/src/adapters/dashboard/web/mechanisms/association/index.js +1 -2
  27. package/src/adapters/dashboard/web/mechanisms/consolidation/index.js +8 -5
  28. package/src/adapters/dashboard/web/mechanisms/consolidation/panel.js +7 -7
  29. package/src/adapters/dashboard/web/mechanisms/decay/index.js +1 -2
  30. package/src/adapters/dashboard/web/mechanisms/dreaming/index.js +19 -0
  31. package/src/adapters/dashboard/web/mechanisms/emotional/index.js +9 -6
  32. package/src/adapters/dashboard/web/mechanisms/episodic-semantic/index.js +4 -5
  33. package/src/adapters/dashboard/web/mechanisms/index.js +5 -3
  34. package/src/adapters/dashboard/web/mechanisms/interference/index.js +1 -2
  35. package/src/adapters/dashboard/web/mechanisms/prospective/index.js +7 -5
  36. package/src/adapters/dashboard/web/mechanisms/reconsolidation/index.js +1 -2
  37. package/src/adapters/dashboard/web/mechanisms/regions.js +1 -1
  38. package/src/adapters/dashboard/web/mechanisms/retrieval/index.js +1 -2
  39. package/src/adapters/dashboard/web/mechanisms/salience/index.js +1 -2
  40. package/src/adapters/dashboard/web/mechanisms/schema/index.js +1 -2
  41. package/src/adapters/dashboard/web/narrate.ts +76 -13
  42. package/src/adapters/dashboard/web/pages/health/sections/checks.js +17 -1
  43. package/src/adapters/dashboard/web/pages/home/home.css +29 -13
  44. package/src/adapters/dashboard/web/pages/home/index.js +2 -0
  45. package/src/adapters/dashboard/web/pages/home/sections/explorer.js +22 -7
  46. package/src/adapters/dashboard/web/pages/home/sections/hero.js +15 -3
  47. package/src/adapters/dashboard/web/pages/home/sections/live-activity.js +15 -9
  48. package/src/adapters/dashboard/web/pages/home/sections/recent-chapters.js +6 -2
  49. package/src/adapters/dashboard/web/pages/home/sections/tiles.js +35 -18
  50. package/src/adapters/dashboard/web/pages/memories/index.js +30 -36
  51. package/src/adapters/dashboard/web/pages/memories/memories.css +97 -72
  52. package/src/adapters/dashboard/web/pages/memories/row.js +51 -0
  53. package/src/adapters/dashboard/web/pages/memories/sections/feel.js +176 -0
  54. package/src/adapters/dashboard/web/pages/memories/sections/hold.js +67 -0
  55. package/src/adapters/dashboard/web/pages/memories/sections/list.js +65 -43
  56. package/src/adapters/dashboard/web/pages/memories/sections/search.js +26 -23
  57. package/src/adapters/dashboard/web/pages/memories/state.js +12 -5
  58. package/src/adapters/dashboard/web/pages/self/index.js +57 -16
  59. package/src/adapters/dashboard/web/pages/self/sections/dreams.js +76 -0
  60. package/src/adapters/dashboard/web/pages/self/sections/journal.js +75 -19
  61. package/src/adapters/dashboard/web/pages/self/sections/page.js +108 -65
  62. package/src/adapters/dashboard/web/pages/self/sections/settling.js +129 -104
  63. package/src/adapters/dashboard/web/pages/self/sections/wake.js +31 -15
  64. package/src/adapters/dashboard/web/pages/self/self.css +122 -59
  65. package/src/adapters/dashboard/web/pages/self/state.js +21 -0
  66. package/src/adapters/dashboard/web/server.ts +9 -0
  67. package/src/adapters/dashboard/web/shared/memory-marks.css +17 -0
  68. package/src/adapters/dashboard/web/shared/memory-marks.js +81 -0
  69. package/src/adapters/dashboard/web/shared/memory-modal.js +240 -53
  70. package/src/adapters/dashboard/web/shared/modal.css +67 -0
  71. package/src/adapters/dashboard/web/shared/tip.js +1 -1
  72. package/src/adapters/dashboard/web/shared/widgets/feed.css +4 -0
  73. package/src/adapters/dashboard/web/shared/widgets/feed.js +56 -14
  74. package/src/adapters/dashboard/web/shared/widgets/light.css +1 -0
  75. package/src/adapters/dashboard/web/shared/widgets/light.js +7 -5
  76. package/src/adapters/dashboard/web/shared/widgets/tips.css +19 -0
  77. package/src/adapters/dashboard/web/shared/widgets/tips.js +56 -0
  78. package/src/adapters/dashboard/web/views/activity.ts +18 -2
  79. package/src/adapters/dashboard/web/views/archive-words.ts +27 -10
  80. package/src/adapters/dashboard/web/views/dreams.ts +199 -0
  81. package/src/adapters/dashboard/web/views/mechanism-panel.ts +116 -35
  82. package/src/adapters/dashboard/web/views/mechanisms.ts +81 -255
  83. package/src/adapters/dashboard/web/views/memories.ts +245 -43
  84. package/src/adapters/dashboard/web/views/memory-words.ts +133 -0
  85. package/src/adapters/dashboard/web/views/memory.ts +226 -4
  86. package/src/adapters/dashboard/web/views/mind.ts +261 -61
  87. package/src/adapters/dashboard/web/views/overview.ts +80 -42
  88. package/src/adapters/dashboard/web/views/search.ts +35 -1
  89. package/src/adapters/dashboard/web/views/shared.ts +14 -0
  90. package/src/adapters/dashboard/web/views.ts +2 -0
  91. package/src/adapters/feelings-line.ts +74 -0
  92. package/src/adapters/fired.ts +163 -23
  93. package/src/adapters/mcp/CONTRACT.md +8 -0
  94. package/src/adapters/mcp/NOTES.md +56 -0
  95. package/src/adapters/mcp/server.ts +254 -6
  96. package/src/adapters/mcp/tools.ts +180 -5
  97. package/src/adapters/mechanism-evidence.ts +465 -0
  98. package/src/core/bridge.ts +21 -16
  99. package/src/core/counterpart.ts +422 -10
  100. package/src/core/dream/CONTRACT.md +143 -0
  101. package/src/core/dream/INTERFACE-GAPS.md +24 -0
  102. package/src/core/dream/NOTES.md +84 -0
  103. package/src/core/dream/index.ts +1067 -0
  104. package/src/core/dream/mark.ts +14 -0
  105. package/src/core/dream/tunables.ts +56 -0
  106. package/src/core/encode/CONTRACT.md +7 -1
  107. package/src/core/feelings-wheel.ts +171 -13
  108. package/src/core/mint.ts +9 -0
  109. package/src/core/physics/CONTRACT.md +132 -21
  110. package/src/core/physics/NOTES.md +233 -0
  111. package/src/core/physics/index.ts +419 -50
  112. package/src/core/prospective/CONTRACT.md +35 -6
  113. package/src/core/prospective/INTERFACE-GAPS.md +10 -5
  114. package/src/core/prospective/NOTES.md +175 -4
  115. package/src/core/prospective/derive.ts +32 -3
  116. package/src/core/prospective/index.ts +362 -39
  117. package/src/core/prospective/tunables.ts +18 -1
  118. package/src/core/prospective/windows.ts +104 -46
  119. package/src/core/recall/CONTRACT.md +28 -0
  120. package/src/core/recall/NOTES.md +55 -0
  121. package/src/core/recall/activate.ts +32 -5
  122. package/src/core/recall/gate.ts +7 -1
  123. package/src/core/recall/index.ts +28 -2
  124. package/src/core/recall/mood.ts +106 -0
  125. package/src/core/recall/tunables.ts +26 -0
  126. package/src/core/remember/CONTRACT.md +5 -0
  127. package/src/core/remember/index.ts +1 -0
  128. package/src/core/remember/proposals.ts +86 -3
  129. package/src/core/remember/spans.ts +11 -1
  130. package/src/core/self/CONTRACT.md +3 -0
  131. package/src/core/self/INTERFACE-GAPS.md +7 -0
  132. package/src/core/self/NOTES.md +30 -0
  133. package/src/core/self/identity.ts +115 -6
  134. package/src/core/self/index.ts +17 -0
  135. package/src/core/self/tunables.ts +17 -0
  136. package/src/core/sleep/CONTRACT.md +17 -1
  137. package/src/core/sleep/INTERFACE-GAPS.md +19 -0
  138. package/src/core/sleep/NOTES.md +36 -0
  139. package/src/core/sleep/consolidate.ts +149 -96
  140. package/src/core/sleep/decay.ts +11 -0
  141. package/src/core/sleep/index.ts +4 -1
  142. package/src/core/sleep/tunables.ts +9 -0
  143. package/src/core/sleep/types.ts +17 -0
  144. package/src/core/sleep/upgrade.ts +168 -0
  145. package/src/core/store/CONTRACT.md +21 -2
  146. package/src/core/store/NOTES.md +68 -0
  147. package/src/core/store/feelings.ts +23 -6
  148. package/src/core/store/index.ts +716 -17
  149. package/src/core/store/operational.ts +329 -4
  150. package/src/core/store/owner-op-seam.ts +79 -1
  151. package/src/core/types.ts +37 -0
  152. package/src/adapters/dashboard/web/pages/memories/sections/constellation.js +0 -178
  153. package/src/adapters/dashboard/web/pages/memories/sections/kinds.js +0 -42
@@ -1,11 +1,19 @@
1
1
  /* One memory, opened — from any row, dot or reference on any page. Resolved at
2
- the moment it is opened, so a memory that left the store says so. */
2
+ the moment it is opened, so a memory that left the store says so.
3
+
4
+ Top to bottom (2026-09-26, an experiment): the title and the words; how
5
+ strong it is and where it heads if unused; why it mattered; the days it was
6
+ used; its standing in plain words; its feelings; what it is linked to; its
7
+ versions; a few small chips (model, the date it is about, when it was
8
+ recorded); and a "details" fold with the raw numbers. A part with nothing in
9
+ it is left out. */
3
10
  import { act, resultHtml } from "./actions.js";
4
11
  import { api, fail } from "./api.js";
5
12
  import { emptyBox } from "./absence.js";
6
13
  import { esc } from "./dom.js";
7
14
  import { headline, n2, n3, said } from "./format.js";
8
- import { openModal, section } from "./modal.js";
15
+ import { FEELING_COLOURS, kindMark, kindOf, shortDate } from "./memory-marks.js";
16
+ import { openModal } from "./modal.js";
9
17
  import { confirmTyped } from "./widgets/confirm.js";
10
18
 
11
19
  export async function openMemory(id) {
@@ -17,61 +25,240 @@ export async function openMemory(id) {
17
25
  emptyBox(d.absence || "[no longer at this address]",
18
26
  "Ids are resolved at the moment a page is drawn, so a memory that has left the store stops resolving immediately."));
19
27
  }
28
+ openModal(memoryCard(d));
29
+ }
30
+
31
+ /** The card's markup — pure, from the `/api/memory` payload. */
32
+ export function memoryCard(d) {
33
+ const k = kindOf(d.kind);
34
+ const title = d.title ? esc(d.title) : d.confidential ? said(d.text, true) : esc(headline(d.shownText || d.text));
35
+ return '<div class="mc' + (d.archived ? " mc-arch" : "") + '">' +
36
+ '<h3 class="mc-title">' + kindMark(d.kind, false) + "<span>" + title + "</span></h3>" +
37
+ '<div class="mc-kind">' + esc(k.label) + (d.askedFor ? " · you asked for " + esc(d.askedFor) + ", which forwards here" : "") + "</div>" +
38
+ (d.archived ? '<div class="mc-archived">Archived — ' + esc(d.archivedWords || d.archived) + ". Kept, not deleted.</div>" : "") +
39
+ "<div class='body'>" + (d.confidential ? '<span class="withheld">' + esc(d.text) + "</span>" : esc(d.shownText || d.text)) + "</div>" +
40
+ (d.journal
41
+ ? '<p class="mc-note">A journal entry, not a memory: the account memories are made from. It sits outside every sleep phase, and nothing here decays.</p>'
42
+ : "") +
43
+ part("How strong", curvePart(d)) +
44
+ part("Why it mattered", fingerprint(d)) +
45
+ part("Use", usePart(d)) +
46
+ part("Standing", standing(d)) +
47
+ part("Feelings", feelingsPart(d)) +
48
+ part("Linked memories", linked(d)) +
49
+ part("Versions", versions(d)) +
50
+ chips(d) +
51
+ footer(d) +
52
+ "</div>";
53
+ }
54
+
55
+ /** A titled part, or nothing at all when it has nothing in it. */
56
+ function part(title, body) {
57
+ return body ? '<section class="mc-part"><h4>' + esc(title) + "</h4>" + body + "</section>" : "";
58
+ }
59
+
60
+ const pct = (x) => Math.round(Math.max(0, Math.min(1, Number(x) || 0)) * 100) + "%";
61
+
62
+ // ── how strong: so far, and ahead if unused ────────────────────────────────
63
+
64
+ function curvePart(d) {
65
+ if (!d.curve) return d.curveNote && !d.journal ? '<p class="mc-line">' + esc(d.curveNote) + ".</p>" : "";
66
+ const c = d.curve;
67
+ const W = 520, H = 120, L = 8, R = 8, T = 10, B = 20;
68
+ const span = Math.max(1, c.to - c.from);
69
+ const x = (day) => L + ((day - c.from) / span) * (W - L - R);
70
+ const y = (s) => T + (1 - Math.max(0, Math.min(1, s))) * (H - T - B);
71
+ const path = (pts) => pts.map((q, i) => (i === 0 ? "M" : "L") + x(q[0]).toFixed(1) + " " + y(q[1]).toFixed(1)).join(" ");
72
+ const past = c.points.filter((q) => q[0] <= c.day);
73
+ const ahead = c.points.filter((q) => q[0] >= c.day);
74
+ const now = (c.points.find((q) => q[0] === c.day) || [c.day, d.strength])[1];
75
+ let svg = '<svg class="mc-curve" viewBox="0 0 ' + W + " " + H + '" preserveAspectRatio="none" role="img" aria-label="strength so far, and ahead if unused">' +
76
+ '<line class="mc-guide" x1="' + L + '" x2="' + (W - R) + '" y1="' + y(c.archiveLine) + '" y2="' + y(c.archiveLine) + '"/>' +
77
+ '<line class="mc-today" x1="' + x(c.day) + '" x2="' + x(c.day) + '" y1="' + T + '" y2="' + (H - B) + '"/>';
78
+ if (past.length > 1) svg += '<path d="' + path(past) + '" class="mc-past"/>';
79
+ if (ahead.length > 1) svg += '<path d="' + path(ahead) + '" class="mc-ahead"/>';
80
+ svg += '<circle cx="' + x(c.day) + '" cy="' + y(now) + '" r="4" class="mc-now"/></svg>';
81
+ const axis = '<div class="mc-axis">' + (c.from === c.day
82
+ ? "<span>today, day " + c.day + "</span>"
83
+ : "<span>last used, day " + c.from + "</span><span>today</span>") + "<span>day " + c.to + "</span></div>";
84
+ const words = "Held " + pct(now) + " now" + (c.from < c.day ? ", fading since it was last used" : "") + ". " + (c.archiveDay !== null
85
+ ? "Unused, it falls to the let-go line around lived day " + c.archiveDay + "."
86
+ : now < c.archiveLine ? "It is already under the let-go line." : "Unused, it stays above the let-go line for the next " + (c.to - c.day) + " lived days.");
87
+ return svg + axis + '<p class="mc-line">' + esc(words) +
88
+ ' <span class="mc-dim">Solid is what happened; dashed is where it heads if nobody uses it; the faint line is where it could be let go.</span></p>';
89
+ }
90
+
91
+ // ── why it mattered: a four-part fingerprint ────────────────────────────────
92
+
93
+ function fingerprint(d) {
94
+ if (d.journal || d.chapter) return "";
95
+ const s = d.salience;
96
+ const parts = [["relevance", s.relevance], ["feeling", s.emotional], ["changes what I expect", s.predictive], ["novelty", s.novelty]];
97
+ if (parts.every(([, v]) => !v)) return "";
98
+ return '<div class="mc-print">' + parts.map(([label, v]) => {
99
+ const blind = v === null;
100
+ return '<div class="mc-pbar" title="' + esc(label + ": " + (blind ? "not measured (nothing to compare it with yet)" : n2(v))) + '">' +
101
+ '<span class="mc-plabel">' + esc(label) + (blind ? ' <span class="mc-dim">· not measured</span>' : "") + "</span>" +
102
+ '<span class="mc-ptrack' + (blind ? " blind" : "") + '"><span style="width:' + (blind ? 0 : Math.round(Math.max(0, Math.min(1, v)) * 100)) + '%"></span></span>' +
103
+ "</div>";
104
+ }).join("") + "</div>";
105
+ }
106
+
107
+ // ── use: a strip of lived days, a dot on each day it was used ─────────────
108
+
109
+ function usePart(d) {
110
+ if (d.journal || d.chapter) return "";
111
+ const p = d.promotion;
112
+ if (d.uses === 0 && d.useDays.length === 0 && !p.byUse) return "";
113
+ const last = d.day;
114
+ const first = Math.max(d.bornDay, last - 59);
115
+ const used = new Set(d.useDays);
116
+ if (d.uses > 0) used.add(d.lastUsedDay);
117
+ let cells = "";
118
+ for (let day = first; day <= last; day++) {
119
+ const cls = "mc-cell" + (used.has(day) ? " used" : "") + (day === d.bornDay ? " born" : "") + (day === last ? " today" : "");
120
+ cells += '<i class="' + cls + '" title="lived day ' + day + (day === d.bornDay ? " — born" : "") + (used.has(day) ? " — used" : "") + '"></i>';
121
+ }
122
+ const shown = [...used].filter((x) => x >= first).length;
123
+ const lines = [];
124
+ if (d.uses > 0) {
125
+ lines.push("Used " + d.uses + "× over " + d.reinforcedDays + (d.reinforcedDays === 1 ? " separate day" : " separate days") +
126
+ ", last on lived day " + d.lastUsedDay + ".");
127
+ if (shown < d.reinforcedDays) lines.push("The log shows " + shown + " of those days; it keeps only so much.");
128
+ } else lines.push("Not used yet.");
129
+ if (p.byUse) {
130
+ const more = Math.max(0, p.required - p.days);
131
+ lines.push("Coming back on " + p.required + " separate days over " + p.needSpan + " makes it core" +
132
+ (more ? " — " + more + " more to go." : p.span < p.needSpan ? " — it needs to keep coming back a little longer." : "."));
133
+ }
134
+ return '<div class="mc-strip" role="img" aria-label="lived days, a dot on each day it was used">' +
135
+ (first > d.bornDay ? '<span class="mc-more">…</span>' : "") + cells + "</div>" +
136
+ '<div class="mc-axis"><span>' + (first === d.bornDay ? "born, day " + first : "day " + first) + "</span><span>today, day " + last + "</span></div>" +
137
+ '<p class="mc-line">' + esc(lines.join(" ")) + "</p>";
138
+ }
139
+
140
+ // ── standing, in plain words ────────────────────────────────────────────────
141
+
142
+ function standing(d) {
143
+ const out = [];
144
+ if (d.promoted) out.push('<span class="mbadge core">★ core</span><span>part of who I am</span>');
145
+ if (d.protected) out.push('<span class="mbadge lock">locked</span><span>protected — nothing can revise it</span>');
146
+ else if (!d.journal && !d.chapter) {
147
+ out.push("<span>revisable — a strong enough correction can change it" +
148
+ (d.pressure > 0 ? '<span class="mc-dim"> · under some pressure now (' + n2(d.pressure) + (d.bar === null ? "" : " of a bar of " + n2(d.bar)) + ")</span>" : "") +
149
+ "</span>");
150
+ }
151
+ if (d.chapter) out.push('<span class="mbadge journal">journal</span><span>a journal chapter, kept as written — not scored</span>');
152
+ return out.length ? '<ul class="mc-list">' + out.map((x) => "<li>" + x + "</li>").join("") + "</ul>" : "";
153
+ }
154
+
155
+ // ── feelings ────────────────────────────────────────────────────────────────
156
+
157
+ function feelingsPart(d) {
158
+ // Emotion part A (#244): feeling now holds a memory higher and slows its fading.
159
+ const held = d.intensity > 0 && !d.confidential
160
+ ? '<p class="mc-dim">Feeling holds it higher and slows its fading (intensity ' + n2(d.intensity) + ").</p>"
161
+ : "";
162
+ if (!d.feelings || d.feelings.length === 0) return held;
163
+ return '<ul class="mc-list">' + d.feelings.map((f) =>
164
+ '<li><i class="mc-fdot" style="background:' + (FEELING_COLOURS[f.core] || "#8a95a3") + '"></i><span>' +
165
+ (f.whose === "owner" ? "you felt " : f.whose === "self" ? "I felt " : esc(f.whose) + " felt ") + "<b>" + esc(f.word) + "</b>" +
166
+ '<span class="mc-dim"> · ' + esc(f.core) + (f.carriedBy ? " — " + esc(f.carriedBy) : "") + "</span></span></li>").join("") + "</ul>" + held;
167
+ }
168
+
169
+ // ── linked memories ────────────────────────────────────────────────────────
170
+
171
+ function ref(id, text, confidential, role) {
172
+ return '<div class="ref" role="button" tabindex="0" onclick="openMemory(\'' + esc(id) + '\')" ' +
173
+ "onkeydown=\"if(event.key==='Enter')openMemory('" + esc(id) + "')\">" +
174
+ (role ? '<span class="role">' + role + "</span>" : "") + said(text, confidential) + "</div>";
175
+ }
176
+
177
+ function linked(d) {
178
+ const around = d.points.filter((p) => p.role === "hangs on" || p.role === "grounded in")
179
+ .map((p) => ref(p.id, p.text, false, esc(p.role)));
180
+ const wired = d.edges.slice().sort((a, b) => b.weight - a.weight).map((e) =>
181
+ ref(e.id, e.text, e.confidential, '<span class="mc-wbar" title="wired together: ' + n2(e.weight) + '"><span style="width:' +
182
+ Math.round(Math.max(0, Math.min(1, e.weight)) * 100) + '%"></span></span>'));
183
+ const all = around.concat(wired);
184
+ return all.length ? '<div class="mc-refs">' + all.join("") + "</div>" : "";
185
+ }
186
+
187
+ // ── versions: one line of its lineage ──────────────────────────────────────
188
+
189
+ const REL = {
190
+ replaced: "replaced this older memory",
191
+ corrects: "corrects (the other stays as it was)",
192
+ revised: "rewritten in place",
193
+ became: "replaced by this newer memory",
194
+ };
195
+
196
+ function versions(d) {
197
+ if (!d.timeline || d.timeline.length === 0) return "";
198
+ const steps = d.timeline.map((s) => {
199
+ const when = s.day === null ? "" : "day " + s.day;
200
+ const head = '<span class="mc-vrel">' + esc(REL[s.rel] || s.rel) + "</span>" +
201
+ (when ? '<span class="mc-dim"> · ' + esc(when) + "</span>" : "") +
202
+ (s.reason && s.rel !== "corrects" ? '<span class="mc-dim"> · ' + esc(String(s.reason).replace(/-/g, " ")) + "</span>" : "");
203
+ const body = s.id ? ref(s.id, s.text, s.confidential, "") : "";
204
+ return '<li class="mc-v mc-v-' + s.rel + '"><i class="mc-vdot"></i><div>' + head + body + "</div></li>";
205
+ });
206
+ const nowAt = d.timeline.some((s) => s.rel === "became") ? "" :
207
+ '<li class="mc-v mc-v-now"><i class="mc-vdot"></i><div><span class="mc-vrel">this memory, as it stands</span>' +
208
+ '<span class="mc-dim"> · revision ' + esc(String(d.revision)) + "</span></div></li>";
209
+ return '<ol class="mc-versions">' + steps.join("") + nowAt + "</ol>";
210
+ }
211
+
212
+ // ── small chips ────────────────────────────────────────────────────────────
213
+
214
+ function chips(d) {
215
+ const c = [];
216
+ if (d.writtenDate) {
217
+ c.push('<span class="mc-chip dated" title="' + (d.chapter ? "the day its journal chapter names" : "the date written at the front of the memory") +
218
+ '">' + esc(shortDate(d.writtenDate)) + "</span>");
219
+ }
220
+ if (d.model) c.push('<span class="mc-chip model" title="the model that wrote these words">' + esc(d.model) + "</span>");
221
+ if (d.eventDate) c.push('<span class="mc-chip" title="the date this memory is about">about ' + esc(d.eventDate) + "</span>");
222
+ if (d.happenedOn) c.push('<span class="mc-chip" title="when it happened">happened ' + esc(d.happenedOn) + "</span>");
223
+ if (d.learnedOn && d.learnedOn !== "—") {
224
+ c.push('<span class="mc-chip" title="the calendar day it entered the store (on a migrated or seeded store, the day of the import)">recorded ' +
225
+ esc(d.learnedOn) + "</span>");
226
+ }
227
+ c.push('<span class="mc-chip" title="the lived day it was born">lived day ' + esc(String(d.bornDay)) + "</span>");
228
+ for (const p of d.prospective || []) {
229
+ c.push('<span class="mc-chip" title="a reminder it holds">reminder ' + esc(p.date) + " · " + esc(p.state) + "</span>");
230
+ }
231
+ return '<div class="mc-chips">' + c.join("") + "</div>";
232
+ }
233
+
234
+ // ── the details fold, and the two buttons ──────────────────────────────────
235
+
236
+ function footer(d) {
20
237
  const kv = (k, v) => '<div class="k">' + esc(k) + '</div><div class="v">' + v + "</div>";
21
238
  const s = d.salience;
22
- openModal(
23
- "<h3>" + (d.title ? esc(d.title) : d.confidential ? said(d.text, true) : esc(headline(d.text))) + "</h3>" +
24
- "<div class='sub'><span>" + esc(d.id) + "</span>" +
25
- (d.askedFor ? "<span>you asked for " + esc(d.askedFor) + ", which forwards here</span>" : "") +
26
- "<span class='path'>rev " + esc(String(d.revision)) + " · " + esc(d.contentHash || "—") + "</span>" +
239
+ const raw = '<div class="kv">' +
240
+ kv("id", esc(d.id)) +
241
+ kv("record", "rev " + esc(String(d.revision)) + " · " + esc(d.contentHash || "—")) +
242
+ kv("band", esc(d.band) + " <span class='mc-dim'>(recorded " + esc(d.recordedBand) + ")</span>") +
243
+ kv("strength", n3(d.strength) + " <span class='mc-dim'>· repetition " + n3(d.repetition) + "</span>") +
244
+ kv("salience", n3(s.combined) + " <span class='mc-dim'>relevance " + n2(s.relevance) + " · emotional " + n2(s.emotional) +
245
+ " · predictive " + n2(s.predictive) + " · novelty " + (s.novelty === null ? "blind" : n2(s.novelty)) +
246
+ (s.claimed === null ? "" : " · claimed floor " + n2(s.claimed)) + "</span>") +
247
+ (d.feelingsLine || d.intensity > 0 ? kv("feelings", esc(d.feelingsLine || "none recorded") + " <span class='mc-dim'>· intensity " + n2(d.intensity) + "</span>") : "") +
248
+ kv("lived", "born day " + d.bornDay + " · used " + d.uses + "× over " + d.reinforcedDays + " days · last used day " + d.lastUsedDay) +
249
+ kv("standing", (d.consolidated ? "consolidated" : "not consolidated") + " · " + (d.promoted ? "promoted" : "not promoted") +
250
+ " · " + (d.protected ? "protected" : "revisable") + " · pressure " + n3(d.pressure) + (d.bar === null ? "" : " / bar " + n3(d.bar))) +
251
+ (d.createdAt ? kv("written", esc(new Date(d.createdAt).toISOString())) : "") +
252
+ (d.archived ? kv("archived", esc(d.archived)) : "") +
253
+ d.points.map((p) => kv(p.role, esc(p.id))).join("") +
254
+ d.removal.map((r) => kv("removal", esc(r.stage) + " by " + esc(r.actor) + " — " + esc(r.reason || "no reason recorded"))).join("") +
255
+ "</div>";
256
+ return '<div class="mc-foot">' +
257
+ '<details class="mc-details"><summary>details</summary>' + raw + "</details>" +
258
+ '<div class="mc-buttons">' +
27
259
  "<button class='copy' data-id=\"" + esc(d.id) + "\" onclick=\"copyId(this)\">copy id</button>" +
28
260
  "<button class='copy act-danger' data-id=\"" + esc(d.id) + "\" onclick=\"removeMemory(this)\">remove…</button>" +
29
- "</div>" +
30
- "<div id='remove-out'></div>" +
31
- "<div class='body'>" + (d.confidential ? '<span class="withheld">' + esc(d.text) + "</span>" : esc(d.text)) + "</div>" +
32
- (d.journal
33
- ? "<p style='color:var(--purple);font-size:11px;line-height:1.7;margin:-4px 0 14px'>" +
34
- "This is a journal entry, not a memory. It is the account a memory was made from, it sits outside " +
35
- "every sleep phase, and the physics below is recorded but never acted on — nothing here decays.</p>"
36
- : "") +
37
- '<div class="kv">' +
38
- kv("kind", esc(d.kind)) +
39
- kv("band", esc(d.band) + " <span style='color:var(--faint)'>(recorded " + esc(d.recordedBand) + ")</span>") +
40
- kv("strength", n3(d.strength) + " <span style='color:var(--faint)'>· repetition " + n3(d.repetition) + "</span>") +
41
- kv("salience", n3(s.combined) + " <span style='color:var(--faint)'>relevance " + n2(s.relevance) +
42
- " · emotional " + n2(s.emotional) + " · predictive " + n2(s.predictive) +
43
- (s.novelty === null ? " · <span style='color:var(--amber)'>novelty blind (no schema context existed)</span>" : " · novelty " + n2(s.novelty)) +
44
- (s.claimed === null ? "" : " · claimed floor " + n2(s.claimed)) + "</span>") +
45
- kv("lived", "born day " + d.bornDay + " · used " + d.uses + "× over " + d.reinforcedDays +
46
- " separate days · last used day " + d.lastUsedDay) +
47
- kv("recorded", esc(d.learnedOn) + (d.happenedOn ? " · happened " + esc(d.happenedOn) : "") +
48
- "<span style='color:var(--faint)'> — the calendar day this entered the store; " +
49
- "on a migrated or seeded store, the day of the import</span>") +
50
- kv("standing", (d.consolidated ? "consolidated" : "not yet consolidated") + " · " +
51
- (d.promoted ? "promoted into identity" : "not promoted") + " · " +
52
- (d.protected ? "<span style='color:var(--amber)'>PROTECTED — no revision path reaches it</span>" : "revisable")) +
53
- kv("pressure", d.pressure === 0
54
- ? "<span style='color:var(--dim)'>(none yet) — nothing has argued with it</span>"
55
- : n3(d.pressure) + (d.bar === null ? "" : " against a bar of " + n3(d.bar))) +
56
- (d.archived ? kv("archived", "<span style='color:var(--amber)'>" + esc(d.archived) + "</span>") : "") +
57
- "</div>" +
58
- section("Wired together with", d.edges.map((e) =>
59
- "<div class='ref' onclick=\"openMemory('" + e.id + "')\"><span class='role'>" + n2(e.weight) + "</span>" +
60
- said(e.text, e.confidential) + "</div>").join(""),
61
- "(none yet) — it fires with nothing.") +
62
- section("What it points at, resolved just now", d.points.map((p) =>
63
- "<div class='ref' onclick=\"openMemory('" + p.id + "')\"><span class='role'>" + esc(p.role) + "</span>" +
64
- esc(p.text) + "</div>").join(""), "(none yet) — it points at nothing.") +
65
- section("Version history", d.versions.map((v) =>
66
- "<div class='ref'><span class='role'>v" + v.seq + " · " + esc(v.reason) + " · day " + v.day + "</span>" +
67
- esc(v.became) + "</div>").join(""), "(none yet) — it has never been revised.") +
68
- section("Looks ahead to", d.prospective.map((p) =>
69
- "<div class='ref'><span class='role'>" + esc(p.date) + " (" + esc(p.precision) + ")</span>" +
70
- esc(p.state) + ", fired " + p.fires + "×</div>").join(""), "(none yet) — it holds no intention.") +
71
- (d.removal.length === 0 ? "" : section("Removal record", d.removal.map((r) =>
72
- "<div class='ref'><span class='role'>" + esc(r.stage) + "</span>by " + esc(r.actor) +
73
- " — " + esc(r.reason || "no reason recorded") + "</div>").join(""), ""))
74
- );
261
+ "</div></div><div id='remove-out'></div>";
75
262
  }
76
263
 
77
264
  /** The id, on demand — it is how the owner addresses this memory anywhere else
@@ -22,3 +22,70 @@
22
22
  #modal .ref{font-size:11px;padding:6px 0;border-bottom:1px solid var(--border);cursor:pointer;line-height:1.55}
23
23
  #modal .ref:hover{color:var(--cyan)}
24
24
  #modal .ref .role{color:var(--dim);display:inline-block;min-width:118px}
25
+
26
+ /* ── the memory card (`memory-modal.js`; 2026-09-26, an experiment) ── */
27
+ #modal .mc-title{display:flex;align-items:flex-start;gap:8px;color:var(--ink);font-size:16px;line-height:1.4;margin-bottom:2px}
28
+ #modal .mc-title .kmark{padding-top:3px}
29
+ #modal .mc-title .kic{width:16px;height:16px}
30
+ .mc-kind{color:var(--faint);font-size:12px;margin:0 0 12px 24px;overflow-wrap:anywhere}
31
+ .mc-archived{color:var(--amber);font-size:13px;margin:-4px 0 12px;padding:7px 11px;border:1px solid rgba(255,215,64,.25);
32
+ border-radius:var(--radius);background:rgba(255,215,64,.04)}
33
+ .mc-arch .body,.mc-arch .mc-title span{color:var(--dim)}
34
+ .mc-arch .mc-curve,.mc-arch .mc-print,.mc-arch .mc-strip{opacity:.55}
35
+ .mc-note{color:var(--purple);font-size:12.5px;line-height:1.6;margin:-4px 0 14px}
36
+ .mc-part{margin:0 0 14px;min-width:0}
37
+ #modal .mc-part h4{margin:0 0 6px}
38
+ .mc-line{color:var(--ink);font-size:13px;line-height:1.55;margin:6px 0 0}
39
+ .mc-dim{color:var(--dim)}
40
+ .mc-curve{display:block;width:100%;height:120px;background:var(--deep);border:1px solid var(--border);border-radius:var(--radius)}
41
+ .mc-guide{stroke:rgba(255,183,77,.45);stroke-width:1;stroke-dasharray:2 3;vector-effect:non-scaling-stroke}
42
+ .mc-today{stroke:rgba(0,229,255,.25);stroke-width:1;vector-effect:non-scaling-stroke}
43
+ .mc-past{fill:none;stroke:var(--cyan);stroke-width:2;vector-effect:non-scaling-stroke}
44
+ .mc-ahead{fill:none;stroke:var(--cyan);stroke-width:1.5;stroke-dasharray:5 4;opacity:.7;vector-effect:non-scaling-stroke}
45
+ .mc-now{fill:var(--cyan)}
46
+ .mc-axis{display:flex;justify-content:space-between;gap:8px;color:var(--faint);font-size:11.5px;margin-top:3px}
47
+ .mc-print{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,8.5rem),1fr));gap:8px 14px}
48
+ .mc-pbar{display:flex;flex-direction:column;gap:4px;min-width:0;cursor:default}
49
+ .mc-plabel{color:var(--dim);font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
50
+ .mc-ptrack{display:block;height:6px;border-radius:3px;background:var(--deep);border:1px solid var(--border);overflow:hidden}
51
+ .mc-ptrack span{display:block;height:100%;background:var(--purple);border-radius:3px}
52
+ .mc-ptrack.blind{background:repeating-linear-gradient(135deg,var(--deep) 0 4px,rgba(138,149,163,.18) 4px 6px)}
53
+ .mc-strip{display:flex;gap:2px;align-items:center;flex-wrap:nowrap;overflow:hidden}
54
+ .mc-cell{flex:1 1 0;min-width:2px;max-width:18px;height:16px;border-radius:2px;background:var(--deep);border:1px solid var(--border);position:relative}
55
+ .mc-cell.used::after{content:"";position:absolute;left:50%;top:50%;width:min(8px,90%);aspect-ratio:1;
56
+ transform:translate(-50%,-50%);border-radius:50%;background:var(--cyan)}
57
+ .mc-cell.born{border-color:var(--purple)}
58
+ .mc-cell.today{border-color:var(--cyan)}
59
+ .mc-more{color:var(--faint);font-size:12px;padding-right:2px}
60
+ .mc-list{list-style:none;margin:0;padding:0}
61
+ .mc-list li{font-size:13px;line-height:1.55;color:var(--ink);padding:3px 0;display:flex;gap:8px;align-items:baseline}
62
+ .mc-list li>span:last-child{min-width:0;flex:1}
63
+ .mc-list li>.mbadge{flex:none}
64
+ .mc-list b{font-weight:600}
65
+ .mc-fdot{display:inline-block;width:9px;height:9px;border-radius:50%}
66
+ .mc-refs .ref{font-size:12.5px;display:flex;gap:10px;align-items:baseline}
67
+ #modal .mc-refs .ref .role{min-width:0;flex:none;font-size:11.5px}
68
+ .mc-wbar{display:inline-block;width:40px;height:4px;border-radius:2px;background:var(--deep);overflow:hidden;vertical-align:middle}
69
+ .mc-wbar span{display:block;height:100%;background:rgba(0,229,255,.6)}
70
+ .mc-versions{list-style:none;margin:0 0 0 5px;padding:0;border-left:1px solid var(--glow)}
71
+ .mc-v{position:relative;display:flex;gap:10px;padding:4px 0 6px 12px;font-size:12.5px}
72
+ .mc-v>div{min-width:0;flex:1}
73
+ .mc-vdot{position:absolute;left:-5px;top:9px;width:9px;height:9px;border-radius:50%;background:var(--card);border:2px solid var(--glow)}
74
+ .mc-v-now .mc-vdot{background:var(--cyan);border-color:var(--cyan)}
75
+ .mc-vrel{color:var(--ink)}
76
+ #modal .mc-v .ref{border-bottom:none;padding:2px 0 0}
77
+ .mc-chips{display:flex;flex-wrap:wrap;gap:6px;margin:4px 0 12px}
78
+ .mc-chip{font-size:12px;color:var(--dim);border:1px solid var(--border);border-radius:11px;padding:2px 9px;white-space:nowrap}
79
+ .mc-chip.model{color:var(--purple);border-color:rgba(179,136,255,.3);font-family:var(--mono);font-size:11.5px}
80
+ .mc-foot{display:flex;flex-wrap:wrap;gap:8px 16px;align-items:flex-start;justify-content:space-between;border-top:1px solid var(--border);padding-top:10px}
81
+ .mc-details{flex:1 1 16rem;min-width:0}
82
+ .mc-details summary{cursor:pointer;color:var(--dim);font-size:12.5px;min-height:24px}
83
+ #modal .mc-details .kv{margin:8px 0 0}
84
+ .mc-buttons{display:flex;gap:8px}
85
+ #modal .mc-buttons .copy{font-size:11px;padding:4px 10px}
86
+ @media(max-width:640px){
87
+ #modal .mc-details .kv{grid-template-columns:minmax(0,1fr)}
88
+ #modal .mc-details .kv .k{margin-top:6px}
89
+ .mc-kind{margin-left:0}
90
+ #modal .mc-buttons .copy,.mc-details summary{min-height:44px}
91
+ }
@@ -1,4 +1,4 @@
1
- /* The hover tooltip (the constellation uses it). `#tip` lives in the shell. */
1
+ /* The hover tooltip (the memories tab's "How it feels" uses it). `#tip` lives in the shell. */
2
2
  import { $ } from "./dom.js";
3
3
 
4
4
  export function showTip(x, y, html) {
@@ -9,5 +9,9 @@
9
9
  .ev.amber .t{color:var(--amber)}
10
10
  .ev.notable .t{color:#dfe6ee}
11
11
  .ev.calm .t{color:var(--dim)}
12
+ .ev .ev-i{display:inline-block;vertical-align:-2px;margin-right:7px;color:var(--cyan);opacity:.85}
13
+ .ev.calm .ev-i{color:var(--dim)}
14
+ .ev.amber .ev-i{color:var(--amber)}
15
+ .ev .ev-x{color:var(--faint);font-family:var(--mono);font-size:.95em;white-space:nowrap}
12
16
  .ev.flash{animation:evflash 1.8s ease-out}
13
17
  @keyframes evflash{0%{background:rgba(0,229,255,.14)}100%{background:transparent}}
@@ -1,39 +1,81 @@
1
1
  /* The activity feed: narrated durable-log rows, newest first. Any page may
2
2
  render one; a feed REGISTERED as live also receives the pulse's new rows
3
- (`shell/pulse.js`), prepended and flashed. */
3
+ (`shell/pulse.js`), prepended and flashed — only the rows its `accept` takes,
4
+ so the home feed stays memory events while the flow feed takes everything.
5
+
6
+ A row carries a small icon when it has one (`web/lanes.ts`), and "×N" when
7
+ it stands for N neighbours that read the same (the mechanism panel's Lately). */
4
8
  import { absenceLine } from "../absence.js";
5
9
  import { $, esc } from "../dom.js";
6
10
  import { openEvent } from "../event-modal.js";
7
11
 
12
+ /** Tiny line icons, 14px, drawn in the row's own colour. */
13
+ const PATHS = {
14
+ // a pen: something written down
15
+ remembered: '<path d="M3 13l1-3 7-7 2 2-7 7-3 1z"/>',
16
+ // an arrow up: held more firmly
17
+ stronger: '<path d="M8 13V3M4 7l4-4 4 4"/>',
18
+ // two arrows: an older reading replaced by a newer one
19
+ replaced: '<path d="M3 6h9l-2-2M13 10H4l2 2"/>',
20
+ // an arrow down: fading, let go
21
+ faded: '<path d="M8 3v10M4 9l4 4 4-4"/>',
22
+ // a page: a chapter
23
+ chapter: '<path d="M4 2h6l2 2v10H4zM6 7h4M6 10h4"/>',
24
+ // a moon: sleep
25
+ sleep: '<path d="M11 3a5 5 0 1 0 2 7 4 4 0 0 1-2-7z"/>',
26
+ // a clock: a reminder
27
+ reminder: '<circle cx="8" cy="8" r="5.5"/><path d="M8 5v3l2 1.5"/>',
28
+ // a note passed on: a handoff
29
+ handoff: '<path d="M2 8h9M8 5l3 3-3 3M13 3v10"/>',
30
+ };
31
+ const LABEL = {
32
+ remembered: "remembered", stronger: "stronger", replaced: "replaced", faded: "faded",
33
+ chapter: "chapter", sleep: "sleep", reminder: "reminder", handoff: "handoff",
34
+ };
35
+
36
+ function icon(name) {
37
+ const p = name && PATHS[name];
38
+ if (!p) return "";
39
+ return '<svg class="ev-i" viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5"' +
40
+ ' stroke-linecap="round" stroke-linejoin="round" role="img" aria-label="' + LABEL[name] + '">' + p + "</svg>";
41
+ }
42
+
43
+ function inner(e) {
44
+ const times = e.repeats > 1 ? '<span class="ev-x"> ×' + e.repeats + "</span>" : "";
45
+ return '<span class="d">day ' + e.day + "</span>" +
46
+ '<span class="t">' + icon(e.icon) + esc(e.text) + times + '<span class="k">' + esc(e.name) +
47
+ (e.node ? " · " + esc(e.node) : "") + "</span></span>";
48
+ }
49
+
8
50
  export function renderFeed(el, events, ctx) {
9
51
  if (!events || events.length === 0) {
10
52
  el.innerHTML = absenceLine(ctx && ctx.feedAbsent ? ctx.feedAbsent : "(never run)", "nothing has reached my durable log");
11
53
  return;
12
54
  }
13
55
  el.innerHTML = events.map((e) =>
14
- '<div class="ev ' + e.tone + '" data-seq="' + e.seq + '" onclick="openEvent(' + e.seq + ')">' +
15
- '<span class="d">day ' + e.day + "</span>" +
16
- '<span class="t">' + esc(e.text) + '<span class="k">' + esc(e.name) +
17
- (e.node ? " · " + esc(e.node) : "") + "</span></span></div>"
56
+ '<div class="ev ' + e.tone + (e.icon ? " has-i" : "") + '" data-seq="' + e.seq + '" onclick="openEvent(' + e.seq + ')">' +
57
+ inner(e) + "</div>"
18
58
  ).join("");
19
59
  }
20
60
 
21
- /** Element ids of the feeds the pulse writes into, in registration order. */
22
- const LIVE = [];
23
- export function registerLiveFeed(id) { if (!LIVE.includes(id)) LIVE.push(id); }
61
+ /** The feeds the pulse writes into, in registration order: element id → accept. */
62
+ const LIVE = new Map();
63
+ export function registerLiveFeed(id, accept) { if (!LIVE.has(id)) LIVE.set(id, accept || (() => true)); }
24
64
 
25
- /** New events arrive oldest-first; each is inserted at the top, flashed. A feed
26
- * still showing its absence line is left alone (its page repaints it). */
65
+ /** New events arrive oldest-first; each one a feed accepts is inserted at the
66
+ * top, flashed. A feed still showing its absence line is left alone (its page
67
+ * repaints it). */
27
68
  export function prependToLiveFeeds(fresh) {
28
- for (const el of LIVE.map((id) => $(id))) {
69
+ for (const [id, accept] of LIVE) {
70
+ const el = $(id);
29
71
  if (!el || el.querySelector(".empty")) continue;
30
72
  for (const e of fresh) {
73
+ if (!accept(e)) continue;
31
74
  const row = document.createElement("div");
32
- row.className = "ev " + e.tone + " flash";
75
+ row.className = "ev " + e.tone + (e.icon ? " has-i" : "") + " flash";
33
76
  row.dataset.seq = e.seq;
34
77
  row.onclick = () => openEvent(e.seq);
35
- row.innerHTML = '<span class="d">day ' + e.day + '</span><span class="t">' + esc(e.text) +
36
- '<span class="k">' + esc(e.name) + (e.node ? " · " + esc(e.node) : "") + "</span></span>";
78
+ row.innerHTML = inner(e);
37
79
  el.insertBefore(row, el.firstChild);
38
80
  }
39
81
  while (el.children.length > 60) el.removeChild(el.lastChild);
@@ -2,3 +2,4 @@
2
2
  .light{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none;background:var(--faint);opacity:.55}
3
3
  .light-green{background:var(--teal);opacity:1;box-shadow:0 0 8px rgba(0,191,165,.7)}
4
4
  .light-amber{background:var(--amber);opacity:1;box-shadow:0 0 8px rgba(255,215,64,.45)}
5
+ .light-waiting{background:transparent;opacity:1;box-shadow:inset 0 0 0 1.5px var(--teal)}
@@ -1,15 +1,17 @@
1
1
  /* The status light: one small dot that says whether a mechanism is working.
2
- green — built, and it fired in the window
3
- amber — built, and it has not fired in the window
4
- grey — not built yet; it never claims activity
2
+ green — built, and it fired in the window
3
+ waiting — built, and simply not due: its scheduled run is ahead, or it
4
+ holds nothing to act on yet (a ring, not a dot)
5
+ amber — built, and quiet when it should not be
6
+ grey — not built yet; it never claims activity
5
7
  The word travels with the dot (as its accessible name), so the colour is
6
8
  never the only carrier of the meaning. */
7
9
  import { esc } from "../dom.js";
8
10
 
9
- export const LIGHT_WORD = { green: "firing", amber: "quiet", grey: "not built yet" };
11
+ export const LIGHT_WORD = { green: "firing", waiting: "waiting", amber: "quiet", grey: "not built yet" };
10
12
 
11
13
  /** A light's markup. Unknown statuses draw grey rather than guess. */
12
14
  export function light(status) {
13
- const s = status === "green" || status === "amber" ? status : "grey";
15
+ const s = status === "green" || status === "amber" || status === "waiting" ? status : "grey";
14
16
  return '<span class="light light-' + s + '" role="img" aria-label="' + esc(LIGHT_WORD[s]) + '"></span>';
15
17
  }
@@ -0,0 +1,19 @@
1
+ /* ── the `?`: the explaining words, out of the reading path (`tips.js`) ── */
2
+ .q-wrap{position:relative;display:inline-block;vertical-align:middle;line-height:1}
3
+ .q{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;margin:0 0 0 2px;
4
+ border:1px solid var(--glow);border-radius:50%;background:none;color:var(--dim);font-family:var(--sans);
5
+ font-size:12px;font-weight:600;line-height:1;cursor:pointer;position:relative}
6
+ /* A small glyph with a thumb-sized hit area around it. */
7
+ .q::after{content:"";position:absolute;inset:-12px}
8
+ .q:hover,.q:focus-visible,.q-wrap.open .q{color:var(--cyan);border-color:var(--cyan)}
9
+ .q-pop{display:none;position:absolute;left:0;top:calc(100% + 8px);z-index:30;width:max-content;
10
+ max-width:min(22rem,calc(100vw - 32px));background:var(--deep);border:1px solid var(--glow);border-radius:6px;
11
+ padding:9px 12px;font-family:var(--sans);font-size:13px;font-weight:400;line-height:1.55;color:var(--ink);
12
+ text-transform:none;letter-spacing:0;text-align:left;white-space:normal;box-shadow:0 6px 26px rgba(0,0,0,.6)}
13
+ /* Hovered: a floating note that never takes the pointer, so it can't sit in
14
+ the way of what is under it. Pinned (tap / click / Enter): the words drop
15
+ into the flow under the line they explain and cover nothing. */
16
+ @media(hover:hover){.q-wrap:not(.open):hover .q-pop,.q-wrap:not(.open) .q:focus-visible+.q-pop{display:block;pointer-events:none}}
17
+ .q-wrap.open{display:inline}
18
+ .q-wrap.open .q-pop{display:block;position:static;width:auto;max-width:none;margin:8px 0 2px;box-shadow:none;
19
+ background:rgba(0,229,255,.05);border-color:var(--border)}
@@ -0,0 +1,56 @@
1
+ /* The small `?` that holds the explaining words, out of the reading path:
2
+ hover floats them on a pointer that can hover; a tap (or a click, or Enter)
3
+ pins them open in the flow under their line, and a second one closes them.
4
+ What is pinned is kept here, by name, so a live refresh draws it open again.
5
+ One copy for every page (the self tab's, from #245); a tip's name is unique
6
+ across the dashboard. */
7
+ import { esc } from "../dom.js";
8
+
9
+ /** Pinned tips, by name. */
10
+ export const openTips = new Set();
11
+
12
+ /** The markup for one tip: a `?` button and its words beside it. */
13
+ export function q(key, text) {
14
+ const open = openTips.has(key);
15
+ return '<span class="q-wrap' + (open ? " open" : "") + '" data-tip="' + esc(key) + '">' +
16
+ '<button type="button" class="q" aria-expanded="' + open + '" aria-label="What this means">?</button>' +
17
+ '<span class="q-pop" role="note">' + esc(text) + "</span></span>";
18
+ }
19
+
20
+ /** Keep an open tip inside the window: shift it left when it would run past
21
+ * the right edge (a phone is where that happens). */
22
+ function clamp(wrap) {
23
+ const pop = wrap.querySelector(".q-pop");
24
+ if (!pop) return;
25
+ pop.style.left = "";
26
+ // A pinned tip sits in the flow and needs no help; only the floating one can
27
+ // run past the edge.
28
+ if (getComputedStyle(pop).position !== "absolute") return;
29
+ const r = pop.getBoundingClientRect();
30
+ if (r.width === 0) return;
31
+ const room = document.documentElement.clientWidth - 12;
32
+ if (r.right > room) pop.style.left = Math.round(-(r.right - room)) + "px";
33
+ const r2 = pop.getBoundingClientRect();
34
+ if (r2.left < 12) pop.style.left = Math.round(parseFloat(pop.style.left || "0") + (12 - r2.left)) + "px";
35
+ }
36
+
37
+ /** Wire every tip under `root` that is not wired yet. Safe to call after each
38
+ * repaint, and on a root whose tips were not all redrawn. */
39
+ export function wireTips(root) {
40
+ root.querySelectorAll(".q-wrap:not([data-wired])").forEach((wrap) => {
41
+ wrap.dataset.wired = "1";
42
+ const key = wrap.dataset.tip;
43
+ const btn = wrap.querySelector(".q");
44
+ btn.addEventListener("click", (e) => {
45
+ e.stopPropagation();
46
+ e.preventDefault();
47
+ const open = !openTips.has(key);
48
+ if (open) openTips.add(key); else openTips.delete(key);
49
+ wrap.classList.toggle("open", open);
50
+ btn.setAttribute("aria-expanded", String(open));
51
+ if (open) clamp(wrap);
52
+ });
53
+ wrap.addEventListener("mouseenter", () => clamp(wrap));
54
+ if (openTips.has(key)) clamp(wrap);
55
+ });
56
+ }