@jossuealcala/madre 1.0.4 → 1.1.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.
Files changed (273) hide show
  1. package/ADDITIONAL-TERMS.md +7 -2
  2. package/CHANGELOG.en.md +152 -1
  3. package/CHANGELOG.md +152 -1
  4. package/CONTRIBUTING.md +2 -2
  5. package/LICENSE +111 -661
  6. package/NOTICE +59 -24
  7. package/README.en.md +36 -204
  8. package/README.md +36 -210
  9. package/SECURITY.md +1 -0
  10. package/TRADEMARKS.en.md +13 -14
  11. package/TRADEMARKS.md +42 -26
  12. package/bin/madre.cjs +2 -2
  13. package/bin/madre.mjs +114 -42
  14. package/docs/REFERENCE.md +53 -6
  15. package/docs/SDK.md +44 -5
  16. package/docs/en/REFERENCE.md +53 -6
  17. package/docs/en/SDK.md +43 -4
  18. package/docs/madre-banner.png +0 -0
  19. package/docs/sdk/hello-module.mjs +3 -0
  20. package/package.json +3 -2
  21. package/public/abduction.js +6 -6
  22. package/public/activity.js +425 -0
  23. package/public/app.js +3519 -647
  24. package/public/assets/abduction-cat-blink.webp +0 -0
  25. package/public/assets/abduction-cat-control-left.webp +0 -0
  26. package/public/assets/abduction-cat-control-right.webp +0 -0
  27. package/public/assets/abduction-cat.webp +0 -0
  28. package/public/assets/manual/shots/en-agents.webp +0 -0
  29. package/public/assets/manual/shots/en-chats.webp +0 -0
  30. package/public/assets/manual/shots/en-code.webp +0 -0
  31. package/public/assets/manual/shots/en-composer.webp +0 -0
  32. package/public/assets/manual/shots/en-connectors.webp +0 -0
  33. package/public/assets/manual/shots/en-continuity.webp +0 -0
  34. package/public/assets/manual/shots/en-coordinator.webp +0 -0
  35. package/public/assets/manual/shots/en-copilot.webp +0 -0
  36. package/public/assets/manual/shots/en-diagnostics.webp +0 -0
  37. package/public/assets/manual/shots/en-home.webp +0 -0
  38. package/public/assets/manual/shots/en-local.webp +0 -0
  39. package/public/assets/manual/shots/en-market.webp +0 -0
  40. package/public/assets/manual/shots/en-memory.webp +0 -0
  41. package/public/assets/manual/shots/en-modes.webp +0 -0
  42. package/public/assets/manual/shots/en-notes.webp +0 -0
  43. package/public/assets/manual/shots/en-settings.webp +0 -0
  44. package/public/assets/manual/shots/en-welcome.webp +0 -0
  45. package/public/assets/manual/shots/en-windows.webp +0 -0
  46. package/public/assets/manual/shots/es-agents.webp +0 -0
  47. package/public/assets/manual/shots/es-chats.webp +0 -0
  48. package/public/assets/manual/shots/es-code.webp +0 -0
  49. package/public/assets/manual/shots/es-composer.webp +0 -0
  50. package/public/assets/manual/shots/es-connectors.webp +0 -0
  51. package/public/assets/manual/shots/es-continuity.webp +0 -0
  52. package/public/assets/manual/shots/es-coordinator.webp +0 -0
  53. package/public/assets/manual/shots/es-copilot.webp +0 -0
  54. package/public/assets/manual/shots/es-diagnostics.webp +0 -0
  55. package/public/assets/manual/shots/es-home.webp +0 -0
  56. package/public/assets/manual/shots/es-local.webp +0 -0
  57. package/public/assets/manual/shots/es-market.webp +0 -0
  58. package/public/assets/manual/shots/es-memory.webp +0 -0
  59. package/public/assets/manual/shots/es-modes.webp +0 -0
  60. package/public/assets/manual/shots/es-notes.webp +0 -0
  61. package/public/assets/manual/shots/es-settings.webp +0 -0
  62. package/public/assets/manual/shots/es-welcome.webp +0 -0
  63. package/public/assets/manual/shots/es-windows.webp +0 -0
  64. package/public/assets/news/1.1/en/chats.webp +0 -0
  65. package/public/assets/news/1.1/en/home.webp +0 -0
  66. package/public/assets/news/1.1/en/maps.webp +0 -0
  67. package/public/assets/news/1.1/en/market.webp +0 -0
  68. package/public/assets/news/1.1/en/permissions.webp +0 -0
  69. package/public/assets/news/1.1/en/privacy.webp +0 -0
  70. package/public/assets/news/1.1/en/welcome.webp +0 -0
  71. package/public/assets/news/1.1/es/chats.webp +0 -0
  72. package/public/assets/news/1.1/es/home.webp +0 -0
  73. package/public/assets/news/1.1/es/maps.webp +0 -0
  74. package/public/assets/news/1.1/es/market.webp +0 -0
  75. package/public/assets/news/1.1/es/permissions.webp +0 -0
  76. package/public/assets/news/1.1/es/privacy.webp +0 -0
  77. package/public/assets/news/1.1/es/welcome.webp +0 -0
  78. package/public/attribution.js +15 -16
  79. package/public/brands.js +2 -2
  80. package/public/code-tools.js +2 -2
  81. package/public/editor.js +13 -13
  82. package/public/en.js +483 -0
  83. package/public/es.js +1817 -598
  84. package/public/hardware.js +2 -2
  85. package/public/i18n.js +47 -9
  86. package/public/icons.js +158 -0
  87. package/public/index.html +68 -51
  88. package/public/inquiry.js +2 -2
  89. package/public/loader.js +271 -2
  90. package/public/macroverso.js +60 -21
  91. package/public/manual-content.js +900 -0
  92. package/public/manual-shots.js +47 -0
  93. package/public/manual.css +246 -0
  94. package/public/manual.html +15 -0
  95. package/public/manual.js +427 -0
  96. package/public/market-art.js +99 -41
  97. package/public/market-view.js +243 -47
  98. package/public/market.js +139 -26
  99. package/public/mcp-catalog.js +62 -0
  100. package/public/neural.js +64 -8
  101. package/public/nostromo-engine.js +709 -40
  102. package/public/page-errors.js +29 -0
  103. package/public/power.js +350 -11
  104. package/public/remedy.js +89 -0
  105. package/public/resay.js +4 -2
  106. package/public/review-ask.js +12 -7
  107. package/public/routing.js +3 -3
  108. package/public/salas-mac.css +875 -48
  109. package/public/salas-mac.html +27 -15
  110. package/public/salas-mac.js +1668 -338
  111. package/public/salas.css +2 -2
  112. package/public/salas.html +3 -3
  113. package/public/salas.js +3 -3
  114. package/public/styles.css +2694 -323
  115. package/public/syntax.js +2 -2
  116. package/public/terms.js +152 -0
  117. package/public/touch.js +2 -2
  118. package/public/tour-chapters.js +100 -92
  119. package/public/tour.js +118 -28
  120. package/public/troubleshooting.js +327 -21
  121. package/public/wallpaper.js +4 -3
  122. package/public/welcome.js +923 -0
  123. package/src/activity.mjs +85 -0
  124. package/src/adapters/claude.mjs +61 -35
  125. package/src/adapters/codex.mjs +18 -5
  126. package/src/adapters/cursor.mjs +60 -9
  127. package/src/adapters/gemini.mjs +17 -4
  128. package/src/adapters/madre.mjs +30 -9
  129. package/src/adapters/opencode.mjs +73 -10
  130. package/src/adapters/process.mjs +19 -15
  131. package/src/adapters/subagents.mjs +159 -0
  132. package/src/asking.mjs +8 -2
  133. package/src/auth-probe.mjs +47 -11
  134. package/src/bridge/devices.mjs +2 -2
  135. package/src/bridge/handoff.mjs +2 -2
  136. package/src/bridge/host.mjs +2 -2
  137. package/src/bridge/network.mjs +2 -2
  138. package/src/bridge/policy.mjs +3 -3
  139. package/src/bridge/qr.mjs +2 -2
  140. package/src/bridge/server.mjs +3 -3
  141. package/src/builtin-updates.mjs +87 -0
  142. package/src/capabilities.mjs +5 -5
  143. package/src/chats.mjs +51 -2
  144. package/src/checkpoint.mjs +67 -9
  145. package/src/choices.mjs +2 -2
  146. package/src/cli-args.mjs +2 -2
  147. package/src/cold.mjs +2 -2
  148. package/src/commands.mjs +2 -2
  149. package/src/config.mjs +2 -2
  150. package/src/conversation-context.mjs +2 -2
  151. package/src/credentials.mjs +80 -18
  152. package/src/dataset.mjs +2 -2
  153. package/src/directives.mjs +2 -2
  154. package/src/distiller.mjs +2 -2
  155. package/src/embeddings.mjs +2 -2
  156. package/src/enlaces.mjs +2 -2
  157. package/src/environment.mjs +147 -0
  158. package/src/event-store.mjs +2 -2
  159. package/src/exam.mjs +2 -2
  160. package/src/extensions.mjs +2 -2
  161. package/src/eyecat-watch.mjs +2 -2
  162. package/src/eyecat.mjs +2 -2
  163. package/src/file-ops.mjs +2 -2
  164. package/src/files.mjs +2 -2
  165. package/src/github.mjs +2 -2
  166. package/src/heartbeat.mjs +2 -2
  167. package/src/history.mjs +76 -0
  168. package/src/i18n.mjs +32 -3
  169. package/src/image-studio.mjs +2 -2
  170. package/src/install-metrics.mjs +109 -0
  171. package/src/json-file.mjs +2 -2
  172. package/src/launch.mjs +2 -2
  173. package/src/lease.mjs +15 -4
  174. package/src/lobby-work.mjs +11 -4
  175. package/src/local-ai.mjs +12 -4
  176. package/src/looks.mjs +19 -7
  177. package/src/market-check.mjs +165 -0
  178. package/src/market-key.mjs +10 -2
  179. package/src/market-license.mjs +104 -0
  180. package/src/market-remote.mjs +71 -13
  181. package/src/maturity.mjs +2 -2
  182. package/src/mcp/connect.mjs +2 -2
  183. package/src/mcp/github-server.mjs +2 -2
  184. package/src/mcp/image-server.mjs +2 -2
  185. package/src/mcp/memory-server.mjs +2 -2
  186. package/src/mcp/proxy.mjs +16 -5
  187. package/src/mcp/smtp-server.mjs +2 -2
  188. package/src/memory-dashboard.mjs +2 -2
  189. package/src/memory-tools.mjs +2 -2
  190. package/src/memory.mjs +2 -2
  191. package/src/models.mjs +115 -12
  192. package/src/module-scope.mjs +2 -2
  193. package/src/modules/ahp.mjs +2 -2
  194. package/src/modules/ash-policy.mjs +2 -2
  195. package/src/modules/ash.mjs +2 -2
  196. package/src/modules/bishop-exam.mjs +2 -2
  197. package/src/modules/bishop-plan.mjs +2 -2
  198. package/src/modules/bishop.mjs +9 -3
  199. package/src/modules/choices.mjs +2 -2
  200. package/src/modules/correo.mjs +2 -2
  201. package/src/modules/enlaces.mjs +2 -2
  202. package/src/modules/git-pulse.mjs +2 -2
  203. package/src/modules/github.mjs +2 -2
  204. package/src/modules/helpers.mjs +2 -2
  205. package/src/modules/image-studio.mjs +2 -2
  206. package/src/modules/index.mjs +92 -5
  207. package/src/modules/intents-calibration.mjs +2 -2
  208. package/src/modules/intents-desk.mjs +4 -3
  209. package/src/modules/intents-observe.mjs +2 -2
  210. package/src/modules/intents-policy.mjs +2 -2
  211. package/src/modules/intents-try.mjs +2 -2
  212. package/src/modules/intents.mjs +2 -2
  213. package/src/modules/local-models.mjs +41 -10
  214. package/src/modules/mcp-connect.mjs +2 -2
  215. package/src/modules/notes.mjs +281 -0
  216. package/src/modules/ollama.mjs +48 -13
  217. package/src/modules/playwright.mjs +16 -5
  218. package/src/modules/reminders.mjs +664 -0
  219. package/src/modules/ripley.mjs +3 -3
  220. package/src/modules/runs.mjs +2 -2
  221. package/src/modules/sdk.mjs +57 -9
  222. package/src/modules/updates.mjs +2 -2
  223. package/src/mother.mjs +13 -3
  224. package/src/npm-launch.mjs +2 -2
  225. package/src/ollama.mjs +8 -6
  226. package/src/opencode-health.mjs +83 -0
  227. package/src/outbound.mjs +35 -3
  228. package/src/override.mjs +27 -22
  229. package/src/ports.mjs +2 -2
  230. package/src/prices.mjs +2 -2
  231. package/src/privacy.mjs +2 -2
  232. package/src/quota-monitor.mjs +2 -2
  233. package/src/quota-sources.mjs +2 -2
  234. package/src/request-guard.mjs +2 -2
  235. package/src/review-ask.mjs +4 -3
  236. package/src/room/archivist.mjs +2 -2
  237. package/src/room/attachments.mjs +2 -2
  238. package/src/room/budget.mjs +2 -2
  239. package/src/room/context.mjs +2 -2
  240. package/src/room/control.mjs +2 -2
  241. package/src/room/copilot.mjs +2 -2
  242. package/src/room/economy.mjs +2 -2
  243. package/src/room/escalation.mjs +2 -2
  244. package/src/room/ghost.mjs +2 -2
  245. package/src/room/guard.mjs +6 -4
  246. package/src/room/prompt.mjs +3 -3
  247. package/src/room/returns.mjs +2 -2
  248. package/src/room/runs.mjs +6 -4
  249. package/src/room/vectors.mjs +2 -2
  250. package/src/room.mjs +144 -36
  251. package/src/router.mjs +2 -2
  252. package/src/runs.mjs +2 -2
  253. package/src/runtime-detection.mjs +36 -6
  254. package/src/salas.mjs +31 -6
  255. package/src/sentinel-errors.mjs +17 -7
  256. package/src/server-sentinel.mjs +2 -2
  257. package/src/server.mjs +980 -139
  258. package/src/setup-trouble.mjs +33 -0
  259. package/src/setup.mjs +4 -4
  260. package/src/smtp.mjs +2 -2
  261. package/src/telemetry.mjs +266 -0
  262. package/src/terms.mjs +43 -0
  263. package/src/tour.mjs +60 -7
  264. package/src/uninstall.mjs +225 -0
  265. package/src/updates.mjs +2 -2
  266. package/src/usage-sentinel.mjs +2 -2
  267. package/src/vault.mjs +2 -2
  268. package/src/verdict.mjs +13 -10
  269. package/src/whats-new.mjs +97 -3
  270. package/public/assets/abduction-cat-blink.png +0 -0
  271. package/public/assets/abduction-cat-control-left.png +0 -0
  272. package/public/assets/abduction-cat-control-right.png +0 -0
  273. package/public/assets/abduction-cat.png +0 -0
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: AGPL-3.0-only
2
- // MADRE · © 2026 Jossue Alcalá · GNU AGPL v3 with additional terms (Section 7): ADDITIONAL-TERMS.md
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // MADRE · © 2026 Jossue Alcalá · Business Source License 1.1: LICENSE
3
3
  // SALAS on the Mac: every room this Mac knows, open or asleep, in one place (docs/MACROVERSO.md,
4
4
  // phase 1). The room that serves this page answers for all of them (src/salas.mjs): it lists
5
5
  // them, opens one that is asleep, asks one to close, and stops every agent in every room. A room
@@ -7,22 +7,34 @@
7
7
  //
8
8
  // The phone has its own SALAS (salas.js), served by the bridge; the two read the same rooms.
9
9
 
10
- import { browserLanguage, setLanguage, t } from './i18n.js';
10
+ import { browserLanguage, sessionDetail, setLanguage, t } from './i18n.js';
11
11
  import { brandOf, monogram } from './brands.js';
12
- import { startReviewAsk } from './review-ask.js';
12
+ import { SPONSORS_URL, startReviewAsk } from './review-ask.js';
13
13
  import { startTour } from './tour.js';
14
14
  import { dropStickyHover } from './touch.js';
15
- import { drawAttribution, drawColophonKeys, drawLegal } from './attribution.js';
15
+ import { AUTHOR, AUTHOR_URL, YEAR, drawAttribution, drawColophonKeys, drawLegal } from './attribution.js';
16
16
 
17
17
  // Where nothing can hover (a tablet), a tapped key does not stay lit (public/touch.js).
18
18
  dropStickyHover();
19
- import { creep, finishLoader, makeLoader, setLoader, showCurtain } from './loader.js';
20
- import { labelPowerKey, powerKey } from './power.js';
19
+ import { bootDone, creep, finishLoader, makeLoader, openingPlayed, playOpening, setLoader, showCurtain } from './loader.js';
20
+ import { POWER_ICON, askUninstall, labelPowerKey, openPowerMenu, powerKey } from './power.js';
21
21
  import { drawHardware } from './hardware.js';
22
22
  import { CUSTOM_WALL, addPicture, customTile, customTools, customWall, paintCustomWall, rememberedWall } from './wallpaper.js';
23
- import { neuralChosen, rememberNeural } from './neural.js';
23
+ import { mapKeys, neuralChosen, rememberNeural } from './neural.js';
24
24
  import { openMarket } from './market-view.js';
25
+ import { openWelcome, welcomeOpen, WELCOME_STEPS } from './welcome.js';
26
+ import { remedyKey } from './remedy.js';
25
27
  import { loadMarket } from './market.js';
28
+ import { trazo, trazoDrawing } from './icons.js';
29
+ import { tellFailures } from './page-errors.js';
30
+ import { mountActivity } from './activity.js';
31
+ import { ensureTerms } from './terms.js';
32
+
33
+ // Nothing of MADRE starts before its license and privacy notice are accepted on this computer
34
+ // (public/terms.js, src/terms.mjs): the page waits here.
35
+ await ensureTerms();
36
+ // A failure of Home's page is told to MADRE's anonymous diagnostics (src/telemetry.mjs).
37
+ tellFailures('home');
26
38
 
27
39
  const $ = (id) => document.getElementById(id);
28
40
  const root = document.documentElement;
@@ -48,7 +60,8 @@ let timer = 0;
48
60
  let arming = 0;
49
61
  let data = null;
50
62
  let macro = null; // the macroverse, while it is open
51
- let welcomed = false; // the first-run wizard was offered this visit
63
+ let welcomed = false; // the welcome was offered this visit (public/welcome.js)
64
+ let welcomeSeen = null; // where the welcome is (src/tour.mjs, `welcome`), as last saved
52
65
  let agentsSeen = null; // what /api/settings said of the agents, last time it was asked
53
66
  let localSeen = null; // what /api/salas/local-ai said: the mode and which projects use the local AI
54
67
  let versionSeen = null; // what /api/version said of MADRE, last time it was asked
@@ -68,8 +81,8 @@ const revoking = new Set(); // link ids whose row asks before revoking
68
81
 
69
82
  // The room's looks, from this browser: the same keys the room's own page keeps (app.js, LOOKS),
70
83
  // so a choice made here is the room's too when the room is served at this address.
71
- const ACCENTS = ['madre', 'mountain', 'caribbean', 'phantom', 'malbec', 'dijon', 'pacific', 'love', 'sierra', 'pitahaya', 'papaya', 'agave', 'dinamo', 'marina', 'pulso', 'leal', 'dulce'];
72
- const ACCENT_WORDS = { madre: () => t('Madre green'), mountain: () => t('Mountain green'), caribbean: () => t('Caribbean blue'), phantom: () => t('Phantom purple'), malbec: () => t('Malbec red'), dijon: () => t('Dijon yellow'), pacific: () => t('Pacific blue'), love: () => t('Love pink'), sierra: () => t('Sierra blue'), pitahaya: () => 'Pitahaya', papaya: () => 'Papaya', agave: () => 'Agave', dinamo: () => t('Dynamo black'), marina: () => t('Marina blue'), pulso: () => t('Pulse green'), leal: () => t('Loyal orange'), dulce: () => t('Sweet yellow') };
84
+ const ACCENTS = ['madre', 'mountain', 'caribbean', 'phantom', 'malbec', 'dijon', 'pacific', 'love', 'sierra', 'pitahaya', 'papaya', 'agave', 'dinamo', 'marina', 'pulso', 'leal', 'dulce', 'marmol', 'durazno', 'pistache', 'petalo', 'negro', 'fortaleza'];
85
+ const ACCENT_WORDS = { madre: () => t('Madre green'), mountain: () => t('Mountain green'), caribbean: () => t('Caribbean blue'), phantom: () => t('Phantom purple'), malbec: () => t('Malbec red'), dijon: () => t('Dijon yellow'), pacific: () => t('Pacific blue'), love: () => t('Love pink'), sierra: () => t('Sierra blue'), pitahaya: () => 'Pitahaya', papaya: () => 'Papaya', agave: () => 'Agave', dinamo: () => t('Dynamo black'), marina: () => t('Marina blue'), pulso: () => t('Pulse green'), leal: () => t('Loyal orange'), dulce: () => t('Sweet yellow'), marmol: () => t('Marble gray'), durazno: () => t('Peach orange'), pistache: () => t('Pistachio green'), petalo: () => t('Petal pink'), negro: () => t('Black'), fortaleza: () => t('Fortress blue') };
73
86
  // The wallpapers are the room's (app.js, LOOKS.wallpaper; styles.css, --wp-*): the same images, the
74
87
  // same veil, the same «mesh» and blur the room's PERSONALIZE sets, read from the same keys.
75
88
  const WALLPAPERS = ['default', 'jarrito', 'canela', 'paradise', 'ventura', 'magna', 'biznaga', 'oceano', 'quila', 'xico', 'tropical', 'tradicion', 'urbania', CUSTOM_WALL];
@@ -291,7 +304,9 @@ const addressOf = (room) => (room.here ? '/' : `http://127.0.0.1:${room.open.por
291
304
  const KINDS = ['decision', 'fact', 'preference', 'question', 'aberration'];
292
305
  const KIND_WORDS = { decision: t('DECISION'), fact: t('FACT'), preference: t('PREFERENCE'), question: t('QUESTION'), aberration: t('DOUBTFUL MEMORY') };
293
306
  // A kind as a sentence says it: «Decisión», not «DECISIÓN».
294
- const kindWord = (kind) => { const word = String(KIND_WORDS[kind] ?? kind).toLowerCase(); return word.charAt(0).toUpperCase() + word.slice(1); };
307
+ // A word the catalogue keeps in capitals, said in sentence case: «Decisión», «Centrar».
308
+ const asLabel = (text) => { const word = String(text).toLowerCase(); return word.charAt(0).toUpperCase() + word.slice(1); };
309
+ const kindWord = (kind) => asLabel(KIND_WORDS[kind] ?? kind);
295
310
 
296
311
  function memoryStrip(census) {
297
312
  const strip = el('div', 'sm-strip');
@@ -316,11 +331,14 @@ function stateOf(room) {
316
331
  const glance = room.glance ?? {};
317
332
  if (!room.open) return { key: 'asleep', words: room.lastOpened ? t('Asleep · last open {when}', { when: ago(room.lastOpened) }) : t('Asleep') };
318
333
  if (glance.outdated) return { key: 'outdated', words: t('Update MADRE in this project to see it here.') };
334
+ // Still on the MADRE it was opened with, after Home updated (QA 1.1.0, ACT-05): its card said
335
+ // «Active» and a press took the person into the old version without a word.
336
+ if (room.open?.version && data?.version && !room.here && olderVersion(room.open.version, data.version)) return { key: 'outdated', words: t('On MADRE {version} · restart it to bring it to {latest}', { version: room.open.version, latest: data.version }) };
319
337
  if (glance.unreachable) return { key: 'quiet', words: t('Not answering right now') };
320
338
  if (glance.delayed) return { key: 'quiet', words: t('Responding slowly · last known state') };
321
339
  if (glance.waitingCount) return { key: 'waiting', words: t('Waiting for you · {n}', { n: glance.waitingCount }) };
322
340
  if (glance.working?.length) return { key: 'working', words: glance.working.length === 1 ? t('@{agent} is working', { agent: glance.working[0] }) : t('{n} agents working', { n: glance.working.length }) };
323
- return { key: 'calm', words: t('Calm') };
341
+ return { key: 'calm', words: t('Active') };
324
342
  }
325
343
 
326
344
  function button(className, words, onClick) {
@@ -479,14 +497,27 @@ function projectsInOrder() {
479
497
  : [...open, ...asleep];
480
498
  return { all, open, asleep };
481
499
  }
500
+ let homeBootAsked = false;
482
501
  function draw() {
483
502
  if (!data) return;
484
503
  const { all, open } = projectsInOrder();
485
504
  drawBishop(data.rooms.find((room) => room.id === data.salas) ?? null);
486
505
  drawWaiting();
487
506
  drawProjects(all);
488
- if (!all.length && !welcomed) { welcomed = true; void homeTour.loaded.then((answer) => { if (!answer?.owed) openWizard(); }); }
507
+ // An empty Home opens the welcome where it was left, or at the project when it was finished
508
+ // without one; someone new meets it in place of the bonjour (public/tour.js).
509
+ // Not for whoever updated from before 1.1.0: they meet the news, and «Add project» is on Home (2026-10-30).
510
+ if (!all.length && !welcomed) { welcomed = true; void homeTour.loaded.then((answer) => { if (!answer?.owed && !answer?.upgraded) openHomeWelcome({ at: answer?.state?.welcome?.finished ? 'project' : null }); }); }
489
511
  welcomeHome();
512
+ // Home is drawn: the ground over its first frame goes (loader.js, bootDone) — unless the welcome is
513
+ // about to open, whose opening comes first; then it goes as the welcome opens (openHomeWelcome).
514
+ if (!homeBootAsked) {
515
+ homeBootAsked = true;
516
+ void homeTour.loaded.then((answer) => {
517
+ const welcomeComing = !answer?.upgraded && (answer?.owed ? homeTour.path() === 'new' : !all.length);
518
+ if (!welcomeComing) bootDone();
519
+ }, () => bootDone());
520
+ }
490
521
  const working = open.some((room) => room.glance?.working?.length);
491
522
  ui.stop.hidden = !working;
492
523
  drawLinks(all);
@@ -570,7 +601,7 @@ for (const choice of ui.filter.querySelectorAll('[data-filter]')) {
570
601
  // ORDER, where the projects are (2026-10-13): the same four orders as Home's Appearance, one press
571
602
  // away from the list they arrange. «Yours» is the order made by dragging a card or by its
572
603
  // right-click › Move; the menu says so, so the way to make it is never a secret.
573
- const SORT_ICON = '<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M6 4.5v11M3.5 13 6 15.5 8.5 13"/><path d="M11 6h5.5M11 10h4M11 14h2.5"/></svg>';
604
+ const SORT_ICON = trazo('sort');
574
605
  const orderKey = button('sm-btn sm-order', null, () => {
575
606
  const box = orderKey.getBoundingClientRect();
576
607
  const now = readLooks().home.order;
@@ -600,7 +631,7 @@ function drawWaiting() {
600
631
  ui.waiting.count.textContent = String(total);
601
632
  ui.waiting.box.classList.toggle('has', Boolean(total));
602
633
  ui.waiting.body.replaceChildren();
603
- if (!total) { ui.waiting.body.append(el('p', 'sm-hint', t('Nobody needs you. When an agent asks for you, it shows here.'))); return; }
634
+ if (!total) { ui.waiting.body.append(el('p', 'sm-hint', t('All caught up. When an agent asks you something, it shows up here.'))); return; }
604
635
  for (const room of rooms.slice(0, 2)) {
605
636
  const row = el('a', 'sm-waiting-row');
606
637
  row.href = addressOf(room);
@@ -622,7 +653,7 @@ function drawMemory() {
622
653
  sum.travelling += census.travelling ?? 0;
623
654
  for (const kind of KINDS) sum.kinds[kind] = (sum.kinds[kind] ?? 0) + (census.kinds?.[kind] ?? 0);
624
655
  }
625
- ui.memory.total.textContent = t('{n} memories', { n: sum.memories });
656
+ ui.memory.total.textContent = memoriesCount(sum.memories);
626
657
  ui.memory.total.hidden = !counted.length;
627
658
  ui.memory.body.replaceChildren();
628
659
  if (!counted.length) { ui.memory.body.append(el('p', 'sm-hint', t('Open a project to count its memory.'))); return; }
@@ -717,8 +748,40 @@ async function restartAll() {
717
748
  // NEEDS YOU: what the person would want to know before anything else, from what the rooms, the
718
749
  // agents and MADRE itself say: a room on an older MADRE or not answering, an agent without a
719
750
  // session, a link about to expire, a newer MADRE. Nothing listed is a guess.
751
+ // REMINDERS (src/modules/reminders.mjs · an idea by Daniel Castillo): the due ones of every
752
+ // project, first in «Needs you», each with its project and the keys to settle it.
753
+ let remindersSeen = null;
754
+ let reminderPrefs = { hour: 9, snooze: 60 }; // Reminders' settings: how long «later» is
755
+ const reminderLocale = () => (document.documentElement.lang === 'en' ? 'en-US' : 'es-MX');
756
+ const reminderWhen = (due) => new Intl.DateTimeFormat(reminderLocale(), { weekday: 'long', hour: 'numeric', minute: '2-digit' }).format(new Date(due));
757
+ async function loadReminders({ opening = false } = {}) {
758
+ const answer = await fetch('/api/reminders', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
759
+ if (!answer) return;
760
+ remindersSeen = answer.reminders ?? [];
761
+ if (answer.prefs) reminderPrefs = answer.prefs;
762
+ const due = remindersSeen.filter((one) => Date.parse(one.due) <= Date.now());
763
+ // Said when MADRE opens, once: the reminders themselves stay in «Needs you» until settled.
764
+ if (opening && due.length) toast(due.length === 1 ? t('A reminder is due: {what}', { what: due[0].text }) : t('{n} reminders are due. They are in «Needs you».', { n: due.length }), 'done');
765
+ drawAttention();
766
+ }
767
+ async function settleReminder(path, payload) {
768
+ const answer = await post(path, payload);
769
+ if (!answer.ok) toast(answer.body?.error ?? t('The reminder did not change.'), 'error');
770
+ await loadReminders();
771
+ }
720
772
  function attentionItems() {
721
773
  const items = [];
774
+ for (const one of (remindersSeen ?? []).filter((item) => Date.parse(item.due) <= Date.now())) {
775
+ const room = data?.rooms.find((item) => item.id === one.room) ?? null;
776
+ // Due is waiting for the person, said as when it fell due (ACT-09): a green dot and «jueves 8:41
777
+ // p.m.» read as a thing done, not as one waiting.
778
+ items.push({
779
+ tone: 'wait', words: one.text,
780
+ hint: [room ? roomLabel(room) : one.project, t('Reminder · due {when}', { when: ago(one.due) })].filter(Boolean).join(' · '),
781
+ act: () => void settleReminder('/api/reminders/done', { id: one.id }), go: one.repeat ? t('Done for today') : t('Done'),
782
+ later: { go: reminderPrefs.snooze === 60 ? t('In an hour') : reminderPrefs.snooze > 60 ? t('In {n} hours', { n: Math.round(reminderPrefs.snooze / 60) }) : t('In {n} minutes', { n: reminderPrefs.snooze }), act: () => void settleReminder('/api/reminders/snooze', { id: one.id, minutes: reminderPrefs.snooze }) },
783
+ });
784
+ }
722
785
  for (const room of data?.rooms ?? []) {
723
786
  if (!room.open) continue;
724
787
  const name = roomLabel(room);
@@ -729,6 +792,11 @@ function attentionItems() {
729
792
  const state = agentState(agent, agentsSeen);
730
793
  if (!state.ok) items.push({ tone: state.key, words: `${agent.label ?? agent.id} · ${state.words}`, hint: t('Connected once, every project uses it.'), act: () => openSettings('agents'), go: t('Connect') });
731
794
  }
795
+ // The welcome left halfway: where it stopped, and the way back to it.
796
+ if (welcomeSeen?.at && !welcomeSeen.finished) {
797
+ const n = WELCOME_STEPS.indexOf(welcomeSeen.at) + 1;
798
+ items.unshift({ tone: 'wait', words: t('MADRE is not ready yet.'), hint: t('The welcome stopped at step {n} of {total}.', { n, total: WELCOME_STEPS.length }), act: () => void openHomeWelcome(), go: t('Continue') });
799
+ }
732
800
  const soon = Date.now() + 3 * 86400000;
733
801
  for (const enlace of data?.enlaces ?? []) {
734
802
  if (!enlace.expires || Date.parse(enlace.expires) > soon) continue;
@@ -744,8 +812,10 @@ function attentionItems() {
744
812
  }
745
813
  function drawAttention() {
746
814
  const items = attentionItems();
815
+ // Said like «Waiting for you» (1.0.5): one big number, calm at 0, in the accent when something needs a hand.
747
816
  ui.attention.count.textContent = String(items.length);
748
- ui.attention.count.hidden = !items.length;
817
+ ui.attention.count.hidden = false;
818
+ ui.attention.count.closest('.sm-tile')?.classList.toggle('has', items.length > 0);
749
819
  ui.attention.list.replaceChildren();
750
820
  if (!items.length) {
751
821
  const calm = el('li', 'sm-attention-item is-calm');
@@ -765,6 +835,11 @@ function drawAttention() {
765
835
  go.href = item.href;
766
836
  if (item.external) { go.target = '_blank'; go.rel = 'noopener'; }
767
837
  row.append(go);
838
+ } else if (item.later) {
839
+ // Two keys in one row (a reminder: done, or in an hour).
840
+ const acts = el('span', 'sm-attention-acts');
841
+ acts.append(button('sm-btn small', item.go, item.act), button('sm-btn small quiet', item.later.go, item.later.act));
842
+ row.append(acts);
768
843
  } else if (item.act) row.append(button('sm-btn small', item.go, item.act));
769
844
  ui.attention.list.append(row);
770
845
  }
@@ -819,9 +894,11 @@ async function loadWork({ again = false } = {}) {
819
894
  function drawWork() {
820
895
  const w = ui.work;
821
896
  w.list.replaceChildren();
897
+ // Whatever it says, the Coordinator's tile is measured again once it is said (fitTile).
898
+ queueMicrotask(() => { if (typeof fitTiles === 'function' && layout) fitTiles(); });
822
899
  const state = work?.state ?? 'loading';
823
900
  w.box.classList.toggle('is-working', state === 'working');
824
- w.again.hidden = !work || state === 'empty' || state === 'unavailable';
901
+ w.again.hidden = !work || state === 'empty' || state === 'unavailable' || state === 'plain';
825
902
  w.again.disabled = state === 'working';
826
903
  if (!work) { w.by.textContent = ''; w.note.textContent = t('Reading your conversations…'); return; }
827
904
  if (state === 'empty') { w.by.textContent = ''; w.note.textContent = t('No conversations in the last two weeks. What you work on in any project shows here, summarised by MADRE.'); return; }
@@ -847,6 +924,7 @@ function drawWork() {
847
924
  w.note.textContent = state === 'working' ? t('MADRE is summarising your latest conversations…')
848
925
  : state === 'unavailable' ? (bullets.length ? t('MADRE\'s local model is off: this is the last summary it wrote.') : t('MADRE\'s local model is off: these are your latest conversations, as they are.'))
849
926
  : state === 'failed' ? t('MADRE could not summarise them this time: these are your latest conversations, as they are.')
927
+ : state === 'plain' ? t('The AI on this computer is small to summarise them well: these are your latest conversations, as they are.')
850
928
  : work.stale ? t('There is newer work than this summary: it updates itself in a few minutes, or now if you press Summarize again.')
851
929
  : t('Written by MADRE on this Mac from your latest conversations.');
852
930
  if (typeof fitTiles === 'function') fitTiles();
@@ -864,75 +942,99 @@ function endsOf(enlace) {
864
942
  const { a, b } = enlace.rooms;
865
943
  return enlace.direction === 'b→a' ? { source: b, reader: a } : { source: a, reader: b };
866
944
  }
945
+ // A connection, said so it is understood at a glance (2026-10-28): who looks up whom, drawn as on the
946
+ // project map — the one that reads, an arrow, the one that shares —; what crosses, until when and
947
+ // whether orders go, as tags; what was read lately; and each thing it allows as a switch with one
948
+ // line on what it does. «Cancel the connection» asks once more before it does.
949
+ const LINK_MARK = (id) => {
950
+ const face = el('span', `sm-link-end${id === data.salas ? ' hub' : ''}`);
951
+ if (id === data.salas) face.append(mark('bishop', 30)); else { face.style.setProperty('--pc', toneOf(id)); face.append(el('i', null, roomName(id).slice(0, 1).toUpperCase())); }
952
+ const words = el('span', 'sm-link-end-words');
953
+ words.append(el('b', null, roomName(id)));
954
+ const box = el('span', 'sm-link-end-box');
955
+ box.append(face, words);
956
+ return box;
957
+ };
958
+ const LINK_ARROW = '<svg viewBox="0 0 60 16" aria-hidden="true"><path d="M58 8H6M12 2.5 6 8l6 5.5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';
959
+ const LINK_BOTH = '<svg viewBox="0 0 60 16" aria-hidden="true"><path d="M6 8h48M12 2.5 6 8l6 5.5M48 2.5 54 8l-6 5.5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';
867
960
  function linkRow(enlace) {
868
961
  const { source, reader } = endsOf(enlace);
869
962
  const node = el('article', `sm-link${revoking.has(enlace.id) ? ' revoking' : ''}`);
870
963
  node.dataset.link = enlace.id;
871
964
  node.append(el('span', 'sm-link-kind', source === data.salas || reader === data.salas ? t('With the Coordinator') : t('Between projects')));
872
- const who = el('p', 'who');
965
+ // Who looks up whom, as the map draws it.
966
+ const pair = el('div', 'sm-link-pair');
967
+ const arrow = el('span', 'sm-link-arrow');
968
+ arrow.innerHTML = enlace.direction === 'both' ? LINK_BOTH : LINK_ARROW; // trusted: our own SVG strings
969
+ arrow.append(el('small', null, enlace.direction === 'both' ? t('read each other') : t('looks up')));
970
+ pair.append(LINK_MARK(reader), arrow, LINK_MARK(source));
971
+ // The drawing says it; the sentence is kept for whoever hears the page.
972
+ const who = el('span');
873
973
  who.append(enlace.direction === 'both' ? sayTinted('{a} and {b} read each other', { a: enlace.rooms.a, b: enlace.rooms.b }) : sayTinted('{reader} reads from {source}', { reader, source }));
874
- node.append(who);
875
- const what = [kindsWords(enlace.kinds), enlace.expires ? t('until {date}', { date: new Date(enlace.expires).toLocaleDateString(language, { day: 'numeric', month: 'short' }) }) : t('no expiry')];
876
- if (enlace.orders?.allowed) what.push(t('orders up to #{n}', { n: enlace.orders.maxMode }));
974
+ pair.setAttribute('role', 'img');
975
+ pair.setAttribute('aria-label', who.textContent);
976
+ node.append(pair);
977
+ // What crosses, until when, and whether orders go.
978
+ const tags = el('div', 'sm-link-tags');
979
+ for (const kind of enlace.kinds ?? []) {
980
+ const word = String(KIND_WORDS[kind] ?? kind).toLocaleLowerCase(language);
981
+ const tag = el('span', 'sm-link-tag');
982
+ tag.append(el('i', `k-${kind}`), word.slice(0, 1).toLocaleUpperCase(language) + word.slice(1));
983
+ tags.append(tag);
984
+ }
985
+ tags.append(el('span', 'sm-link-tag plain', enlace.expires ? t('until {date}', { date: new Date(enlace.expires).toLocaleDateString(language, { day: 'numeric', month: 'short' }) }) : t('no expiry')));
986
+ tags.append(el('span', 'sm-link-tag plain', enlace.orders?.allowed ? t('orders up to #{n}', { n: enlace.orders.maxMode }) : t('no orders')));
877
987
  // D-S13: a link BISHOP signed on its own says so, so it is never mistaken for one you signed.
878
- if (enlace.signed?.by === 'bishop') what.push(t('signed by the Coordinator'));
879
- if (enlace.train) what.push(t('the Coordinator learns from it'));
880
- if (enlace.state) what.push(t('shares its state'));
881
- if (enlace.deliver) what.push(t('receives delivered notes'));
882
- node.append(el('p', 'what', what.join(' · ')));
988
+ if (enlace.signed?.by === 'bishop') tags.append(el('span', 'sm-link-tag plain', t('signed by the Coordinator')));
989
+ node.append(tags);
883
990
  const traffic = enlace.traffic ?? {};
884
991
  // S-021: the last reading says who read, as the room that asked said it.
885
992
  const last = traffic.lastAt ? (traffic.lastAgent ? t('last by @{agent} of {room}, {when}', { agent: traffic.lastAgent, room: roomName(traffic.lastRoom), when: ago(traffic.lastAt) }) : t('last {when}', { when: ago(traffic.lastAt) })) : t('none yet');
886
993
  node.append(el('p', 'traffic', [t('{n} reads in 24 h', { n: traffic.reads24h ?? 0 }), last].join(' · ')));
887
- // Fase 3e: recall on every turn, ticked or cleared here by the human.
888
- const recall = el('label', 'row sm-recall');
889
- const recallBox = el('input'); recallBox.type = 'checkbox'; recallBox.checked = Boolean(enlace.recall);
890
- recallBox.addEventListener('change', async () => {
891
- recallBox.disabled = true;
892
- const answer = await fetch('/api/salas/enlaces/recall', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: enlace.id, recall: recallBox.checked }) })
893
- .then((response) => response.ok).catch(() => false);
894
- if (!answer) recallBox.checked = !recallBox.checked;
895
- recallBox.disabled = false;
896
- await refresh();
897
- });
898
- recall.append(recallBox, document.createTextNode(t('Always include (up to 3 notes)')));
899
- node.append(recall);
900
- // D-S15: on a link the Coordinator reads, whether it also learns from that project.
901
- if (reader === data.salas) {
902
- const learn = el('label', 'row sm-recall');
903
- const learnBox = el('input'); learnBox.type = 'checkbox'; learnBox.checked = Boolean(enlace.train);
904
- learnBox.addEventListener('change', async () => {
905
- learnBox.disabled = true;
906
- const answer = await fetch('/api/salas/enlaces/train', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: enlace.id, train: learnBox.checked }) })
907
- .then((response) => response.ok).catch(() => false);
908
- if (!answer) learnBox.checked = !learnBox.checked;
909
- learnBox.disabled = false;
910
- await refresh();
911
- });
912
- learn.append(learnBox, document.createTextNode(t('The Coordinator learns from it')));
913
- node.append(learn);
914
- }
915
- // D-S16 and D-S17: what else the link allows, ticked or cleared here by you.
916
- for (const [field, label] of [['state', t('It shares its state')], ['deliver', t('It receives delivered notes')]]) {
917
- const allow = el('label', 'row sm-recall');
918
- const box = el('input'); box.type = 'checkbox'; box.checked = Boolean(enlace[field]);
994
+ // What else it allows, each a switch that says what it does (Fase 3e, D-S15, D-S16, D-S17).
995
+ const options = el('div', 'sm-link-options');
996
+ const option = (on, title, says, path, payload) => {
997
+ const line = el('label', 'sm-link-option');
998
+ const words = el('span', 'sm-link-option-words');
999
+ words.append(el('b', null, title), el('small', null, says));
1000
+ const wrap = el('span', 'settings-switch');
1001
+ const box = el('input');
1002
+ box.type = 'checkbox';
1003
+ box.checked = Boolean(on);
919
1004
  box.addEventListener('change', async () => {
920
1005
  box.disabled = true;
921
- const answer = await fetch('/api/salas/enlaces/allow', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: enlace.id, field, on: box.checked }) })
1006
+ const answer = await fetch(path, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(payload(box.checked)) })
922
1007
  .then((response) => response.ok).catch(() => false);
923
1008
  if (!answer) box.checked = !box.checked;
924
1009
  box.disabled = false;
925
1010
  await refresh();
926
1011
  });
927
- allow.append(box, document.createTextNode(label));
928
- node.append(allow);
929
- }
1012
+ wrap.append(box, el('i'));
1013
+ line.append(words, wrap);
1014
+ options.append(line);
1015
+ };
1016
+ option(enlace.recall, t('Always include its notes'), t('Up to 3 of its notes go with every answer, not only when an agent asks for them.'), '/api/salas/enlaces/recall', (on) => ({ id: enlace.id, recall: on }));
1017
+ if (reader === data.salas) option(enlace.train, t('The Coordinator learns from it'), t('What the Coordinator reads here also goes into what it is trained with.'), '/api/salas/enlaces/train', (on) => ({ id: enlace.id, train: on }));
1018
+ option(enlace.state, t('It shares its state'), t('Its goal, phase, next step and what is open can be read too, never its files.'), '/api/salas/enlaces/allow', (on) => ({ id: enlace.id, field: 'state', on }));
1019
+ option(enlace.deliver, t('It receives delivered notes'), t('Notes can be handed to it; they wait for you to accept them before entering its memory.'), '/api/salas/enlaces/allow', (on) => ({ id: enlace.id, field: 'deliver', on }));
1020
+ node.append(options);
930
1021
  const actions = el('div', 'sm-actions');
931
- if (revoking.has(enlace.id)) actions.append(el('span', 'sm-ask', t('Nothing crosses from then on.')), button('sm-btn danger', t('Revoke it'), () => revokeLink(enlace.id)), button('sm-btn ghost', t('Cancel'), () => { revoking.delete(enlace.id); draw(); }));
932
- else actions.append(button('sm-btn ghost', t('Revoke'), () => { revoking.add(enlace.id); draw(); }));
1022
+ if (revoking.has(enlace.id)) actions.append(el('span', 'sm-ask', t('Nothing crosses from then on.')), button('sm-btn danger small', t('Yes, cancel it'), () => revokeLink(enlace.id)), button('sm-btn ghost small', t('Keep the connection'), () => { revoking.delete(enlace.id); draw(); }));
1023
+ else actions.append(button('sm-btn ghost small', t('Cancel the connection'), () => { revoking.add(enlace.id); draw(); }));
933
1024
  node.append(actions);
934
1025
  return node;
935
1026
  }
1027
+ // How a connection works, in three steps under the sheet's title, as the project map says its own
1028
+ // gestures: who shares, who looks up, and you sign — cancelled whenever you want.
1029
+ function drawLinkSteps() {
1030
+ let steps = ui.linksSheet.querySelector('.sm-link-steps');
1031
+ if (!steps) { steps = el('ol', 'sm-link-steps'); ui.linksNote.after(steps); }
1032
+ steps.replaceChildren(...[
1033
+ [t('Choose what it shares'), t('A project and what it learned: decisions, facts, preferences.')],
1034
+ [t('Choose who looks it up'), t('Another project, or the Coordinator, which sees them all.')],
1035
+ [t('You sign it'), t('Until a date or with no end. Cancel it here whenever you want.')],
1036
+ ].map(([title, says], index) => { const item = el('li'); item.append(el('i', null, String(index + 1)), el('b', null, title), el('small', null, says)); return item; }));
1037
+ }
936
1038
  function drawLinks(projects) {
937
1039
  const enlaces = [...(data.enlaces ?? [])].sort((a, b) => {
938
1040
  const direct = (one) => Number(one.rooms.a !== data.salas && one.rooms.b !== data.salas);
@@ -946,7 +1048,8 @@ function drawLinks(projects) {
946
1048
  ui.linksSum.textContent = enlaces.length
947
1049
  ? [enlaces.length === 1 ? t('1 in force') : t('{n} in force', { n: enlaces.length }), t('{n} reads in 24 h', { n: reads })].join(' · ')
948
1050
  : enough ? t('No connections yet.') : t('Add a project to connect it.');
949
- ui.linksNote.textContent = t('A connection lets one project read the summarized notes of another, read-only, by a contract you sign here. Nothing is written across, and only notes already used in answers are shared.');
1051
+ ui.linksNote.textContent = t('A connection lets one project look up what another already learned: its decisions, facts and preferences. It only reads, never changes the other project, and you can cancel it whenever you want.');
1052
+ drawLinkSteps();
950
1053
  ui.links.replaceChildren(...enlaces.map(linkRow));
951
1054
  if (!enlaces.length && ui.linksSheet.open) ui.linksSheet.close();
952
1055
  drawMap(projects, enlaces);
@@ -1069,7 +1172,7 @@ function openGraph() {
1069
1172
  const keys = el('span', 'surface-modes');
1070
1173
  const close = button('surface-mode close x-close x-only', null, () => graphWindow.close());
1071
1174
  close.setAttribute('aria-label', t('Close'));
1072
- close.innerHTML = '<span class="x-icon"><svg viewBox="0 0 20 20" focusable="false" aria-hidden="true"><path d="M5.5 5.5l9 9M14.5 5.5l-9 9" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg></span>'; // trusted
1175
+ close.innerHTML = `<span class="x-icon">${trazo('close')}</span>`; // trusted
1073
1176
  keys.append(close);
1074
1177
  head.append(words, keys);
1075
1178
  const stage = el('div', 'sm-graph-stage');
@@ -1130,8 +1233,11 @@ function paintSide(side, picked, toList) {
1130
1233
  };
1131
1234
  list(t('Looks up'), readsFrom);
1132
1235
  list(t('Looked up by'), readBy);
1133
- if (room?.open && id !== data.salas) side.append(button('sm-btn primary small', t('Open the project'), () => leaveTo(addressOf(room))));
1134
- side.append(listKey);
1236
+ // The keys go side by side, as everywhere else in MADRE (1.0.5): one under the other read as a list.
1237
+ const keys = el('div', 'sm-keys-row');
1238
+ if (room?.open && id !== data.salas) keys.append(button('sm-btn primary small', t('Open the project'), () => leaveTo(addressOf(room))));
1239
+ keys.append(listKey);
1240
+ side.append(keys);
1135
1241
  return;
1136
1242
  }
1137
1243
  const enlace = enlaces.find((one) => one.id === picked.link);
@@ -1195,6 +1301,19 @@ function paintMap(host, projects, enlaces, { wide, pick = null, picked = null })
1195
1301
  merge.append(svgNode('feMergeNode', { in: 'soft' }), svgNode('feMergeNode', { in: 'SourceGraphic' }));
1196
1302
  glow.append(merge);
1197
1303
  defs.append(glow);
1304
+ // NEURAL, 1.0.5: the connections drawn as the neural mode draws memory (public/neural.js), in a
1305
+ // light SVG of their own: a deep glow behind, each project a neuron (a soma that glows, short
1306
+ // dendrites with a bead at the end), each connection an axon that bends a little, and what
1307
+ // crosses it a signal of light that travels the axon. Only what travels lights up.
1308
+ const depthId = `sm-depth-${wide ? 'w' : 't'}`;
1309
+ const depthGradient = svgNode('radialGradient', { id: depthId });
1310
+ for (const [offset, opacity] of [['0%', 1], ['60%', 0.35], ['100%', 0]]) {
1311
+ const stop = svgNode('stop', { offset, 'stop-opacity': opacity, class: 'depth-stop' });
1312
+ depthGradient.append(stop);
1313
+ }
1314
+ defs.append(depthGradient);
1315
+ svg.append(svgNode('ellipse', { class: 'depth', cx, cy, rx: W * 0.55, ry: H * 0.62, fill: `url(#${depthId})` }));
1316
+ const seedOf = (id) => [...String(id)].reduce((sum, char) => (sum * 31 + char.charCodeAt(0)) % 9973, 7);
1198
1317
  const halos = new Map();
1199
1318
  const haloFor = (id, colour) => {
1200
1319
  if (halos.has(id)) return halos.get(id);
@@ -1231,7 +1350,10 @@ function paintMap(host, projects, enlaces, { wide, pick = null, picked = null })
1231
1350
  const { start, end } = edges(from, to);
1232
1351
  // To or from the Coordinator the wire is straight; between two projects it bows away from the
1233
1352
  // middle, so it never runs through the Coordinator.
1234
- let d = `M${start.x.toFixed(1)} ${start.y.toFixed(1)} L${end.x.toFixed(1)} ${end.y.toFixed(1)}`;
1353
+ // An axon to or from the Coordinator bends a little, to one side or the other by its index.
1354
+ const sideways = (index % 2 ? 1 : -1) * Math.min(14, Math.hypot(end.x - start.x, end.y - start.y) * 0.12);
1355
+ const lx = end.x - start.x, ly = end.y - start.y, ll = Math.hypot(lx, ly) || 1;
1356
+ let d = `M${start.x.toFixed(1)} ${start.y.toFixed(1)} Q ${((start.x + end.x) / 2 - (ly / ll) * sideways).toFixed(1)} ${((start.y + end.y) / 2 + (lx / ll) * sideways).toFixed(1)} ${end.x.toFixed(1)} ${end.y.toFixed(1)}`;
1235
1357
  if (source !== data.salas && reader !== data.salas) {
1236
1358
  const mx = (start.x + end.x) / 2, my = (start.y + end.y) / 2;
1237
1359
  const ox = mx - cx, oy = my - cy, out = Math.hypot(ox, oy) || 1;
@@ -1254,15 +1376,25 @@ function paintMap(host, projects, enlaces, { wide, pick = null, picked = null })
1254
1376
  // travel, from the project read to the one reading, and both ways when they read each other.
1255
1377
  // A still line under it says the connection is there even when nothing moves.
1256
1378
  const ways = enlace.direction === 'both' ? [['out', tone], ['back', reader === data.salas ? 'var(--text-3)' : toneOf(reader)]] : [['out', tone]];
1257
- for (const [way, colour] of ways) {
1258
- const flow = svgNode('path', { class: `flow ${way}`, d, filter: `url(#${glowId})` });
1259
- flow.style.stroke = colour;
1260
- flow.style.setProperty('--flow-delay', `${(index * 0.37) % 1.4}s`);
1261
- flow.dataset.a = source;
1262
- flow.dataset.b = reader;
1263
- if (still) flow.classList.add('still');
1264
- svg.append(flow);
1265
- }
1379
+ ways.forEach(([way, colour], wayIndex) => {
1380
+ // A signal of light that travels the axon, the way the notes go; both ways when they read
1381
+ // each other. With reduced motion the axon stays lit instead.
1382
+ if (still) {
1383
+ const lit = svgNode('path', { class: `flow ${way} still`, d });
1384
+ lit.style.stroke = colour;
1385
+ lit.dataset.a = source;
1386
+ lit.dataset.b = reader;
1387
+ svg.append(lit);
1388
+ return;
1389
+ }
1390
+ const signal = svgNode('circle', { class: `flow signal ${way}`, r: wide ? 2.6 : 2.2, filter: `url(#${glowId})` });
1391
+ signal.style.fill = colour;
1392
+ signal.dataset.a = source;
1393
+ signal.dataset.b = reader;
1394
+ const travel = svgNode('animateMotion', { dur: `${(2.8 + ((index + wayIndex) % 4) * 0.45).toFixed(2)}s`, begin: `-${((index * 0.61 + wayIndex * 1.3) % 2.4).toFixed(2)}s`, repeatCount: 'indefinite', path: d, ...(way === 'back' ? { keyPoints: '1;0', keyTimes: '0;1', calcMode: 'linear' } : {}) });
1395
+ signal.append(travel);
1396
+ svg.append(signal);
1397
+ });
1266
1398
  });
1267
1399
  for (const room of ring) {
1268
1400
  const spot = at.get(room.id);
@@ -1276,12 +1408,28 @@ function paintMap(host, projects, enlaces, { wide, pick = null, picked = null })
1276
1408
  const star = svgNode('g', { class: 'star' });
1277
1409
  star.style.setProperty('--tw', `${(2.6 + ((room.id.length * 37) % 19) / 10).toFixed(1)}s`);
1278
1410
  star.style.setProperty('--tw-delay', `${(((room.id.charCodeAt(0) ?? 0) * 13) % 23) / 10}s`);
1411
+ // 1.0.5, quieter: a small soft halo, a solid dot of its tone and a hairline ring around it.
1279
1412
  star.append(
1280
- svgNode('circle', { class: 'halo', cx: spot.x.toFixed(1), cy: spot.y.toFixed(1), r: (spot.r * (on ? 2.9 : 2.2)).toFixed(1), fill: haloFor(room.id, toneOf(room.id)) }),
1281
- svgNode('circle', { class: 'body', cx: spot.x.toFixed(1), cy: spot.y.toFixed(1), r: (spot.r * (on ? 0.82 : 0.9)).toFixed(1) }),
1282
- svgNode('circle', { class: 'heart', cx: spot.x.toFixed(1), cy: spot.y.toFixed(1), r: Math.max(0.9, spot.r * 0.22).toFixed(1) }),
1413
+ svgNode('circle', { class: 'halo', cx: spot.x.toFixed(1), cy: spot.y.toFixed(1), r: (spot.r * (on ? 1.9 : 1.5)).toFixed(1), fill: haloFor(room.id, toneOf(room.id)) }),
1414
+ svgNode('circle', { class: 'ring', cx: spot.x.toFixed(1), cy: spot.y.toFixed(1), r: (spot.r * 0.95 + 3).toFixed(1) }),
1415
+ svgNode('circle', { class: 'body', cx: spot.x.toFixed(1), cy: spot.y.toFixed(1), r: (spot.r * (on ? 0.62 : 0.55)).toFixed(1) }),
1416
+ svgNode('circle', { class: 'heart', cx: spot.x.toFixed(1), cy: spot.y.toFixed(1), r: Math.max(0.8, spot.r * 0.18).toFixed(1) }),
1283
1417
  );
1284
- group.append(star);
1418
+ // Its dendrites: three or four short fibres, each with a bead at the end, at angles of its own
1419
+ // (from its id, so a project always looks the same), never towards where its name is written.
1420
+ const seed = seedOf(room.id);
1421
+ const fibres = svgNode('g', { class: 'dendrites' });
1422
+ const count = on ? 4 : 3;
1423
+ for (let at = 0; at < count; at += 1) {
1424
+ const angle = Math.atan2(spot.sin, spot.cos) + Math.PI * (0.55 + (at / count) * 0.9) + ((seed % 17) - 8) * 0.03;
1425
+ const length = spot.r * (1.7 + ((seed >> at) % 5) * 0.18);
1426
+ const ax = spot.x + Math.cos(angle) * spot.r * 0.7, ay = spot.y + Math.sin(angle) * spot.r * 0.7;
1427
+ const bx = spot.x + Math.cos(angle) * (spot.r + length), by = spot.y + Math.sin(angle) * (spot.r + length);
1428
+ const bend = ((seed >> (at + 2)) % 2 ? 1 : -1) * length * 0.22;
1429
+ fibres.append(svgNode('path', { d: `M${ax.toFixed(1)} ${ay.toFixed(1)} Q ${((ax + bx) / 2 - Math.sin(angle) * bend).toFixed(1)} ${((ay + by) / 2 + Math.cos(angle) * bend).toFixed(1)} ${bx.toFixed(1)} ${by.toFixed(1)}` }));
1430
+ fibres.append(svgNode('circle', { class: 'bead', cx: bx.toFixed(1), cy: by.toFixed(1), r: 1.05 }));
1431
+ }
1432
+ group.append(fibres, star);
1285
1433
  const title = svgNode('title');
1286
1434
  title.textContent = `${room.name} · ${stateOf(room).words}`;
1287
1435
  group.append(title);
@@ -1301,7 +1449,7 @@ function paintMap(host, projects, enlaces, { wide, pick = null, picked = null })
1301
1449
  const hub = svgNode('g', { class: `bishop${linked.has(data.salas) ? ' linked' : ''}` });
1302
1450
  hub.dataset.id = data.salas;
1303
1451
  // The Coordinator is the brightest star, in its own colour, its mark at the heart.
1304
- hub.append(svgNode('circle', { class: 'corona', cx, cy, r: hubR * 2.4, fill: haloFor(data.salas, brand.solid ?? brand.color) }));
1452
+ hub.append(svgNode('circle', { class: 'corona', cx, cy, r: hubR * 1.6, fill: haloFor(data.salas, brand.solid ?? brand.color) }));
1305
1453
  if (linked.has(data.salas)) hub.append(svgNode('circle', { class: 'halo', cx, cy, r: hubR + 6 }));
1306
1454
  hub.append(svgNode('circle', { class: 'core', cx, cy, r: hubR, fill: brand.solid ?? brand.color }));
1307
1455
  const size = Math.round(hubR * 1.24);
@@ -1365,25 +1513,46 @@ const WIDGETS = {
1365
1513
  'w-coordinator': { kind: 'coordinator', name: () => t('Coordinator training'), about: () => t('How far the Coordinator\'s own record is from training a model of its own.'), size: 4, rows: 3 },
1366
1514
  // Only for MADRE's author, in a copy run from source with the author's token (src/server.mjs, homeWidget):
1367
1515
  // anywhere else the server has no such widget and Home never offers it.
1368
- 'w-usage': { kind: 'usage', owner: true, name: () => t('MADRE usage'), about: () => t('How many copies of MADRE are on, which versions and whether people come back. Only you see this.'), size: 8, rows: 3 },
1516
+ 'w-usage': { kind: 'usage', owner: true, name: () => t('MADRE usage'), about: () => t('How many copies of MADRE are on, which versions and whether people come back. Only you see this.'), size: 8, rows: 5 },
1517
+ // What fails in every copy (src/telemetry.mjs, madre.run's /api/telemetry, 2026-10-28): the author's
1518
+ // too, with the same token, and nowhere else.
1519
+ 'w-errors': { kind: 'errors', owner: true, name: () => t('MADRE errors'), about: () => t('What fails in every copy of MADRE, by how many copies it reaches: the ones Diagnostics knows and the ones nobody catalogued. Only you see this.'), size: 8, rows: 5 },
1520
+ // The author's board (2026-10-30, madre.run's /api/metrics): copies on right now and off, installs,
1521
+ // updates and uninstalls by day, and where MADRE runs. Only in the author's copy run from source.
1522
+ 'w-live': { kind: 'live', owner: true, name: () => t('MADRE live'), about: () => t('How many copies of MADRE are on right now, and how many of this month\'s are off. Only you see this.'), size: 4, rows: 3 },
1523
+ 'w-installs': { kind: 'installs', owner: true, name: () => t('Installs'), about: () => t('Installs, updates and uninstalls of MADRE by day, the last 30 days. Only you see this.'), size: 8, rows: 3 },
1524
+ 'w-environments': { kind: 'environments', owner: true, name: () => t('Where MADRE runs'), about: () => t('The systems, memory, agents, projects per copy and modules of the copies this month. Only you see this.'), size: 8, rows: 5 },
1369
1525
  'w-models': { kind: 'models', name: () => t('Local models'), about: () => t('Ollama, its models, and how close each project is to its own.'), size: 4, rows: 3 },
1526
+ // Your agenda (2026-10-28): every project's reminders by when they are due — late, today, tomorrow,
1527
+ // this week, later —, each settled here, and a new one written as you would say it. Read from the
1528
+ // reminders themselves (src/modules/reminders.mjs), not from a widget of the server.
1529
+ 'w-agenda': { kind: 'agenda', name: () => t('Agenda'), about: () => t('Your reminders from every project, by day, and a new one written as you would say it.'), size: 4, rows: 4, read: async () => {
1530
+ const answer = await fetch('/api/reminders?all=1', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
1531
+ if (answer?.prefs) reminderPrefs = answer.prefs;
1532
+ return answer ? { reminders: answer.reminders ?? [] } : null;
1533
+ } },
1370
1534
  };
1371
1535
  const DEFAULT_LAYOUT = { order: ['bishop', 'waiting', 'links', 'projects', 'decisions', 'attention', 'memory'], size: {}, rows: {} };
1372
1536
  // What each tile is, drawn in the accent the person chose (the same line as the room's AJUSTES icons).
1373
1537
  const TILE_ICONS = {
1374
- 'bishop': '<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="2.6"/><circle cx="10" cy="3.6" r="1.4"/><circle cx="4.4" cy="14" r="1.4"/><circle cx="15.6" cy="14" r="1.4"/><path d="M10 5v2.4M8 11.6 5.6 13.2M12 11.6l2.4 1.6"/></svg>',
1375
- 'waiting': '<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M6 3.5h8M6 16.5h8M6.8 3.5c0 3.2 3.2 4 3.2 6.5S6.8 13.3 6.8 16.5M13.2 3.5c0 3.2-3.2 4-3.2 6.5s3.2 3.3 3.2 6.5"/></svg>',
1376
- 'projects': '<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="14" height="12.5" rx="2.4"/><path d="M3 9.2h14M8 6.6h4"/></svg>',
1377
- 'links': '<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="5" cy="13.5" r="2.2"/><circle cx="15" cy="6.5" r="2.2"/><path d="M7 12.2 13 7.8"/></svg>',
1378
- 'decisions': '<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3.5" y="3.5" width="13" height="13" rx="3"/><path d="m7 10.2 2.1 2.1L13.2 8"/></svg>',
1379
- 'attention': '<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="6.5"/><path d="M10 6.6v4.2"/><path d="M10 13.4h.01" stroke-width="2.2"/></svg>',
1380
- 'memory': '<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="10" cy="5.6" rx="5.5" ry="2.1"/><path d="M4.5 5.6v4.4c0 1.2 2.5 2.1 5.5 2.1s5.5-.9 5.5-2.1V5.6M4.5 10v4.4c0 1.2 2.5 2.1 5.5 2.1s5.5-.9 5.5-2.1V10"/></svg>',
1381
- 'w-system': '<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="5.5" y="5.5" width="9" height="9" rx="1.8"/><path d="M8 3v2.5M12 3v2.5M8 14.5V17M12 14.5V17M3 8h2.5M3 12h2.5M14.5 8H17M14.5 12H17"/></svg>',
1382
- 'w-servers': '<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3.5" y="3.8" width="13" height="5" rx="1.6"/><rect x="3.5" y="11.2" width="13" height="5" rx="1.6"/><path d="M6.4 6.3h.01M6.4 13.7h.01" stroke-width="2.2"/><path d="M10 6.3h3.4M10 13.7h3.4"/></svg>',
1383
- 'w-memory': '<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M3.8 13.5a6.2 6.2 0 1 1 12.4 0"/><path d="m10 13.5 3-4"/><path d="M10 13.5h.01" stroke-width="2.4"/></svg>',
1384
- 'w-coordinator': '<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M3.5 16.5h13"/><path d="M5 13.5l3.2-3.2 2.6 2.4 4.2-5.2"/><path d="M12.4 7.5H15v2.6"/></svg>',
1385
- 'w-models': '<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M10 3.2 16 6.6v6.8L10 16.8 4 13.4V6.6z"/><path d="M4 6.6 10 10l6-3.4M10 10v6.8"/></svg>',
1386
- 'w-usage': '<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M3.5 16.5h13"/><path d="M5.5 13.5v-3M9 13.5V7M12.5 13.5v-4.5M16 13.5V4.5"/></svg>',
1538
+ 'bishop': trazo('coordinator'),
1539
+ 'waiting': trazo('hourglass'),
1540
+ 'projects': trazo('card'),
1541
+ 'links': trazo('edge'),
1542
+ 'decisions': trazo('checkbox'),
1543
+ 'attention': trazo('alert'),
1544
+ 'memory': trazo('database'),
1545
+ 'w-system': trazo('chip'),
1546
+ 'w-servers': trazo('server'),
1547
+ 'w-memory': trazo('gauge'),
1548
+ 'w-coordinator': trazo('trending'),
1549
+ 'w-models': trazo('cube'),
1550
+ 'w-agenda': trazo('calendar'),
1551
+ 'w-usage': trazo('bars'),
1552
+ 'w-errors': trazo('warning'),
1553
+ 'w-live': trazo('broadcast'),
1554
+ 'w-installs': trazo('download'),
1555
+ 'w-environments': trazo('globe'),
1387
1556
  };
1388
1557
  const tileIcon = (id) => { const box = el('span', 'sm-tile-icon'); box.innerHTML = TILE_ICONS[id] ?? ''; return box; }; // trusted: our own SVG strings
1389
1558
  const known = (id) => Object.hasOwn(HOME_TILES, id) || Object.hasOwn(WIDGETS, id);
@@ -1445,7 +1614,11 @@ const rowsOf = (id) => layout.rows?.[id] ?? (HOME_TILES[id] ?? WIDGETS[id])?.row
1445
1614
  const PAIRED = window.matchMedia?.('(max-width: 1180px) and (min-width: 761px)');
1446
1615
  PAIRED?.addEventListener?.('change', () => fitTiles());
1447
1616
  function fitTile(node) {
1448
- const own = rowsOf(node.dataset.tile);
1617
+ // The Coordinator with no summary yet, across the whole board, is as tall as what it holds (2026-10-28):
1618
+ // its five rows only kept an empty box open. Beside other tiles it keeps its rows, and the box says
1619
+ // what will come there (salas-mac.css, the empty summary).
1620
+ const unsaid = node.id === 'sm-bishop' && !ui.work.list.childElementCount && !layout.rows?.bishop && node.getBoundingClientRect().width > ($(BOARD)?.getBoundingClientRect().width ?? Infinity) * 0.9;
1621
+ const own = unsaid ? 0 : rowsOf(node.dataset.tile);
1449
1622
  const chosen = own && PAIRED?.matches && spanOf(node.dataset.tile) < 12 ? Math.max(3, own) : own;
1450
1623
  node.classList.toggle('sm-fixed', chosen > 0);
1451
1624
  // How many rows it has, for the tile's own CSS: a short tile shows what matters and leaves the rest.
@@ -1483,16 +1656,16 @@ function addTile(id) {
1483
1656
 
1484
1657
  // The menu a right-click opens, shared by the tiles and the space between them: the same card and
1485
1658
  // keys as a project's menu (pinsMenu), closed the same way.
1486
- const MOVE_ICON = '<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M10 3.5v13M5.5 8 10 3.5 14.5 8M5.5 12 10 16.5 14.5 12" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';
1487
- const BEFORE_ICON = '<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M12.5 4.5 7 10l5.5 5.5" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>';
1488
- const AFTER_ICON = '<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M7.5 4.5 13 10l-5.5 5.5" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>';
1659
+ const MOVE_ICON = trazo('move');
1660
+ const BEFORE_ICON = trazo('back');
1661
+ const AFTER_ICON = trazo('next');
1489
1662
  // A height is drawn as the rows it takes, out of five; «Automatic» as rows that follow the content.
1490
- const heightIcon = (count) => `<svg viewBox="0 0 20 20" aria-hidden="true"><rect x="5.2" y="2.8" width="9.6" height="14.4" rx="2.4" fill="none" stroke="currentColor" stroke-width="1.4" opacity=".45"/>${count ? `<rect x="7" y="${(15.4 - 10.8 * count / 5).toFixed(2)}" width="6" height="${(10.8 * count / 5).toFixed(2)}" rx="1.2" fill="currentColor"/>` : '<path d="M7.2 8.6 10 6l2.8 2.6M7.2 11.4 10 14l2.8-2.6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>'}</svg>`;
1663
+ const heightIcon = (count) => `<svg viewBox="0 0 20 20" aria-hidden="true"><rect x="5.2" y="2.8" width="9.6" height="14.4" rx="2.4" fill="none" stroke="currentColor" stroke-width="1.6" opacity=".45"/>${count ? `<rect x="7" y="${(15.4 - 10.8 * count / 5).toFixed(2)}" width="6" height="${(10.8 * count / 5).toFixed(2)}" rx="1.2" fill="currentColor"/>` : '<path d="M7.2 8.6 10 6l2.8 2.6M7.2 11.4 10 14l2.8-2.6" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>'}</svg>`;
1491
1664
  // A size is drawn as the share of the row it takes: a third, a half, two thirds, all of it.
1492
- const sizeIcon = (span) => `<svg viewBox="0 0 20 20" aria-hidden="true"><rect x="2.8" y="5.2" width="14.4" height="9.6" rx="2.4" fill="none" stroke="currentColor" stroke-width="1.4" opacity=".45"/><rect x="4.6" y="7" width="${(10.8 * span / 12).toFixed(2)}" height="6" rx="1.2" fill="currentColor"/></svg>`;
1493
- const ADD_ICON = '<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M10 4.5v11M4.5 10h11" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>';
1494
- const RESET_ICON = '<svg viewBox="0 0 20 20" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M4.2 8.6A6 6 0 1 1 4.8 13"/><path d="M3.8 4.6v4.2H8"/></svg>';
1495
- const HIDE_ICON = '<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M5.5 10h9" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>';
1665
+ const sizeIcon = (span) => `<svg viewBox="0 0 20 20" aria-hidden="true"><rect x="2.8" y="5.2" width="14.4" height="9.6" rx="2.4" fill="none" stroke="currentColor" stroke-width="1.6" opacity=".45"/><rect x="4.6" y="7" width="${(10.8 * span / 12).toFixed(2)}" height="6" rx="1.2" fill="currentColor"/></svg>`;
1666
+ const ADD_ICON = trazo('add');
1667
+ const RESET_ICON = trazo('reset');
1668
+ const HIDE_ICON = trazo('minus');
1496
1669
  function homeMenu(point, entries, label) {
1497
1670
  pinsCloseMenu();
1498
1671
  const menu = el('div', 'bar-card sm-menu');
@@ -1692,6 +1865,8 @@ document.querySelector('.sm-main')?.addEventListener('contextmenu', (event) => {
1692
1865
  // it would need when nothing feeds it yet.
1693
1866
  let homeAddSheet = null;
1694
1867
  async function openHomeAdd() {
1868
+ // Asked again while it is open: the same window comes forward, not a second one.
1869
+ if (homeAddSheet?.open) { homeAddSheet.focus?.(); homeWindowForward(homeAddSheet); return; }
1695
1870
  homeAddSheet?.remove();
1696
1871
  homeAddSheet = el('dialog', 'sm-sheet sm-add-sheet');
1697
1872
  const body = el('div', 'sm-sheet-body');
@@ -1701,7 +1876,7 @@ async function openHomeAdd() {
1701
1876
  const keys = el('span', 'surface-modes');
1702
1877
  const close = button('surface-mode close x-close x-only', null, () => homeAddSheet.close());
1703
1878
  close.setAttribute('aria-label', t('Close'));
1704
- close.innerHTML = '<span class="x-icon"><svg viewBox="0 0 20 20" focusable="false" aria-hidden="true"><path d="M5.5 5.5l9 9M14.5 5.5l-9 9" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg></span>'; // trusted
1879
+ close.innerHTML = `<span class="x-icon">${trazo('close')}</span>`; // trusted
1705
1880
  keys.append(close);
1706
1881
  head.append(keys);
1707
1882
  body.append(head, el('p', 'hint', t('Tiles you took off and widgets you can put on Home. Right-click any tile to move it, resize it or take it off.')));
@@ -1711,10 +1886,31 @@ async function openHomeAdd() {
1711
1886
  // The key's squares stay filled while the sheet it opened is there.
1712
1887
  const key = document.getElementById('sm-add-widgets');
1713
1888
  key?.classList.add('filled');
1714
- homeAddSheet.addEventListener('close', () => { homeAddSheet?.remove(); homeAddSheet = null; key?.classList.remove('filled'); });
1715
1889
  document.body.append(homeAddSheet);
1716
- homeAddSheet.showModal();
1717
- void homeTour.hint('home-add', list, { inside: true, title: t('Add to Home'), text: t('The tiles you took off, and the widgets. A widget is offered only when something on this Mac feeds it; right-click any tile to move it, resize it or take it off.') });
1890
+ // A window of Home, as Settings and the Market are (2026-10-28): carried by its head, sized by its
1891
+ // sides, its place kept. On a phone it stays the sheet it was.
1892
+ const sheetNow = homeAddSheet;
1893
+ const framed = homeWindow({ root: sheetNow, bar: head, close: () => sheetNow.close(), key: 'pulse.homeAddWindow', minW: 420, minH: 240, keys: false, size: { w: 560, h: 640 } });
1894
+ // As tall as its list, unless the person gave it a size of their own (2026-10-28): with two widgets
1895
+ // a window of 640 px was mostly empty.
1896
+ const fit = () => {
1897
+ if (!framed || !sheetNow.isConnected) return;
1898
+ let sized = null;
1899
+ try { sized = localStorage.getItem('pulse.homeAddWindow'); } catch { /* no storage: fit it */ }
1900
+ if (sized) return;
1901
+ // Down to the foot of its list: scrollHeight never says less than the window already is.
1902
+ const below = getComputedStyle(body);
1903
+ const need = Math.ceil(list.getBoundingClientRect().bottom - body.getBoundingClientRect().top + body.scrollTop + Number.parseFloat(below.paddingBottom) + Number.parseFloat(below.borderBottomWidth));
1904
+ if (need < sheetNow.getBoundingClientRect().height) framed.resize({ h: Math.max(240, need) });
1905
+ };
1906
+ sheetNow.addEventListener('close', () => { framed?.drop(); sheetNow.remove(); if (homeAddSheet === sheetNow) homeAddSheet = null; key?.classList.remove('filled'); });
1907
+ if (framed) {
1908
+ sheetNow.classList.add('sm-add-framed');
1909
+ sheetNow.addEventListener('keydown', (event) => { if (event.key === 'Escape' && !event.defaultPrevented) { event.preventDefault(); sheetNow.close(); } });
1910
+ sheetNow.show();
1911
+ framed.raise();
1912
+ } else sheetNow.showModal();
1913
+ void homeTour.hint('home-add', list, { inside: true, title: t('Add to Home'), text: t('The tiles you took off and the widgets you can add. A widget shows up only when this Mac has something to put in it. Right-click any tile to move it, change its size or take it off.') });
1718
1914
  // The author's widget is asked about before the list is drawn: where it cannot be read, it is not listed at all.
1719
1915
  const ownerOk = new Set();
1720
1916
  for (const [id, spec] of Object.entries(WIDGETS).filter(([id, spec]) => spec.owner && !placed(id))) {
@@ -1725,7 +1921,7 @@ async function openHomeAdd() {
1725
1921
  ...Object.entries(HOME_TILES).filter(([id]) => !placed(id)).map(([id, spec]) => ({ id, spec, ready: true })),
1726
1922
  ...Object.entries(WIDGETS).filter(([id, spec]) => !placed(id) && (!spec.owner || ownerOk.has(id))).map(([id, spec]) => ({ id, spec, ready: null })),
1727
1923
  ];
1728
- if (!entries.length) { list.append(el('p', 'sm-hint', t('Everything is already on Home.'))); return; }
1924
+ if (!entries.length) { list.append(el('p', 'sm-hint', t('Everything is already on Home.'))); fit(); return; }
1729
1925
  for (const entry of entries) {
1730
1926
  const row = el('div', 'sm-add-row');
1731
1927
  row.append(tileIcon(entry.id));
@@ -1740,7 +1936,9 @@ async function openHomeAdd() {
1740
1936
  if (entry.ready === null) {
1741
1937
  add.disabled = true;
1742
1938
  said.textContent = t('Checking…');
1743
- const reading = await fetch(`/api/salas/widget?kind=${entry.spec.kind}`, { cache: 'no-store' }).then((response) => (response.ok ? response.json() : { failed: response.status })).catch(() => ({ failed: true }));
1939
+ // One that reads for itself (the agenda) is ready when it can read: it has a box to start with.
1940
+ const reading = entry.spec.read ? ((await entry.spec.read()) ? { available: true } : { failed: true })
1941
+ : await fetch(`/api/salas/widget?kind=${entry.spec.kind}`, { cache: 'no-store' }).then((response) => (response.ok ? response.json() : { failed: response.status })).catch(() => ({ failed: true }));
1744
1942
  if (!row.isConnected) return;
1745
1943
  const ok = Boolean(reading?.available);
1746
1944
  add.disabled = !ok;
@@ -1749,6 +1947,7 @@ async function openHomeAdd() {
1749
1947
  said.textContent = ok ? '' : reading.failed === 404 ? t('This page is served by a project started before widgets existed: open Home from its own address, or restart that project.') : reading.failed ? t('It could not be read just now.') : (entry.spec.needs?.() ?? t('Nothing feeds it on this Mac yet.'));
1750
1948
  }
1751
1949
  }
1950
+ fit();
1752
1951
  }
1753
1952
 
1754
1953
  // ---- The widgets. Each is a tile that reads its own route every 20 s while Home is in view.
@@ -1763,35 +1962,250 @@ function meter(value, tone = null) {
1763
1962
  }
1764
1963
  const toneFor = (share) => (share >= 0.85 ? 'hot' : share >= 0.6 ? 'warm' : null);
1765
1964
  const OS_WORDS = { darwin: 'macOS', linux: 'Linux', win32: 'Windows', other: () => t('other') };
1965
+ const osWord = (name) => { const word = OS_WORDS[name] ?? name; return typeof word === 'function' ? word() : word; };
1766
1966
  const WIDGET_PAINT = {
1967
+ // The agenda: what is late and what is today first, then tomorrow, this week and later; a line per
1968
+ // reminder with its project and its keys; and a box for a new one, in the person's own words.
1969
+ agenda(body, reading, { again } = {}) {
1970
+ const list = reading.reminders ?? [];
1971
+ const now = new Date();
1972
+ const day = (offset) => { const one = new Date(now); one.setHours(0, 0, 0, 0); one.setDate(one.getDate() + offset); return one.getTime(); };
1973
+ const groups = [
1974
+ [t('Late'), (at) => at < now.getTime()],
1975
+ [t('Today'), (at) => at < day(1)],
1976
+ [t('Tomorrow'), (at) => at < day(2)],
1977
+ [t('This week'), (at) => at < day(7)],
1978
+ [t('Later'), () => true],
1979
+ ];
1980
+ const used = new Set();
1981
+ const time = (due) => new Intl.DateTimeFormat(reminderLocale(), { hour: 'numeric', minute: '2-digit' }).format(new Date(due));
1982
+ const date = (due) => new Intl.DateTimeFormat(reminderLocale(), { weekday: 'short', day: 'numeric', month: 'short' }).format(new Date(due));
1983
+ const box = el('div', 'sm-agenda');
1984
+ let shown = 0;
1985
+ for (const [title, fits] of groups) {
1986
+ const mine = list.filter((one) => !used.has(one.id) && fits(Date.parse(one.due)));
1987
+ for (const one of mine) used.add(one.id);
1988
+ if (!mine.length || shown >= 6) continue;
1989
+ const group = el('div', `sm-agenda-group${title === t('Late') ? ' late' : ''}`);
1990
+ group.append(el('span', 'sm-agenda-day', title));
1991
+ for (const one of mine.slice(0, 6 - shown)) {
1992
+ shown += 1;
1993
+ const row = el('div', 'sm-agenda-row');
1994
+ const words = el('div', 'sm-agenda-words');
1995
+ const when = title === t('Today') || title === t('Late') || title === t('Tomorrow') ? time(one.due) : date(one.due);
1996
+ const room = data?.rooms.find((item) => item.id === one.room) ?? null;
1997
+ words.append(el('b', null, one.text), el('small', null, [when, room ? roomLabel(room) : one.project, one.repeat ? t('repeats') : null].filter(Boolean).join(' · ')));
1998
+ const done = button('sm-agenda-key', null, async () => { done.disabled = true; await settleReminder('/api/reminders/done', { id: one.id }); again?.(); });
1999
+ done.innerHTML = trazo('check'); // trusted
2000
+ done.setAttribute('aria-label', t('Done'));
2001
+ done.title = t('Done');
2002
+ const later = button('sm-agenda-later', t('Later'), async () => { later.disabled = true; await settleReminder('/api/reminders/snooze', { id: one.id, minutes: reminderPrefs.snooze }); again?.(); });
2003
+ row.append(done, words, later);
2004
+ group.append(row);
2005
+ }
2006
+ box.append(group);
2007
+ }
2008
+ if (!list.length) box.append(el('p', 'sm-hint sm-agenda-empty', t('Nothing on your agenda. Write one below, or ask an agent to remind you of something.')));
2009
+ else if (list.length > shown) box.append(el('p', 'sm-hint', t('And {n} more.', { n: list.length - shown })));
2010
+ // A new one, as you would say it: «tomorrow at 5 call Ana» (the time first is taken off the words).
2011
+ const form = el('form', 'sm-agenda-add');
2012
+ const input = el('input');
2013
+ input.type = 'text';
2014
+ input.autocomplete = 'off';
2015
+ input.placeholder = t('Remind me… (tomorrow at 5 call Ana)');
2016
+ input.setAttribute('aria-label', t('New reminder'));
2017
+ const add = el('button', 'sm-btn small', t('Add'));
2018
+ add.type = 'submit';
2019
+ const said = el('small', 'sm-agenda-said');
2020
+ form.append(input, add, said);
2021
+ form.addEventListener('submit', async (event) => {
2022
+ event.preventDefault();
2023
+ const text = input.value.trim();
2024
+ if (!text) { input.focus(); return; }
2025
+ add.disabled = true;
2026
+ const answer = await post('/api/reminders', { text });
2027
+ add.disabled = false;
2028
+ if (!answer.ok) { said.textContent = answer.body?.error ?? t('The reminder was not set.'); return; }
2029
+ input.value = '';
2030
+ input.blur();
2031
+ const due = answer.body?.reminder?.due;
2032
+ if (due) toast(t('Reminder set: {when}.', { when: reminderWhen(due) }));
2033
+ again?.();
2034
+ void loadReminders();
2035
+ });
2036
+ body.append(box, form);
2037
+ },
2038
+ // The author's board (2026-10-30): one reading of madre.run's /api/metrics for the three.
2039
+ live(body, reading) {
2040
+ if (!reading.available) { body.append(el('p', 'sm-hint', reading.status ? t('madre.run answered {status}.', { status: reading.status }) : t('madre.run could not be reached.'))); return; }
2041
+ const live = reading.live ?? {};
2042
+ const lead = el('div', 'sm-usage-lead sm-live-lead');
2043
+ lead.append(el('i', `sm-live-dot${live.on ? ' on' : ''}`), el('b', 'sm-w-big', Number(live.on ?? 0).toLocaleString()), el('span', null, t('on right now')));
2044
+ body.append(lead);
2045
+ const grid = el('div', 'sm-w-grid sm-usage-figures');
2046
+ for (const [label, value, line] of [
2047
+ [t('Off now'), live.off, t('used this month, not on now')],
2048
+ [t('Last hour'), live.hour, t('on at some moment')],
2049
+ [t('Silent'), live.silent, t('diagnostics off or a MADRE before 1.1.0')],
2050
+ ]) {
2051
+ const cell = el('div', 'sm-w-metric');
2052
+ cell.append(el('span', 'sm-w-label', label), el('b', 'sm-w-big', Number(value ?? 0).toLocaleString()), el('small', null, line));
2053
+ grid.append(cell);
2054
+ }
2055
+ body.append(grid);
2056
+ const shares = (list, word = (name) => name) => {
2057
+ const total = list.reduce((sum, one) => sum + one.n, 0);
2058
+ return list.slice(0, 4).map((one) => `${word(one.name)} ${total ? Math.round((one.n / total) * 100) : 0}%`).join(' · ') || '—';
2059
+ };
2060
+ const lines = el('div', 'sm-usage-lines');
2061
+ for (const [label, said] of [[t('Versions'), shares(live.versions ?? [])], [t('Systems'), shares(live.os ?? [], osWord)]]) {
2062
+ const row = el('div', 'sm-w-line');
2063
+ row.append(el('b', null, label), el('small', null, said));
2064
+ lines.append(row);
2065
+ }
2066
+ body.append(lines);
2067
+ },
2068
+ installs(body, reading) {
2069
+ if (!reading.available) { body.append(el('p', 'sm-hint', reading.status ? t('madre.run answered {status}.', { status: reading.status }) : t('madre.run could not be reached.'))); return; }
2070
+ const life = reading.lifecycle ?? { days: [], totals: {} };
2071
+ const totals = life.totals ?? {};
2072
+ const grid = el('div', 'sm-w-grid sm-usage-figures');
2073
+ for (const [label, value, line, tone] of [
2074
+ [t('Installs'), totals.installs, t('new copies, 30 days'), 'up'],
2075
+ [t('Updates'), totals.updates, t('a new version opened'), null],
2076
+ [t('Uninstalls'), totals.uninstalls, t('from Settings'), 'down'],
2077
+ [t('Home opened'), totals.starts, t('times, every copy'), null],
2078
+ ]) {
2079
+ const cell = el('div', `sm-w-metric${tone ? ` sm-life-${tone}` : ''}`);
2080
+ cell.append(el('span', 'sm-w-label', label), el('b', 'sm-w-big', Number(value ?? 0).toLocaleString()), el('small', null, line));
2081
+ grid.append(cell);
2082
+ }
2083
+ body.append(grid);
2084
+ // Each day: installs up from the line, uninstalls down from it, updates as a quieter part of the bar.
2085
+ const days = life.days ?? [];
2086
+ const top = Math.max(1, ...days.map((one) => one.installs + one.updates), ...days.map((one) => one.uninstalls));
2087
+ const chart = el('div', 'sm-usage-chart');
2088
+ const bars = el('div', 'sm-life-days');
2089
+ bars.setAttribute('role', 'img');
2090
+ bars.setAttribute('aria-label', t('Installs, updates and uninstalls on each day, last 30 days'));
2091
+ const shortDay = (day) => new Date(`${day}T12:00:00Z`).toLocaleDateString(document.documentElement.lang === 'en' ? 'en-US' : 'es-MX', { day: 'numeric', month: 'short' });
2092
+ for (const one of days) {
2093
+ const day = el('span');
2094
+ const up = el('i', 'up');
2095
+ up.style.setProperty('--h', String((one.installs + one.updates) / top));
2096
+ up.style.setProperty('--part', String(one.installs + one.updates ? one.installs / (one.installs + one.updates) : 0));
2097
+ const down = el('i', 'down');
2098
+ down.style.setProperty('--h', String(one.uninstalls / top));
2099
+ day.append(up, down);
2100
+ day.title = t('{day}: {installs} installed · {updates} updated · {uninstalls} uninstalled', { day: shortDay(one.day), installs: one.installs, updates: one.updates, uninstalls: one.uninstalls });
2101
+ bars.append(day);
2102
+ }
2103
+ const axis = el('div', 'sm-usage-axis');
2104
+ axis.append(el('small', null, shortDay(days[0]?.day ?? reading.today)), el('small', 'sm-usage-legend', ''), el('small', null, t('today')));
2105
+ axis.children[1].append(el('i', 'is-new'), t('installed'), el('i', 'is-on'), t('updated'), el('i', 'is-down'), t('uninstalled'));
2106
+ chart.append(bars, axis);
2107
+ body.append(chart);
2108
+ body.append(el('p', 'sm-hint', t('{n} copies were heard for the first time in these 30 days, those from before 1.1.0 included.', { n: Number(totals.firstSeen ?? 0).toLocaleString() })));
2109
+ },
2110
+ environments(body, reading) {
2111
+ if (!reading.available) { body.append(el('p', 'sm-hint', reading.status ? t('madre.run answered {status}.', { status: reading.status }) : t('madre.run could not be reached.'))); return; }
2112
+ const env = reading.env ?? {};
2113
+ const copies = Number(env.copies ?? 0);
2114
+ body.append(el('p', 'sm-hint', copies ? t('{n} copies this month, each by what it said last. Copies from before 1.1.0 say less: «?» is what they did not say.', { n: copies.toLocaleString() }) : t('No copy has said its environment yet: it starts with 1.1.0.')));
2115
+ if (!copies) return;
2116
+ const share = (n) => `${Math.round((n / copies) * 100)}%`;
2117
+ const SYSTEMS = { darwin: 'macOS', linux: 'Linux', win32: 'Windows', wsl: 'WSL', other: t('other') };
2118
+ const CHANNELS = { npx: 'npx', global: t('installed (npm -g)'), project: t('inside a project'), source: t('from source') };
2119
+ const LANGS = { es: t('Spanish'), en: t('English') };
2120
+ const AGENT_NAMES = { claude: 'Claude', codex: 'Codex', gemini: 'Gemini', opencode: 'OpenCode', cursor: 'Cursor' };
2121
+ const said = (list, words = {}) => (list ?? []).filter((one) => one.name !== '?').slice(0, 5).map((one) => `${words[one.name] ?? one.name} ${share(one.n)}`).join(' · ') || '—';
2122
+ const lines = el('div', 'sm-usage-lines sm-env-lines');
2123
+ for (const [label, text] of [
2124
+ [t('Systems'), said(env.systems, SYSTEMS)],
2125
+ [t('Chip'), said(env.arch, { arm64: 'Apple / ARM', x64: 'x64' })],
2126
+ [t('Memory'), said(env.ram)],
2127
+ [t('Cores'), said(env.cores)],
2128
+ [t('Installed with'), said(env.channel, CHANNELS)],
2129
+ [t('Language'), said(env.language, LANGS)],
2130
+ [t('Shell'), said(env.shell)],
2131
+ [t('Node'), said(env.node, Object.fromEntries((env.node ?? []).map((one) => [one.name, `Node ${one.name}`])))],
2132
+ [t('Agents installed'), said(env.agents, AGENT_NAMES)],
2133
+ [t('Agents ready'), said(env.agentsReady, AGENT_NAMES)],
2134
+ [t('Local AI'), t('installed {a} · on {b}', { a: share(env.localAi?.installed ?? 0), b: share(env.localAi?.running ?? 0) })],
2135
+ [t('Modules on'), said(env.modules)],
2136
+ ]) {
2137
+ const row = el('div', 'sm-w-line');
2138
+ row.append(el('b', null, label), el('small', null, text));
2139
+ lines.append(row);
2140
+ }
2141
+ body.append(lines);
2142
+ // Projects per copy, the figure that sets the free limit of 1.1.1: a bar for each range.
2143
+ const ranges = ['0', '1', '2–5', '6–10', '11–20', '> 20'];
2144
+ const counts = new Map((env.projects ?? []).map((one) => [one.name, one.n]));
2145
+ const known = ranges.reduce((sum, name) => sum + (counts.get(name) ?? 0), 0);
2146
+ const box = el('div', 'sm-env-projects');
2147
+ box.append(el('b', null, t('Projects per copy')));
2148
+ for (const name of ranges) {
2149
+ const n = counts.get(name) ?? 0;
2150
+ const row = el('div', 'sm-env-range');
2151
+ row.append(el('span', null, name), meter(known ? n / known : 0), el('small', null, known ? `${n} · ${Math.round((n / known) * 100)}%` : '—'));
2152
+ box.append(row);
2153
+ }
2154
+ body.append(box);
2155
+ },
1767
2156
  usage(body, reading) {
1768
2157
  if (!reading.available) { body.append(el('p', 'sm-hint', reading.status ? t('madre.run answered {status}.', { status: reading.status }) : t('madre.run could not be reached.'))); return; }
2158
+ const n = (value) => Number(value ?? 0).toLocaleString();
2159
+ const pctOf = (part, whole) => (whole ? Math.round((part / whole) * 100) : 0);
2160
+ // The figure that matters first: people using it this week, and whether that grew.
2161
+ const week = Number(reading.active.week ?? 0);
2162
+ const before = Number(reading.active.lastWeek ?? 0);
2163
+ const change = before ? Math.round(((week - before) / before) * 100) : null;
2164
+ const lead = el('div', 'sm-usage-lead');
2165
+ const trend = change === null ? (week ? t('first week with data') : '') : change === 0 ? t('same as the week before') : change > 0 ? t('{n}% more than the week before', { n: change }) : t('{n}% fewer than the week before', { n: -change });
2166
+ lead.append(el('b', 'sm-w-big', n(week)), el('span', null, t('copies used this week')), el('small', `sm-usage-trend${change > 0 ? ' up' : change < 0 ? ' down' : ''}`, trend));
2167
+ body.append(lead);
1769
2168
  const grid = el('div', 'sm-w-grid sm-usage-figures');
1770
- for (const [label, n, line] of [[t('Today'), reading.active.day, t('copies on')], [t('7 days'), reading.active.week, t('active copies')], [t('30 days'), reading.active.month, t('active copies')], [t('Ever'), reading.active.ever, t('copies seen')]]) {
2169
+ for (const [label, value, line] of [
2170
+ [t('Today'), reading.active.day, t('on today')],
2171
+ [t('30 days'), reading.active.month, t('used this month')],
2172
+ [t('Stayed'), reading.stayed, t('came back another day')],
2173
+ [t('Tried it'), reading.tried, t('seen a single day')],
2174
+ ]) {
1771
2175
  const cell = el('div', 'sm-w-metric');
1772
- cell.append(el('span', 'sm-w-label', label), el('b', 'sm-w-big', Number(n).toLocaleString()), el('small', null, line));
2176
+ cell.append(el('span', 'sm-w-label', label), el('b', 'sm-w-big', n(value)), el('small', null, line));
1773
2177
  grid.append(cell);
1774
2178
  }
1775
2179
  body.append(grid);
1776
2180
  // The last 30 days: copies on each day, and the part of them seen for the first time.
1777
2181
  const top = Math.max(1, ...reading.days.map((one) => one.active));
2182
+ const chart = el('div', 'sm-usage-chart');
1778
2183
  const days = el('div', 'sm-usage-days');
1779
2184
  days.setAttribute('role', 'img');
1780
2185
  days.setAttribute('aria-label', t('Copies on each day, last 30 days'));
2186
+ const shortDay = (day) => new Date(`${day}T12:00:00Z`).toLocaleDateString(document.documentElement.lang === 'en' ? 'en-US' : 'es-MX', { day: 'numeric', month: 'short' });
1781
2187
  for (const one of reading.days) {
1782
2188
  const bar = el('i');
1783
2189
  bar.style.setProperty('--h', String(one.active / top));
1784
2190
  bar.style.setProperty('--new', String(one.active ? one.new / one.active : 0));
1785
- bar.title = t('{day}: {n} on · {fresh} new', { day: one.day, n: one.active, fresh: one.new });
2191
+ bar.title = t('{day}: {n} on · {fresh} new', { day: shortDay(one.day), n: one.active, fresh: one.new });
1786
2192
  days.append(bar);
1787
2193
  }
1788
- body.append(days);
1789
- const share = (list, word = (name) => name) => list.slice(0, 4).map((one) => `${typeof word(one.name) === 'function' ? word(one.name)() : word(one.name)} ${one.n}`).join(' · ') || '—';
1790
- const back = (part) => (part.cohort ? `${Math.round((part.back / part.cohort) * 100)}%` : '—');
2194
+ const axis = el('div', 'sm-usage-axis');
2195
+ axis.append(el('small', null, shortDay(reading.days[0]?.day ?? reading.today)), el('small', 'sm-usage-legend', ''), el('small', null, t('today')));
2196
+ axis.children[1].append(el('i', 'is-on'), t('on that day'), el('i', 'is-new'), t('new'));
2197
+ chart.append(days, axis);
2198
+ body.append(chart);
2199
+ // Each with its share; the newest version first if it is there, so «how many updated» reads at once.
2200
+ const shares = (list, word = (name) => name) => {
2201
+ const total = list.reduce((sum, one) => sum + one.n, 0);
2202
+ return list.slice(0, 4).map((one) => `${word(one.name)} ${pctOf(one.n, total)}%`).join(' · ') || '—';
2203
+ };
2204
+ const back = (part) => (part.cohort ? `${pctOf(part.back, part.cohort)}%` : '—');
1791
2205
  const lines = el('div', 'sm-usage-lines');
1792
2206
  for (const [label, said] of [
1793
- [t('Versions'), share(reading.versions)],
1794
- [t('Systems'), share(reading.os, (name) => OS_WORDS[name] ?? name)],
2207
+ [t('Versions'), shares(reading.versions)],
2208
+ [t('Systems'), shares(reading.os, (name) => { const word = OS_WORDS[name] ?? name; return typeof word === 'function' ? word() : word; })],
1795
2209
  [t('Came back'), t('after 1 day {d1} · 7 days {d7} · 30 days {d30}', { d1: back(reading.retention.d1), d7: back(reading.retention.d7), d30: back(reading.retention.d30) })],
1796
2210
  ]) {
1797
2211
  const row = el('div', 'sm-w-line');
@@ -1799,6 +2213,82 @@ const WIDGET_PAINT = {
1799
2213
  lines.append(row);
1800
2214
  }
1801
2215
  body.append(lines);
2216
+ // Yours do not count: this one never, and any other you name by its identifier.
2217
+ const foot = el('div', 'sm-usage-mine');
2218
+ foot.append(el('small', null, t('Your copies do not count: {n} left out, this one included.', { n: Math.max(1, Number(reading.excluded ?? 0)) })));
2219
+ const form = el('form', 'sm-usage-exclude');
2220
+ const field = el('input');
2221
+ field.type = 'text'; field.placeholder = t('Another copy of yours: its identifier'); field.spellcheck = false; field.autocomplete = 'off';
2222
+ field.setAttribute('aria-label', t('Another copy of yours: its identifier'));
2223
+ const go = button('sm-btn small', t('Leave it out'), null);
2224
+ go.type = 'submit';
2225
+ form.append(field, go);
2226
+ form.addEventListener('submit', async (event) => {
2227
+ event.preventDefault();
2228
+ const id = field.value.trim();
2229
+ if (!id) return;
2230
+ go.disabled = true;
2231
+ const answer = await post('/api/salas/usage/exclude', { id });
2232
+ go.disabled = false;
2233
+ if (!answer.ok) { toast(answer.body?.error ?? t('Home did not answer.'), 'error'); return; }
2234
+ field.value = '';
2235
+ // The tile reads itself again within 20 s; the server already forgot its old figures.
2236
+ toast(t('That copy no longer counts. The figures update in a moment.'), 'done');
2237
+ });
2238
+ foot.append(form);
2239
+ body.append(foot);
2240
+ },
2241
+ // What fails in every copy, the widest first (2026-10-28). Each with what it is (its MU code when
2242
+ // Diagnostics knows it), how many copies and times, which versions and systems, MADRE's own lines
2243
+ // it went through, and the author's word on it.
2244
+ errors(body, reading, { again } = {}) {
2245
+ if (!reading.available) { body.append(el('p', 'sm-hint', reading.status ? t('madre.run answered {status}.', { status: reading.status }) : t('madre.run could not be reached.'))); return; }
2246
+ const open = reading.errors.filter((one) => one.status !== 'ignored' && one.status !== 'fixed');
2247
+ const fresh = open.filter((one) => one.status === 'new').length;
2248
+ const lead = el('div', 'sm-usage-lead');
2249
+ lead.append(el('b', 'sm-w-big', String(open.length)), el('span', null, t('failures in the last 30 days')), el('small', `sm-usage-trend${fresh ? ' down' : ''}`, fresh ? t('{n} not looked at yet', { n: fresh }) : t('all looked at')));
2250
+ body.append(lead);
2251
+ // How much MADRE was used in the same days, so a failure reads against the work it interrupted.
2252
+ const turns = Object.entries(reading.usage?.totals ?? {}).filter(([key]) => /^turn\.[a-z]/.test(key) && !['turn.attachments', 'turn.ash'].includes(key));
2253
+ const modes = Object.entries(reading.usage?.totals ?? {}).filter(([key]) => /^mode\.\d$/.test(key));
2254
+ const all = (list) => list.reduce((sum, [, n]) => sum + n, 0);
2255
+ const lines = el('div', 'sm-usage-lines');
2256
+ for (const [label, said] of [
2257
+ [t('Copies'), t('{n} sent diagnostics', { n: reading.copies })],
2258
+ [t('Turns'), turns.length ? turns.sort((a, b) => b[1] - a[1]).slice(0, 5).map(([key, n]) => `@${key.slice(5)} ${Math.round((n / all(turns)) * 100)}%`).join(' · ') : '—'],
2259
+ [t('Modes'), modes.length ? modes.sort((a, b) => a[0].localeCompare(b[0])).map(([key, n]) => `#${key.slice(5)} ${Math.round((n / all(modes)) * 100)}%`).join(' · ') : '—'],
2260
+ ]) {
2261
+ const row = el('div', 'sm-w-line');
2262
+ row.append(el('b', null, label), el('small', null, said));
2263
+ lines.append(row);
2264
+ }
2265
+ body.append(lines);
2266
+ const list = el('div', 'sm-errors');
2267
+ for (const one of reading.errors.slice(0, 12)) {
2268
+ const row = el('details', `sm-fail is-${one.status}`);
2269
+ const head = el('summary');
2270
+ const what = one.code ? one.code : { agent: t('Agent'), crash: t('Crash'), route: t('Route'), page: t('Page'), install: t('Install'), model: t('Model'), startup: t('Start'), other: t('Other') }[one.kind] ?? one.kind;
2271
+ head.append(el('span', 'sm-fail-what', `${what}${one.agent ? ` · @${one.agent}` : ''}`), el('span', 'sm-fail-said', one.message), el('small', null, t('{copies} copies · {hits} times', { copies: one.copies, hits: one.hits })));
2272
+ row.append(head);
2273
+ const systems = one.systems.map((name) => { const word = OS_WORDS[name] ?? name; return typeof word === 'function' ? word() : word; }).join(', ');
2274
+ const facts = el('p', 'sm-hint', [one.versions.map((v) => `v${v}`).join(', '), `${systems}${one.wsl ? ' · WSL' : ''}`, t('last {when}', { when: new Date(one.last_seen).toLocaleString(document.documentElement.lang === 'en' ? 'en-US' : 'es-MX', { day: 'numeric', month: 'short', hour: 'numeric', minute: '2-digit' }) })].filter(Boolean).join(' · '));
2275
+ row.append(facts);
2276
+ if (one.frames.length) { const code = el('code', 'sm-error-frames', one.frames.join('\n')); row.append(code); }
2277
+ const keys = el('div', 'sm-error-keys');
2278
+ for (const [status, words] of [['known', t('Known')], ['fixed', t('Fixed')], ['ignored', t('Ignore')]]) {
2279
+ const key = button(`sm-btn small${one.status === status ? ' on' : ''}`, words, async () => {
2280
+ key.disabled = true;
2281
+ const answer = await post('/api/salas/errors/status', { fp: one.fp, status: one.status === status ? 'new' : status });
2282
+ if (!answer.ok) { key.disabled = false; toast(t('madre.run could not be reached.'), 'error'); return; }
2283
+ again?.();
2284
+ });
2285
+ keys.append(key);
2286
+ }
2287
+ row.append(keys);
2288
+ list.append(row);
2289
+ }
2290
+ if (!reading.errors.length) list.append(el('p', 'sm-hint', t('No failures in the last 30 days.')));
2291
+ body.append(list);
1802
2292
  },
1803
2293
  system(body, reading) {
1804
2294
  const cpu = el('div', 'sm-w-metric');
@@ -1845,7 +2335,7 @@ const WIDGET_PAINT = {
1845
2335
  top.append(el('b', 'sm-w-big', `${reading.pairs}`), el('span', null, t('of {n} exchanges to train on', { n: reading.target })));
1846
2336
  body.append(top, meter(share));
1847
2337
  body.append(el('p', 'sm-w-says', [reading.stage, reading.says].filter(Boolean).join(' · ')));
1848
- const facts = [t('{n} memories', { n: reading.notes ?? 0 }), reading.trained ? t('model {name}', { name: reading.trained }) : t('no model of its own yet')];
2338
+ const facts = [memoriesCount(reading.notes ?? 0), reading.trained ? t('model {name}', { name: reading.trained }) : t('no model of its own yet')];
1849
2339
  body.append(el('small', 'sm-w-foot', facts.join(' · ')));
1850
2340
  },
1851
2341
  models(body, reading) {
@@ -1884,13 +2374,15 @@ function makeWidget(id) {
1884
2374
  let timer = 0;
1885
2375
  const read = async () => {
1886
2376
  if (document.hidden || !node.isConnected) return;
1887
- const reading = await fetch(`/api/salas/widget?kind=${spec.kind}`, { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
2377
+ // A field being written in is never redrawn under the person (the agenda's new reminder).
2378
+ if (body.contains(document.activeElement) && document.activeElement.matches('input, textarea')) return;
2379
+ const reading = spec.read ? await spec.read() : await fetch(`/api/salas/widget?kind=${spec.kind}`, { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
1888
2380
  if (!node.isConnected) return;
1889
2381
  body.replaceChildren();
1890
2382
  // The author's widget is not there at all for a copy that cannot read it (no token, not from source).
1891
2383
  if (spec.owner) node.hidden = !reading;
1892
2384
  if (!reading) { body.append(el('p', 'sm-hint', t('It could not be read just now.'))); return; }
1893
- WIDGET_PAINT[spec.kind](body, reading);
2385
+ WIDGET_PAINT[spec.kind](body, reading, { again: () => void read() });
1894
2386
  fitTile(node);
1895
2387
  // The first time it shows, what it is (homeTour is set up below this, so it is read late).
1896
2388
  if (!node.dataset.guided) { node.dataset.guided = '1'; setTimeout(() => { try { guideWidget(node, spec.kind); } catch { /* the tour is not up yet */ } }, 1500); }
@@ -1908,7 +2400,8 @@ applyLayout();
1908
2400
  // THE WELCOME OF 1.0 (public/tour.js): the bonjour the first time, the chapters after it, the pill
1909
2401
  // that waits in the bar, `?` for the gestures, and the hint on Connections. In Home, «Take me
1910
2402
  // there» opens what lives here; for what lives inside a project it opens the one open most
1911
- // recently, if any is. A new person is handed to the wizard (agents, projects, open) first.
2403
+ // recently, if any is. A new person meets the welcome (public/welcome.js) in place of the bonjour,
2404
+ // and its last step leads to the chapters.
1912
2405
  const agentsReady = () => (agentsSeen?.agents ?? []).some((agent) => agent.id !== 'madre' && agentState(agent, agentsSeen).ok);
1913
2406
  const intoAProject = () => {
1914
2407
  const room = data ? projectsInOrder().open[0] : null;
@@ -1918,8 +2411,8 @@ const homeTour = startTour({
1918
2411
  page: 'home',
1919
2412
  pillSlot: $('sm-tour-pill'),
1920
2413
  hidden: () => (data?.phonePreview ? [] : ['phone']),
1921
- ready: () => Boolean(data) && !wizard && !sheet,
1922
- welcome: { needed: () => !projectsInOrder().all.length || !agentsReady(), open: (then) => { welcomed = true; openWizard({ then }); } },
2414
+ ready: () => Boolean(data) && !welcomeOpen() && !sheet,
2415
+ welcome: { instead: true, needed: () => !projectsInOrder().all.length || !agentsReady(), open: (then) => openHomeWelcome({ then }) },
1923
2416
  onProjects: () => void refresh(),
1924
2417
  go: {
1925
2418
  get project() { return intoAProject(); },
@@ -1964,6 +2457,11 @@ const WIDGET_GUIDE = {
1964
2457
  coordinator: () => t('How far the Coordinator\'s own record is from training a model of its own.'),
1965
2458
  models: () => t('Ollama and its models, and how many examples each project has toward a model of its own (8/300 is 8 of 300). «Choose projects» sets which ones use the local AI.'),
1966
2459
  usage: () => t('How many copies of MADRE are on, which versions and whether people come back. Only you see this.'),
2460
+ errors: () => t('What fails in every copy of MADRE, by how many copies it reaches. Mark each one known, fixed or ignored; a fixed one that happens again comes back as new.'),
2461
+ live: () => t('Copies on right now: a copy is on when it said so in the last ten minutes. Off are the ones used this month that are not on now. It reads again every minute.'),
2462
+ installs: () => t('Installs, updates and uninstalls by day. An uninstall counts only when made from Settings; whoever simply stops using MADRE shows as off.'),
2463
+ environments: () => t('Each copy once, by what it said last this month: its system, memory, agents, how many projects and which modules. Copies from before 1.1.0 say less.'),
2464
+ agenda: () => t('Your reminders from every project, by day. ✓ settles one, «Later» moves it, and the box below sets a new one as you would say it.'),
1967
2465
  };
1968
2466
  function guideWidget(node, kind) {
1969
2467
  const said = WIDGET_GUIDE[kind];
@@ -1977,21 +2475,86 @@ function welcomeHome() {
1977
2475
  if (welcomeAsked) return;
1978
2476
  welcomeAsked = true;
1979
2477
  void homeTour.loaded.then(async (answer) => {
1980
- if (answer?.owed) { await homeTour.maybeBonjour(); return; }
1981
- if (!answer?.state?.bonjourAt) return;
1982
- setTimeout(() => {
2478
+ welcomeSeen = answer?.state?.welcome ?? null;
2479
+ drawAttention();
2480
+ // Someone new meets the bonjour and the chapters on this same visit: Home's cards come after
2481
+ // them, once Home is quiet again, not only on the next visit as they did (2026-10-20).
2482
+ // Someone who met MADRE just now (src/tour.mjs, `met`) is walked through Home once the bonjour
2483
+ // and its chapters are behind them (2026-10-21): their project, the Coordinator, connections
2484
+ // and where the manual is, «Next» from one card to the other. A step whose place is not on this
2485
+ // Home is left out of the count.
2486
+ const HOME_WALK = [
2487
+ {
2488
+ id: 'home-start',
2489
+ // The list, not a card in it: the cards are drawn again every few seconds, and a hint whose
2490
+ // place is gone puts itself away.
2491
+ anchor: () => (ui.projects?.querySelector?.(':scope > :not([hidden])') ? ui.projects : ui.add),
2492
+ title: () => (ui.projects?.querySelector?.(':scope > :not([hidden])') ? t('Your project lives here') : t('Begin with a project')),
2493
+ text: () => (ui.projects?.querySelector?.(':scope > :not([hidden])') ? t('Open it to start. Each project keeps its own chats and its own memory.') : t('Press «Add project» and choose the folder you work in. Nothing inside it changes.')),
2494
+ },
2495
+ {
2496
+ id: 'home-coordinator',
2497
+ anchor: () => $('sm-bishop-go'),
2498
+ title: () => t('Your Coordinator'),
2499
+ text: () => t('An agent that sees all your projects. Ask it «which project was I on yesterday?», or to pass an instruction from one project to another.'),
2500
+ },
2501
+ {
2502
+ id: 'links',
2503
+ anchor: () => { const tile = $('sm-links-tile'); return tile && !tile.hidden ? tile.querySelector('.sm-tile-head') ?? tile : null; },
2504
+ title: () => t('Connections'),
2505
+ text: () => t('With a connection, one project can look up what another learned. You decide what and until when; nothing is written into the other.'),
2506
+ },
2507
+ {
2508
+ id: 'home-manual',
2509
+ anchor: () => ui.gear,
2510
+ title: () => t('The user manual'),
2511
+ text: () => t('Pictures of MADRE with every step marked, for when you want to look something up. It is in Settings › System › User manual, and as a PDF.'),
2512
+ },
2513
+ ];
2514
+ // It waits for the bonjour and its chapters, however long they take: maybeBonjour only opens
2515
+ // the bonjour, and the walk asked once, before it was given, never came (2026-10-21).
2516
+ let walkTries = 0;
2517
+ const walk = async () => {
2518
+ if (!homeTour.state()?.bonjourAt) { setTimeout(walk, 2000)?.unref?.(); return; }
2519
+ if (!homeTour.newcomer()) return;
2520
+ const seen = homeTour.state()?.hints ?? {};
2521
+ const here = HOME_WALK.filter((one) => one.anchor()?.getClientRects().length);
2522
+ const at = here.findIndex((one) => !seen[one.id]);
2523
+ if (at < 0) return;
2524
+ const one = here[at];
2525
+ const shown = !document.querySelector('dialog[open]') && await homeTour.hint(one.id, one.anchor(), {
2526
+ title: one.title(),
2527
+ text: one.text(),
2528
+ step: at + 1,
2529
+ of: here.length,
2530
+ skip: () => { for (const rest of here.slice(at + 1)) void homeTour.seen(rest.id); },
2531
+ then: () => setTimeout(walk, 350),
2532
+ });
2533
+ // Not yet (the chapters are open, a sheet is): asked again, for as long as a first visit lasts.
2534
+ if (!shown && (walkTries += 1) < 600) setTimeout(walk, 2000)?.unref?.();
2535
+ };
2536
+ setTimeout(walk, 1500)?.unref?.();
2537
+ if (answer?.owed) await homeTour.maybeBonjour();
2538
+ if (!homeTour.state()?.bonjourAt) return;
2539
+ let linkTries = 0;
2540
+ // For whoever came back: what «Connections» is now. Someone new has it in the walk above.
2541
+ const sayLinks = async () => {
1983
2542
  const tile = $('sm-links-tile');
1984
- if (!tile || tile.hidden || document.querySelector('dialog[open]')) return;
1985
- void homeTour.hint('links', tile.querySelector('.sm-tile-head') ?? tile, {
2543
+ if (!tile || tile.hidden || homeTour.newcomer() || homeTour.state()?.hints?.links) return;
2544
+ const shown = !document.querySelector('dialog[open]') && await homeTour.hint('links', tile.querySelector('.sm-tile-head') ?? tile, {
1986
2545
  title: t('Connections'),
1987
2546
  text: homeTour.path() === 'back'
1988
- ? t('A connection lets one project look up what another learned, by a contract you sign. In 0.7.2 «Connections» was signing your agents in: that is now in Settings › Agents.')
1989
- : t('A connection lets one project look up what another learned, by a contract you sign. Nothing is written across.'),
2547
+ ? t('With a connection, one project can look up what another learned. In 0.7.2 «Connections» was where you signed your agents in; that is now Settings › Agents.')
2548
+ : t('With a connection, one project can look up what another learned. You decide what and until when; nothing is written into the other.'),
1990
2549
  });
1991
- }, 2200);
2550
+ if (!shown && (linkTries += 1) < 40) setTimeout(sayLinks, 3000)?.unref?.();
2551
+ };
2552
+ setTimeout(sayLinks, 2200)?.unref?.();
1992
2553
  // 1.0.2 brings one key to Home's bar: said once, after any other card, never over a sheet.
1993
2554
  let tries = 0;
1994
2555
  const sayAdd = async () => {
2556
+ // News is for whoever had the version before; to someone new every key is new (2026-10-19).
2557
+ if (homeTour.path() === 'new') return;
1995
2558
  const key = document.getElementById('sm-add-widgets');
1996
2559
  if (!key || document.querySelector('dialog[open]') || !(await homeTour.hint('new-add-widgets', key, { title: t('New: add widgets'), text: t('This button opens «Add to Home»: choose the widgets you want to see here, or bring back the ones you removed.') }))) {
1997
2560
  if ((tries += 1) < 6) setTimeout(sayAdd, 6000)?.unref?.();
@@ -2028,9 +2591,9 @@ function sayBold(key, vars, bold = Object.keys(vars)) {
2028
2591
  out.append(template.slice(at));
2029
2592
  return out;
2030
2593
  }
2031
- const ALLOWED_GLYPH = '<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M5 10.4l3.2 3.1L15 6.6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
2032
- const NOT_ALLOWED_GLYPH = '<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M6.5 6.5l7 7M13.5 6.5l-7 7" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>';
2033
- const BOTH_WAYS_ICON = '<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M4 7.2h11.2L12.4 4.4M16 12.8H4.8l2.8 2.8" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';
2594
+ const ALLOWED_GLYPH = trazo('check');
2595
+ const NOT_ALLOWED_GLYPH = trazo('close');
2596
+ const BOTH_WAYS_ICON = trazo('swap');
2034
2597
  function openLinkSheet({ reader = null, source = null } = {}) {
2035
2598
  if (!data || sheet) return;
2036
2599
  const rooms = [...data.rooms].sort((x, y) => Number(Boolean(y.open)) - Number(Boolean(x.open)) || roomLabel(x).localeCompare(roomLabel(y)));
@@ -2100,8 +2663,14 @@ function openLinkSheet({ reader = null, source = null } = {}) {
2100
2663
  const seg = el('div', 'sx-seg');
2101
2664
  seg.setAttribute('role', 'radiogroup');
2102
2665
  seg.setAttribute('aria-label', label);
2666
+ // A choice slides the mark and says it over the scene; the step is not drawn again (2026-10-28:
2667
+ // drawing it again made the whole sheet blink at every press).
2103
2668
  for (const [value, words] of options) {
2104
- const one = button(null, words, () => { choose(value); render(); });
2669
+ const one = button(null, words, () => {
2670
+ choose(value);
2671
+ for (const other of seg.children) other.setAttribute('aria-checked', String(other === one));
2672
+ paintStage();
2673
+ });
2105
2674
  one.setAttribute('role', 'radio');
2106
2675
  one.setAttribute('aria-checked', String(value === current));
2107
2676
  seg.append(one);
@@ -2237,7 +2806,9 @@ function openLinkSheet({ reader = null, source = null } = {}) {
2237
2806
  stage.append(terms);
2238
2807
  }
2239
2808
 
2240
- function render({ back = false } = {}) {
2809
+ // `still`: the same step drawn again for a choice that adds or takes rows (orders), without the
2810
+ // step's entrance, so nothing blinks.
2811
+ function render({ back = false, still = false } = {}) {
2241
2812
  settle();
2242
2813
  const steps = stepsNow();
2243
2814
  at = Math.min(at, steps.length - 1);
@@ -2246,7 +2817,7 @@ function openLinkSheet({ reader = null, source = null } = {}) {
2246
2817
  const dots = el('ol', 'sm-steps');
2247
2818
  steps.forEach((name, index) => dots.append(el('li', index === at ? 'on' : index < at ? 'done' : null, STEP_WORDS[name]())));
2248
2819
  head.append(dots, closeKey(() => sheet.close()));
2249
- const page = el('div', `sm-step lw-step${back ? ' back' : ''}`);
2820
+ const page = el('div', `sm-step lw-step${back ? ' back' : ''}${still ? ' still' : ''}`);
2250
2821
  // The swap, on the first step: it turns the link round, and the scene shows it.
2251
2822
  const turn = button('sm-btn small', t('Swap'), () => { [pick.reader, pick.source] = [pick.source, pick.reader]; render(); });
2252
2823
  const intro = (title, lead) => {
@@ -2313,7 +2884,7 @@ function openLinkSheet({ reader = null, source = null } = {}) {
2313
2884
  const box = card();
2314
2885
  box.classList.add('lw-grid');
2315
2886
  for (const kindOf of LINK_KINDS) {
2316
- box.append(row(kindWord(kindOf), LINK_KIND_NOTES[kindOf](), toggle(pick.kinds.has(kindOf), (on) => { if (on) pick.kinds.add(kindOf); else pick.kinds.delete(kindOf); error.textContent = ''; render(); }, kindWord(kindOf)), { recommended: kindOf === 'decision' || kindOf === 'fact', dot: kindOf }));
2887
+ box.append(row(kindWord(kindOf), LINK_KIND_NOTES[kindOf](), toggle(pick.kinds.has(kindOf), (on) => { if (on) pick.kinds.add(kindOf); else pick.kinds.delete(kindOf); error.textContent = ''; paintStage(); }, kindWord(kindOf)), { recommended: kindOf === 'decision' || kindOf === 'fact', dot: kindOf }));
2317
2888
  }
2318
2889
  page.append(box, el('p', 'lw-foot', t('Only the notes already in use are shared, cleaned of private data first. Never your files, your whole conversations or the notes you set aside.')));
2319
2890
  actions.append(next(() => (pick.kinds.size ? null : t('Choose at least one kind.'))));
@@ -2323,19 +2894,19 @@ function openLinkSheet({ reader = null, source = null } = {}) {
2323
2894
  const ends = el('div', 'lw-control');
2324
2895
  ends.append(rail(LINK_DAYS.map(([value, words]) => [value, words()]), pick.days, (value) => { pick.days = value; }, t('It ends')));
2325
2896
  box.append(row(t('It ends'), t('A week is enough to try it; signing it again takes a moment.'), ends, { recommended: pick.days === 7 }));
2326
- box.append(row(t('Always include'), t('With every question it gets up to 3 related notes without looking for them; each time counts toward the hourly limit. Off, its agents look them up only when they need to.'), toggle(pick.recall, (on) => { pick.recall = on; render(); }, t('Always include'))));
2897
+ box.append(row(t('Always include'), t('With every question it gets up to 3 related notes without looking for them; each time counts toward the hourly limit. Off, its agents look them up only when they need to.'), toggle(pick.recall, (on) => { pick.recall = on; paintStage(); }, t('Always include'))));
2327
2898
  // D-S15: only with the Coordinator reading, and only by you.
2328
- if (coordinator(pick.reader)) box.append(row(t('The Coordinator learns from it'), t("Its notes also go into the training of the Coordinator's local AI, so it knows this project without opening it. Clearing it or revoking takes it out of the next export; a model already trained keeps what it learned until you train it again."), toggle(pick.train, (on) => { pick.train = on; render(); }, t('The Coordinator learns from it'))));
2899
+ if (coordinator(pick.reader)) box.append(row(t('The Coordinator learns from it'), t("Its notes also go into the training of the Coordinator's local AI, so it knows this project without opening it. Clearing it or revoking takes it out of the next export; a model already trained keeps what it learned until you train it again."), toggle(pick.train, (on) => { pick.train = on; paintStage(); }, t('The Coordinator learns from it'))));
2329
2900
  // D-S16 and D-S17: by you only, off unless you turn them on.
2330
- box.append(row(t('It shares its state'), t('Besides its notes, its canonical state as Continuity keeps it: objective, phase, next step, its last handoff, decisions and what is still open. Only if the project has Continuity installed; never its files or its code.'), toggle(pick.state, (on) => { pick.state = on; render(); }, t('It shares its state'))));
2331
- box.append(row(t('It receives delivered notes'), t('The project that reads can hand it notes. They wait there until you accept them (or an agent of that project in #3 EDIT or above): nothing enters its memory on its own.'), toggle(pick.deliver, (on) => { pick.deliver = on; render(); }, t('It receives delivered notes'))));
2901
+ box.append(row(t('It shares its state'), t('Besides its notes, its canonical state as Continuity keeps it: objective, phase, next step, its last handoff, decisions and what is still open. Only if the project has Continuity installed; never its files or its code.'), toggle(pick.state, (on) => { pick.state = on; paintStage(); }, t('It shares its state'))));
2902
+ box.append(row(t('It receives delivered notes'), t('The project that reads can hand it notes. They wait there until you accept them (or an agent of that project in #3 EDIT or above): nothing enters its memory on its own.'), toggle(pick.deliver, (on) => { pick.deliver = on; paintStage(); }, t('It receives delivered notes'))));
2332
2903
  page.append(box);
2333
2904
  actions.append(next());
2334
2905
  } else if (kind === 'orders') {
2335
2906
  const name = nameOf(ordersInto());
2336
2907
  intro(t('Orders from the Coordinator'), sayBold('With orders, the Coordinator can ask {room} for a task, and its agents do it there. Without them, it only reads. #3 EDIT and #4 FULL ACCESS never go this way: they arrive as a proposal you unlock in that project.', { room: name }));
2337
2908
  const box = card();
2338
- box.append(row(sayBold('Allow orders into {room}', { room: name }), sayBold('Leave it off unless you need the Coordinator to act in {room}.', { room: name }), toggle(pick.orders, (on) => { pick.orders = on; render(); }, t('Allow orders into {room}', { room: name })), { recommended: !pick.orders }));
2909
+ box.append(row(sayBold('Allow orders into {room}', { room: name }), sayBold('Leave it off unless you need the Coordinator to act in {room}.', { room: name }), toggle(pick.orders, (on) => { pick.orders = on; render({ still: true }); }, t('Allow orders into {room}', { room: name })), { recommended: !pick.orders }));
2339
2910
  if (pick.orders) {
2340
2911
  const modes = el('div', 'lw-control');
2341
2912
  modes.append(rail([1, 2].map((n) => [n, `#${n} ${modeName(n)}`]), pick.maxMode, (value) => { pick.maxMode = value; }, t('Up to which mode')));
@@ -2408,11 +2979,23 @@ function openLinkSheet({ reader = null, source = null } = {}) {
2408
2979
  ui.link.addEventListener('click', () => openLinkSheet());
2409
2980
 
2410
2981
  let refreshPending = null;
2411
- async function refresh() {
2982
+ // What the cards show now, without the clocks (`at`), and when they were drawn: the 4-second clock
2983
+ // redraws only when a project changed, or once a minute for the «… min. ago». A board rebuilt every
2984
+ // 4 s replaced the button under the pointer and the click went nowhere (2026-10-19).
2985
+ let drawnRooms = '';
2986
+ let drawnRoomsAt = 0;
2987
+ // MADRE's pulse says how Home stands with its server (2026-10-28): the dot at its end green while it
2988
+ // answers, red when it does not, amber while an answer is slow to come (styles.css, data-link).
2989
+ const setLink = (state) => { root.dataset.link = state; };
2990
+ setLink('waiting');
2991
+ async function refresh({ polled = false } = {}) {
2412
2992
  if (refreshPending) return refreshPending;
2413
2993
  refreshPending = fetch('/api/salas', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
2994
+ const slow = setTimeout(() => setLink('waiting'), 2500);
2414
2995
  const answer = await refreshPending;
2996
+ clearTimeout(slow);
2415
2997
  refreshPending = null;
2998
+ setLink(answer ? 'live' : 'lost');
2416
2999
  if (!answer) { ui.foot.textContent = t('This project did not answer. It may have closed.'); ui.bar.live.classList.add('is-off'); ui.bar.live.lastChild.textContent = t('Not answering right now'); return; }
2417
3000
  // Home is the first screen of `npx madre`: a MADRE nobody has set takes this browser's language
2418
3001
  // here, once, and every project follows (public/i18n.js, browserLanguage).
@@ -2423,14 +3006,103 @@ async function refresh() {
2423
3006
  const mine = chosenHere === 'es' || chosenHere === 'en' ? chosenHere : browserLanguage();
2424
3007
  if (await post('/api/language', { language: mine }).then((response) => response?.ok !== false).catch(() => false)) answer.language = mine;
2425
3008
  }
2426
- if (answer.language && answer.language !== language) { language = setLanguage(answer.language); root.lang = language; translateStatic(); drawAttention(); drawDecisions(); drawWork(); for (const widget of document.querySelectorAll('.sm-widget')) widget.say?.(); homeTour.repaint(); }
3009
+ if (answer.language && answer.language !== language) sayIn(answer.language);
2427
3010
  data = answer;
2428
3011
  // A project that came up after Home stopped waiting is open: its card no longer says it did not.
2429
3012
  for (const room of answer.rooms ?? []) if (room.open) failed.delete(room.id);
2430
3013
  ui.foot.textContent = t('Every project runs on this Mac, on its own, with its own memory.');
2431
- // The room's corner (app.js, #colophon): the version this Home runs, and NOTICE's own line.
3014
+ const said = JSON.stringify(answer, (key, value) => (key === 'at' ? undefined : value));
3015
+ if (polled && said === drawnRooms && Date.now() - drawnRoomsAt < 60000) return;
3016
+ drawnRooms = said;
3017
+ drawnRoomsAt = Date.now();
3018
+ // The room's corner (app.js, #colophon): the version this Home runs, and NOTICE's own line —
3019
+ // drawn when the answer changed, not on every poll.
2432
3020
  if (answer.version) { drawAttribution(ui.colophon, answer.version); void drawColophonKeys(ui.colophon); }
2433
3021
  draw();
3022
+ if (!newsAsked) { newsAsked = true; setTimeout(() => void homeNews(), 1200); }
3023
+ }
3024
+
3025
+ // WHAT IS NEW, ON HOME (1.1, 2026-10-28): whoever comes from an older MADRE lands here first now, so
3026
+ // Home says what changed — the same notes and the same board as a project (src/whats-new.mjs, app.js
3027
+ // showWhatsNew), shorter: a card each, and «Start». Once per version, per person (the server
3028
+ // remembers it); never over the welcome, a sheet or a window, nor on a first install.
3029
+ let newsAsked = false;
3030
+ async function homeNews(tries = 0) {
3031
+ const news = await fetch('/api/whats-new', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
3032
+ if (!news?.show || !news.notes) return;
3033
+ // The welcome or another window first: the board waits for them to close (a few minutes at most).
3034
+ if (welcomeOpen() || document.querySelector('dialog[open]')) { if (tries < 120) setTimeout(() => void homeNews(tries + 1), 3000); return; }
3035
+ const pick = (value) => (value && typeof value === 'object' && !Array.isArray(value) ? value[language] ?? value.es ?? value.en : value);
3036
+ const notes = news.notes;
3037
+ const dialog = el('dialog', 'whats-new home-news');
3038
+ dialog.setAttribute('aria-label', t("What's new in MADRE {version}", { version: news.version }));
3039
+ const sheet = el('div', 'wn-sheet');
3040
+ const head = el('header', 'wn-head');
3041
+ const words = el('div', 'wn-headline');
3042
+ const logo = document.querySelector('.side-brand .brand-logo, #sm-back .brand-logo')?.cloneNode?.(true);
3043
+ if (logo) { logo.setAttribute('class', 'brand-logo wn-logo'); words.append(logo); }
3044
+ words.append(el('span', 'wn-eyebrow', t("What's new")), el('h2', null, t('You now have {version}', { version: String(news.version).replace(/\.0$/, '') })));
3045
+ if (notes.intro) words.append(el('p', 'wn-intro', pick(notes.intro)));
3046
+ head.append(words, closeKey(() => dialog.close()));
3047
+ const grid = el('div', 'wn-board');
3048
+ for (const item of notes.items ?? []) {
3049
+ const card = el('div', 'wn-card');
3050
+ const shot = el('span', 'wn-shot wn-card-shot');
3051
+ if (item.image) {
3052
+ const image = el('img');
3053
+ image.alt = pick(item.title) ?? '';
3054
+ image.loading = 'lazy';
3055
+ image.decoding = 'async';
3056
+ image.addEventListener('error', () => { shot.classList.add('missing'); image.remove(); });
3057
+ image.addEventListener('load', () => shot.classList.add('loaded'));
3058
+ image.src = pick(item.image);
3059
+ shot.append(image);
3060
+ } else shot.classList.add('missing');
3061
+ card.append(shot, el('b', 'wn-card-title', pick(item.title)), el('span', 'wn-card-line', pick(item.body)));
3062
+ grid.append(card);
3063
+ }
3064
+ const body = el('div', 'wn-body');
3065
+ body.append(grid);
3066
+ const foot = el('footer', 'wn-foot');
3067
+ const changes = news.changes?.[language] ?? news.changes?.es;
3068
+ if (changes) {
3069
+ const link = el('a', 'wn-changes', t('See every change ↗'));
3070
+ link.href = changes; link.target = '_blank'; link.rel = 'noopener noreferrer';
3071
+ foot.append(link);
3072
+ }
3073
+ const start = button('wn-start', t('Start'), () => dialog.close());
3074
+ foot.append(start);
3075
+ sheet.append(head, body, foot);
3076
+ dialog.append(sheet);
3077
+ dialog.addEventListener('close', () => dialog.remove());
3078
+ document.body.append(dialog);
3079
+ dialog.showModal();
3080
+ // Whoever comes from an older MADRE meets MADRE's opening first (2026-10-30), as a new person does in
3081
+ // the welcome (loader.js, playOpening), and the board comes after it — unless this page just played it
3082
+ // (public/terms.js, after the new license was accepted).
3083
+ if (openingPlayed()) start.focus({ preventScroll: true });
3084
+ else void playOpening(dialog, { skipLabel: t('Skip') }).then(() => start.focus({ preventScroll: true }));
3085
+ // Seen once shown, as in a project: a board left open and the page closed is not owed again.
3086
+ void fetch('/api/whats-new/seen', { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' }).catch(() => null);
3087
+ }
3088
+
3089
+ // Home in another language, without a reload: what it says now, and every widget and the tour's pill.
3090
+ function sayIn(code) {
3091
+ language = setLanguage(code);
3092
+ root.lang = language;
3093
+ translateStatic();
3094
+ drawAttention();
3095
+ drawDecisions();
3096
+ drawWork();
3097
+ for (const widget of document.querySelectorAll('.sm-widget')) widget.say?.();
3098
+ homeTour.repaint();
3099
+ }
3100
+ // Chosen in the welcome's first step: kept for every project (as Settings › Language keeps it), and
3101
+ // said at once.
3102
+ async function adoptLanguage(code) {
3103
+ try { localStorage.setItem('pulse.language', code); } catch { /* no storage */ }
3104
+ await post('/api/language', { language: code });
3105
+ sayIn(code);
2434
3106
  }
2435
3107
 
2436
3108
  async function startRoom(room, { enter = false } = {}) {
@@ -2499,6 +3171,13 @@ async function closeRoom(room) {
2499
3171
  const answer = await fetch('/api/salas/close', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ room: room.id }) })
2500
3172
  .then(async (response) => ({ ok: response.ok, body: await response.json().catch(() => ({})) })).catch(() => ({ ok: false, body: {} }));
2501
3173
  if (answer.body.here) {
3174
+ // Home as a project serves it (2026-10-28): closing that project took this page with it and it
3175
+ // read as all of MADRE off. When Home itself is open on its own address, the page goes there.
3176
+ const home = data?.rooms.find((one) => one.id === data.salas && one.open?.port);
3177
+ if (home && home.id !== room.id && String(home.open.port) !== location.port) {
3178
+ setTimeout(() => { location.href = `${location.protocol}//${location.hostname}:${home.open.port}/salas`; }, 900);
3179
+ return;
3180
+ }
2502
3181
  // This page goes with the room that serves it: it says so, and stops asking.
2503
3182
  clearInterval(timer);
2504
3183
  document.body.classList.add('sm-gone');
@@ -2525,17 +3204,18 @@ function macroWords() {
2525
3204
  return {
2526
3205
  title: t('Project map'),
2527
3206
  back: t('Back to Home'),
2528
- hint: t('Drag the space to move it · wheel to come closer · click a project to look at it · drag it to turn it · carry one onto the Coordinator for the Coordinator to read it, or onto another to connect them · ← → from one to the next · Esc to come back'),
3207
+ // How to move round it, as keys of this computer; on a phone, where there are none, its line.
3208
+ hint: homeShellOn() ? mapKeys('projects') : t('Drag the space to move it · wheel to come closer · click a project to look at it · drag it to turn it · carry one onto the Coordinator for the Coordinator to read it, or onto another to connect them · ← → from one to the next · Esc to come back'),
2529
3209
  bishop: t('Coordinator'),
2530
3210
  bishopAbout: t('Your Coordinator. It reads across your projects, signs the connections between them and carries an order from one to another.'),
2531
3211
  bishopReads: (n) => (n ? (n === 1 ? t('It reads 1 project by a connection') : t('It reads {n} projects by connections', { n })) : t('It reads no project yet: each one it reads is a connection you sign.')),
2532
3212
  notLinked: t('Not connected yet: touch one to connect it'),
2533
3213
  talk: t('Talk to the Coordinator'),
2534
3214
  asleep: t('Asleep'),
2535
- recenter: t('RECENTER'),
3215
+ recenter: asLabel(t('RECENTER')),
2536
3216
  // The legend under its name, in the Memory map's words.
2537
3217
  legend: t('Memory kinds'),
2538
- kinds: { ...Object.fromEntries(KINDS.map((kind) => [kind, kindWord(kind)])), dim: t('NOT USED') },
3218
+ kinds: { ...Object.fromEntries(KINDS.map((kind) => [kind, kindWord(kind)])), dim: asLabel(t('NOT USED')) },
2539
3219
  veins: (n) => t('{n} connections', { n }),
2540
3220
  links: t('Connections'),
2541
3221
  link: t('Connect…'),
@@ -2550,12 +3230,12 @@ function macroWords() {
2550
3230
  const open = rooms.filter((room) => room.open);
2551
3231
  const memories = open.reduce((sum, room) => sum + (room.glance?.census?.memories ?? 0), 0);
2552
3232
  const waiting = open.filter((room) => room.glance?.waitingCount).length;
2553
- return [data?.mac ?? null, t('{n} projects', { n: rooms.length }), waiting ? t('{n} waiting for you', { n: waiting }) : null, t('{n} memories', { n: memories })].filter(Boolean).join(' · ');
3233
+ return [data?.mac ?? null, t('{n} projects', { n: rooms.length }), waiting ? t('{n} waiting for you', { n: waiting }) : null, memoriesCount(memories)].filter(Boolean).join(' · ');
2554
3234
  },
2555
3235
  state: (room) => stateOf(room).words,
2556
3236
  path: homeWord,
2557
3237
  ask: askLine,
2558
- kind: (kind) => KIND_WORDS[kind] ?? kind,
3238
+ kind: (kind) => kindWord(kind),
2559
3239
  counts: (room) => (room.open ? [conversationsCount(room.glance?.chats ?? 0), memoriesCount(room.glance?.census?.memories ?? 0)].join(' · ') : room.lastOpened ? t('Asleep · last open {when}', { when: ago(room.lastOpened) }) : t('Asleep')),
2560
3240
  enter: t('Enter the project'),
2561
3241
  backToRoom: t('Back to the project'),
@@ -2620,10 +3300,48 @@ ui.macro.addEventListener('click', async () => {
2620
3300
  wake: async (room) => { await startRoom(room); },
2621
3301
  // Dragged from one universe onto another: the notes of the first would travel to the second.
2622
3302
  link: (source, reader) => openLinkSheet({ source: source?.id ?? null, reader: reader?.id ?? null }),
2623
- closed: () => { macro = null; document.body.classList.remove('sm-in-macro'); ui.macro.focus(); },
3303
+ // Planets or neurons, said once and after the map itself was (homeTour 'home-map').
3304
+ mayTellViews: () => { const seen = homeTour.state(); return Boolean(seen?.bonjourAt && seen.hints?.['home-map'] && !seen.hints['map-views'] && !document.querySelector('.tour-hint')); },
3305
+ toldViews: () => void homeTour.seen('map-views'),
3306
+ closed: () => { macroFrame?.drop(); macroFrame = null; macro = null; document.body.classList.remove('sm-in-macro'); ui.macro.focus(); },
2624
3307
  },
2625
3308
  });
3309
+ frameMacro();
2626
3310
  });
3311
+ // THE PROJECT MAP AS A WINDOW (2026-10-28), as a project's Memory map can be one (app.js,
3312
+ // showNostromoDialog): the whole screen, or a window over Home from a key in its head, carried and
3313
+ // sized as Home's windows are (homeWindow). How it was left is how it opens the next time.
3314
+ const MACRO_WINDOW_KEY = 'pulse.homeMapWindow';
3315
+ let macroFrame = null;
3316
+ const macroFloats = () => { try { return localStorage.getItem(`${MACRO_WINDOW_KEY}.on`) === '1'; } catch { return false; } };
3317
+ function frameMacro() {
3318
+ const layer = macro?.layer;
3319
+ if (!layer || !homeShellOn()) return;
3320
+ let key = layer.querySelector('.nostromo-float');
3321
+ if (!key) {
3322
+ key = button('mother-close nostromo-float', null, () => {
3323
+ const on = !macroFrame;
3324
+ try { localStorage.setItem(`${MACRO_WINDOW_KEY}.on`, on ? '1' : '0'); } catch { /* as long as the page lasts */ }
3325
+ frameMacro();
3326
+ });
3327
+ key.innerHTML = trazo('window'); // trusted: our own SVG
3328
+ const track = layer.querySelector('.nostromo-actions > .surface-modes');
3329
+ if (track) track.before(key); else layer.querySelector('.nostromo-actions')?.append(key);
3330
+ }
3331
+ const floating = macroFloats();
3332
+ if (floating && !macroFrame) {
3333
+ macroFrame = homeWindow({ root: layer, bar: layer.querySelector('.mv-head'), close: () => macro?.close(), key: MACRO_WINDOW_KEY, minW: 480, minH: 360, keys: false, size: { w: 980, h: 680 } });
3334
+ document.body.classList.remove('sm-in-macro');
3335
+ } else if (!floating && macroFrame) {
3336
+ macroFrame.release();
3337
+ macroFrame = null;
3338
+ document.body.classList.add('sm-in-macro');
3339
+ }
3340
+ const said = macroFrame ? t('Fill the screen') : t('Open as a window');
3341
+ key.setAttribute('aria-pressed', String(Boolean(macroFrame)));
3342
+ key.title = said;
3343
+ key.setAttribute('aria-label', said);
3344
+ }
2627
3345
  window.addEventListener('resize', () => { if (data) ui.macro.hidden = !data.rooms.length || window.innerWidth < 900; });
2628
3346
 
2629
3347
  ui.stop.addEventListener('click', async () => {
@@ -2678,10 +3396,8 @@ function drawTopbar() {
2678
3396
  // A newer MADRE.
2679
3397
  b.update.hidden = !(versionSeen?.available && versionSeen.latest);
2680
3398
  if (!b.update.hidden) { b.update.lastChild.textContent = t('{version} AVAILABLE', { version: versionSeen.latest }); b.update.title = t('MADRE {version} is out.', { version: versionSeen.latest }); }
2681
- // The links in force.
2682
- const links = (data.enlaces ?? []).length;
2683
- b.linksCount.hidden = !links;
2684
- b.linksCount.textContent = String(links);
3399
+ // A key, not a counter (1.0.5): how many are in force is said on the Connections tile and in its window.
3400
+ b.linksCount.hidden = true;
2685
3401
  }
2686
3402
  // ---- THE BAR'S ROOMS, the way you want them (2026-10-10), as the room's bar is arranged (app.js,
2687
3403
  // «The bar, the way you want it»). Until the person arranges it, the bar holds the projects that
@@ -2692,12 +3408,12 @@ function drawTopbar() {
2692
3408
  // browser's own (localStorage), as the room keeps its bar.
2693
3409
  const PIN_KEY = 'pulse.lobbyBar';
2694
3410
  const PIN_TYPE = 'application/x-madre-room';
2695
- const PIN_MINUS = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4.5 8h7" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>';
2696
- const PIN_ICON = '<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M7.4 3.4h5.2l-.9 4.4 2.6 2.6v1.2H5.7v-1.2l2.6-2.6zM10 11.6v5" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';
2697
- const UNPIN_ICON = '<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M7.4 3.4h5.2l-.9 4.4 2.6 2.6v1.2H5.7v-1.2l2.6-2.6zM10 11.6v5M3.6 3.6l12.8 12.8" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';
2698
- const ARRANGE_ICON = '<svg viewBox="0 0 20 20" aria-hidden="true"><rect x="2.6" y="5.4" width="14.8" height="9.2" rx="3" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M6.2 10h2.2M11.6 10h2.2" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>';
2699
- const FORGET_ICON = '<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M3.5 6.2c0-.9.7-1.6 1.6-1.6h3l1.6 1.8h5.2c.9 0 1.6.7 1.6 1.6v6.4c0 .9-.7 1.6-1.6 1.6H5.1c-.9 0-1.6-.7-1.6-1.6z" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M7.6 11h4.8" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/></svg>';
2700
- const MORE_ICON = '<svg viewBox="0 0 20 20" aria-hidden="true"><circle cx="5" cy="10" r="1.6" fill="currentColor"/><circle cx="10" cy="10" r="1.6" fill="currentColor"/><circle cx="15" cy="10" r="1.6" fill="currentColor"/></svg>';
3411
+ const PIN_MINUS = trazo('minus');
3412
+ const PIN_ICON = trazo('pin');
3413
+ const UNPIN_ICON = trazo('unpin');
3414
+ const ARRANGE_ICON = trazo('arrange');
3415
+ const FORGET_ICON = trazo('forget');
3416
+ const MORE_ICON = trazo('more');
2701
3417
  const pins = {
2702
3418
  saved: null, // what this page decided, for when storage will not keep it
2703
3419
  chips: new Map(), // room id → its key on the bar
@@ -2802,15 +3518,19 @@ function pinsPlace(ids) {
2802
3518
  }
2803
3519
  function drawPins() {
2804
3520
  const box = ui.bar.open;
3521
+ // In the chat shell the projects at hand are the sidebar's (drawSideProjects), not the bar's.
3522
+ if (homeShellOn()) { box.hidden = true; pinsFit(); drawSideProjects(); return; }
2805
3523
  const ids = pinsShown();
2806
3524
  for (const id of ids) {
2807
3525
  const room = data.rooms.find((one) => one.id === id);
2808
3526
  const state = stateOf(room);
2809
3527
  const chip = pinChip(id);
2810
3528
  const lifted = pins.drag?.moved && pins.drag.id === id;
2811
- chip.className = `sm-tb-room is-${busy.get(id) === 'starting' ? 'working' : state.key}${lifted ? ' bar-lifted' : ''}${pins.dropping === id ? ' is-moving' : ''}`;
3529
+ chip.className = `sm-tb-room is-${busy.get(id) === 'starting' ? 'waking' : state.key}${lifted ? ' bar-lifted' : ''}${pins.dropping === id ? ' is-moving' : ''}`;
2812
3530
  chip.querySelector('span').textContent = room.name;
2813
3531
  chip.lastChild.textContent = monogram(room.name);
3532
+ // Its accent (src/looks.mjs): the key lit in its colour while the project is open.
3533
+ if ((chip.dataset.accent ?? '') !== (room.accent ?? '')) { if (room.accent) chip.dataset.accent = room.accent; else delete chip.dataset.accent; }
2814
3534
  chip.title = `${room.name} · ${busy.get(id) === 'starting' ? t('Waking…') : state.words}`;
2815
3535
  chip.setAttribute('aria-label', room.name);
2816
3536
  if (room.open) { chip.href = addressOf(room); chip.removeAttribute('role'); chip.removeAttribute('tabindex'); }
@@ -3050,8 +3770,11 @@ function pinsMenu(event, room, at = null) {
3050
3770
  menu.append(one);
3051
3771
  };
3052
3772
  const on = pinsShown().includes(room.id);
3053
- item(on ? t('Remove from the bar') : t('Pin to the bar'), on ? UNPIN_ICON : PIN_ICON, () => (on ? pinRemove(room.id) : pinAdd(room.id)));
3054
- item(t('Arrange the bar'), ARRANGE_ICON, () => pinsEdit(true));
3773
+ // In the chat shell the projects at hand live in the sidebar, and it says so; its order is the
3774
+ // menu's and the drop's, so there is no bar to arrange.
3775
+ const side = homeShellOn();
3776
+ item(on ? (side ? t('Remove from the sidebar') : t('Remove from the bar')) : (side ? t('Keep in the sidebar') : t('Pin to the bar')), on ? UNPIN_ICON : PIN_ICON, () => (on ? pinRemove(room.id) : pinAdd(room.id)));
3777
+ if (!side) item(t('Arrange the bar'), ARRANGE_ICON, () => pinsEdit(true));
3055
3778
  menu.append(el('i', 'sm-menu-sep'));
3056
3779
  // Where it sits among the projects: moved by hand, the order becomes «Yours».
3057
3780
  const order = projectsInOrder().all.map((one) => one.id);
@@ -3133,6 +3856,8 @@ function pinsIndexAt(x) {
3133
3856
  if (pins.editing && !box.contains(event.target) && !pins.card?.contains(event.target)) pinsEdit(false);
3134
3857
  }, true);
3135
3858
  document.addEventListener('keydown', (event) => {
3859
+ // ⌘ , (Ctrl+, off a Mac) opens Settings, as in a project: Home said so and did nothing (2026-10-20).
3860
+ if (event.key === ',' && (event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey) { event.preventDefault(); if (settingsSheet) settingsSheet.close(); else openSettings(); return; }
3136
3861
  if (event.key !== 'Escape') return;
3137
3862
  if (pins.menu) { pinsCloseMenu(); return; }
3138
3863
  if (pins.moreCard && !pins.moreCard.hidden) { pinsCloseMore(); return; }
@@ -3358,10 +4083,10 @@ for (const [way, alwaysNew] of [[ui.bishop.go, false], [ui.bishop.tab, true]]) {
3358
4083
  // level at a time; a search narrows either. Several can be chosen; a folder already in Home says
3359
4084
  // so and is not offered again. The sheet never runs past the screen: the tiles take as many rows
3360
4085
  // as it holds, and ‹ › turn the page, so nothing scrolls inside it.
3361
- const SEARCH_GLYPH = '<svg viewBox="0 0 20 20" aria-hidden="true"><circle cx="9" cy="9" r="5.5" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M13.2 13.2 17 17" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>';
3362
- const PAGE_BACK = '<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M12.5 4.5 7 10l5.5 5.5" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"/></svg>';
3363
- const PAGE_ON = '<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M7.5 4.5 13 10l-5.5 5.5" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"/></svg>';
3364
- const FOLD_TICK = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 8.4 6.8 11 12 5.4" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
4086
+ const SEARCH_GLYPH = trazo('search');
4087
+ const PAGE_BACK = trazo('back');
4088
+ const PAGE_ON = trazo('next');
4089
+ const FOLD_TICK = trazo('check');
3365
4090
  const FOLD_ROWS = 5;
3366
4091
 
3367
4092
  // The tiles and their pages. How many rows is measured, not guessed: from five down to two, the
@@ -3448,7 +4173,7 @@ function foldTile({ name, path, note = null, project = true, known = false, chec
3448
4173
  tick.innerHTML = FOLD_TICK;
3449
4174
  glyph.append(tick);
3450
4175
  const words = el('span', 'sm-fold-words');
3451
- words.append(el('b', null, name), el('small', null, note ?? homeWord(path)));
4176
+ words.append(el('b', null, name), el('small', note ? 'note' : null, note ?? homeWord(path)));
3452
4177
  item.append(box, glyph, words);
3453
4178
  if (enter) {
3454
4179
  const into = button('sm-into', null, (event) => { event.preventDefault(); enter(); });
@@ -3506,7 +4231,7 @@ function projectPicker({ onAdded = null, onChange = null, withAdd = true } = {})
3506
4231
  makeKey.type = 'submit';
3507
4232
  const freshError = el('p', 'error');
3508
4233
  fresh.append(nameField, whereLine, makeKey, freshError);
3509
- const parentNow = () => (here?.path && here.path !== here.home ? here.path : here?.home ?? null);
4234
+ const parentNow = () => (here?.path && here.path !== here.home ? here.path : here?.defaultParent ?? here?.home ?? null);
3510
4235
  const sayWhere = () => {
3511
4236
  whereLine.replaceChildren(el('span', null, t('The folder is made in')), ' ', el('code', null, parentNow() ? homeWord(parentNow()) : '~'), ' ');
3512
4237
  const other = button('sm-new-other', t('Choose another place'), () => { touched = true; source = 'browse'; draw(); if (!here) void walk(); });
@@ -3634,7 +4359,7 @@ function closeKey(onClick) {
3634
4359
  const key = button('surface-mode close x-close x-only', null, onClick);
3635
4360
  key.setAttribute('aria-label', t('Close'));
3636
4361
  const icon = el('span', 'x-icon');
3637
- icon.innerHTML = '<svg viewBox="0 0 20 20" focusable="false" aria-hidden="true"><path d="M5.5 5.5l9 9M14.5 5.5l-9 9" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';
4362
+ icon.innerHTML = trazo('close');
3638
4363
  key.append(icon);
3639
4364
  track.append(key);
3640
4365
  return track;
@@ -3666,6 +4391,10 @@ const openHomeMarket = (tab = 'shop', focus = null) => openMarket({
3666
4391
  tab,
3667
4392
  focus,
3668
4393
  host: {
4394
+ // In the chat shell the Market is a window, as in a project (homeWindow); on a phone, the screen.
4395
+ // It opens as wide as the screen allows (2026-10-30: a box in the middle read cramped); the size
4396
+ // a person gives it is kept under a new name, so the old narrow one is not brought back.
4397
+ window: (parts) => homeWindow({ ...parts, key: 'pulse.homeMarketWindow.wide', size: { w: 1920, h: 1400 } }),
3669
4398
  localAi: () => openSettings('local'),
3670
4399
  toast: (words) => toast(words),
3671
4400
  changed: () => drawColophonKeys(ui.colophon),
@@ -3729,6 +4458,9 @@ const openCodeProviders = (() => {
3729
4458
  : provider.via === 'oauth' ? t('Connected with its account · {n} models', { n: provider.models.length })
3730
4459
  : t('Connected · {n} models', { n: provider.models.length });
3731
4460
  words.append(el('b', null, provider.label), el('small', 'sm-agent-note', status));
4461
+ // What went wrong with it the last time a turn used it (src/opencode-health.mjs).
4462
+ const trouble = provider.problem === 'no-credit' ? t('No credit left: its turns are refused') : provider.problem === 'bad-key' ? t('Its key is no longer valid') : null;
4463
+ if (trouble) words.append(el('small', 'oc-problem', trouble));
3732
4464
  const controls = el('span', 'sm-oc-controls');
3733
4465
  if (provider.via === 'api') {
3734
4466
  const remove = button('sm-btn ghost small', t('Remove the key'), async () => {
@@ -3794,14 +4526,45 @@ const openCodeProviders = (() => {
3794
4526
  };
3795
4527
  })();
3796
4528
 
3797
- function agentsPanel({ onPaint = null, compact = false } = {}) {
4529
+ // What went wrong with an install or a sign-in, in plain words (2026-10-28): the server names the
4530
+ // cause in one word (src/setup-trouble.mjs) and this says it and what to do. Home used to drop these
4531
+ // failures: the person pressed Install, nothing happened, and nothing said why.
4532
+ const TROUBLE_WORDS = {
4533
+ install: {
4534
+ network: () => t('It could not download: there is no internet connection, or something on this network blocked it. Check your connection and try again.'),
4535
+ permission: () => t('This computer did not let MADRE install it. Try again; if it fails again, install it from a terminal (below).'),
4536
+ disk: () => t('There is not enough free space on this computer to install it.'),
4537
+ 'npm-missing': () => t('Installing it needs Node and npm, and this computer does not have them. Install Node from nodejs.org, then try again.'),
4538
+ timeout: () => t('It took too long and was stopped. Try again.'),
4539
+ unknown: () => t('It did not install.'),
4540
+ },
4541
+ login: {
4542
+ 'refused-account': () => null,
4543
+ network: () => t('It could not connect: there is no internet connection, or something on this network blocked it.'),
4544
+ timeout: () => t('The connection was not finished in time. Start it again.'),
4545
+ cancelled: () => t('You cancelled the connection.'),
4546
+ unknown: () => t('The connection did not finish.'),
4547
+ },
4548
+ };
4549
+ // The card of Diagnostics for each of those (public/troubleshooting.js), opened beside the failure.
4550
+ const TROUBLE_CARDS = {
4551
+ install: { network: 'install-offline', timeout: 'install-offline', permission: 'install-needs-admin', disk: 'disk-full', 'npm-missing': 'node-missing' },
4552
+ login: { network: 'install-offline', timeout: 'sign-in-unfinished', cancelled: 'sign-in-unfinished', unknown: 'sign-in-unfinished' },
4553
+ };
4554
+ const troubleCard = (agent, kind, cause) => (kind === 'login' && cause === 'refused-account' ? (agent === 'gemini' ? 'gemini-ineligible-tier' : 'not-signed-in') : TROUBLE_CARDS[kind]?.[cause] ?? null);
4555
+ function agentsPanel({ onPaint = null, compact = false, explain = null } = {}) {
3798
4556
  const list = el('div', 'sm-agents');
3799
4557
  const lastLine = new Map(); // agent → what its install or sign-in said last
4558
+ // Installing right now, from a press here (QA 1.1.0, NUE-03): the key says so and waits, instead
4559
+ // of offering «Install» again while npm works; the installer's own last line goes when it ends.
4560
+ const installing = new Set();
4561
+ const trouble = new Map(); // agent → what went wrong last, said in plain words, until it works
3800
4562
  const openMore = new Set(); // agents whose connection detail is unfolded
3801
- const toggleMore = (id) => { if (openMore.has(id)) openMore.delete(id); else openMore.add(id); };
4563
+ const foldedMore = new Set(); // agents the person folded, even one that would open by itself
3802
4564
  let live = null; // the sign-in running right now, as the server tells it
3803
4565
  let poll = 0;
3804
4566
  let stream = null;
4567
+ let drawn = ''; // what the list shows now: the poll redraws only when it changed
3805
4568
 
3806
4569
  // The second half of a browser sign-in: the address stays put, and the code that page hands
3807
4570
  // back is typed here. Without it the sign-in could only wait until its clock killed it.
@@ -3893,7 +4656,9 @@ function agentsPanel({ onPaint = null, compact = false } = {}) {
3893
4656
  return form;
3894
4657
  };
3895
4658
 
3896
- const paint = async () => {
4659
+ // `polled`: asked by the clock, not by the person. The clock redraws only when what the server
4660
+ // says changed: a list rebuilt every 2.5 s ate the click that landed on the old one (2026-10-19).
4661
+ const paint = async ({ polled = false } = {}) => {
3897
4662
  const answer = await fetch('/api/settings', { cache: 'no-store' }).then((response) => response.json()).catch(() => null);
3898
4663
  if (!answer?.agents) return;
3899
4664
  agentsSeen = answer;
@@ -3904,15 +4669,25 @@ function agentsPanel({ onPaint = null, compact = false } = {}) {
3904
4669
  // A field being typed into is never yanked away by the poll: the panel redraws every few
3905
4670
  // seconds, and a half-pasted key or code would go with it.
3906
4671
  if (list.contains(document.activeElement) && ['INPUT', 'SELECT'].includes(document.activeElement.tagName)) { onPaint?.(ready, answer); return; }
4672
+ const said = JSON.stringify(answer);
4673
+ if (polled && said === drawn && list.childNodes.length) { onPaint?.(ready, answer); return; }
4674
+ drawn = said;
3907
4675
  list.replaceChildren();
3908
4676
  for (const agent of answer.agents.filter((one) => one.id !== 'madre')) {
3909
4677
  const state = agentState(agent, answer);
3910
4678
  // The project's AJUSTES design (2026-10-13): one card per agent, folded to a line that says
3911
4679
  // who it is and whether it has a session. One that needs the person opens by itself.
3912
- const unfolded = openMore.has(agent.id) || !state.ok || state.busyNow || (live && live.agent === agent.id);
4680
+ // One that needs the person opens by itself, and still closes when the person folds it (1.0.5).
4681
+ const unfolded = !foldedMore.has(agent.id) && (openMore.has(agent.id) || !state.ok || state.busyNow || (live && live.agent === agent.id));
3913
4682
  const item = el('section', `sm-agent${state.ok ? ' ok' : ''}${unfolded ? ' open' : ''}`);
3914
4683
  item.dataset.agent = agent.id;
3915
- const head = button('sm-agent-head', null, () => { toggleMore(agent.id); if (!openMore.has(agent.id) && !state.ok) openMore.add(agent.id); void paint(); });
4684
+ // What opens is brought into view: the window grows downwards and an agent low in the list
4685
+ // opened below the edge of the screen, as if the arrow had done nothing.
4686
+ const head = button('sm-agent-head', null, async () => {
4687
+ if (unfolded) { openMore.delete(agent.id); foldedMore.add(agent.id); } else { foldedMore.delete(agent.id); openMore.add(agent.id); }
4688
+ await paint();
4689
+ if (openMore.has(agent.id)) list.querySelector(`.sm-agent[data-agent="${agent.id}"]`)?.scrollIntoView?.({ block: 'nearest', behavior: 'smooth' });
4690
+ });
3916
4691
  head.setAttribute('aria-expanded', String(unfolded));
3917
4692
  const words = el('span', 'sm-agent-words');
3918
4693
  words.append(el('b', null, agent.label ?? agent.id), el('small', null, VENDOR_WORDS[agent.id] ?? ''));
@@ -3921,18 +4696,43 @@ function agentsPanel({ onPaint = null, compact = false } = {}) {
3921
4696
  head.append(mark(agent.id, 34), words, chip, el('span', 'sm-chevron'));
3922
4697
  item.append(head);
3923
4698
  const body = el('div', 'sm-agent-body');
4699
+ // The welcome says first what this agent needs (public/welcome.js): Gemini's key, Cursor's own
4700
+ // installer, a code when MADRE runs on another computer.
4701
+ const why = explain?.(agent, state, answer);
4702
+ if (why) body.append(why);
3924
4703
  // Which account it is signed in with, as its own CLI reports it, and which one it asks for.
3925
4704
  const facts = el('div', 'sm-agent-facts');
3926
4705
  if (agent.detected && agent.version) facts.append(el('code', 'sm-agent-line', `${agent.version}${agent.path ? ` · ${agent.path}` : ''}`));
3927
- if (agent.detected && answer.sessions?.[agent.id]?.detail) facts.append(el('small', 'sm-agent-line', answer.sessions[agent.id].detail));
3928
- if (agent.account) facts.append(el('small', 'sm-agent-note', agent.account));
3929
- if (lastLine.has(agent.id) && !state.ok) {
4706
+ const said = agent.detected ? sessionDetail(answer.sessions?.[agent.id]) : null;
4707
+ if (said) facts.append(el('small', 'sm-agent-line', said));
4708
+ // In the welcome, Gemini's account is already said above its card (welcome.js, explainAgent):
4709
+ // said twice in two ways, it read as two different requirements (QA 1.1.0, NUE-04).
4710
+ if (agent.account && !(compact && agent.id === 'gemini' && !state.ok)) facts.append(el('small', 'sm-agent-note', agent.account));
4711
+ // Installed, the installer's last line («added 2 packages in 4s») has nothing left to say.
4712
+ if (agent.detected && !installing.has(agent.id) && !state.busyNow && !answer.loggingIn) lastLine.delete(agent.id);
4713
+ if (lastLine.has(agent.id) && !state.ok && !trouble.has(agent.id)) {
3930
4714
  const said = lastLine.get(agent.id);
3931
4715
  const line = el('small', 'sm-agent-line', said.line);
3932
4716
  if (said.url) { const link = el('a', null, t('Open the sign-in page')); link.href = said.url; link.target = '_blank'; link.rel = 'noopener'; line.append(' ', link); }
3933
4717
  facts.append(line);
3934
4718
  }
3935
4719
  if (facts.childNodes.length) body.append(facts);
4720
+ // What went wrong, said where it happened, with what the program printed last for whoever
4721
+ // wants to look closer. It goes away once the agent works.
4722
+ if (state.ok) trouble.delete(agent.id);
4723
+ const wrong = trouble.get(agent.id);
4724
+ if (wrong && !state.busyNow) {
4725
+ const box = el('div', `sm-agent-trouble${wrong.tone === 'quiet' ? ' quiet' : ''}`);
4726
+ box.setAttribute('role', 'status');
4727
+ box.append(el('p', null, wrong.words));
4728
+ if (wrong.detail) {
4729
+ const more = el('details', 'sm-agent-trouble-more');
4730
+ more.append(el('summary', null, t('What it said')), el('code', null, wrong.detail));
4731
+ box.append(more);
4732
+ }
4733
+ if (wrong.card) box.append(remedyKey(wrong.card));
4734
+ body.append(box);
4735
+ }
3936
4736
  // One button per account the CLI can sign in with: Claude has two, and only the human can
3937
4737
  // say which one is paying.
3938
4738
  const doorKeys = () => {
@@ -3950,7 +4750,9 @@ function agentsPanel({ onPaint = null, compact = false } = {}) {
3950
4750
  if (door.choose) { choosingAccount.add(agent.id); void paint(); return; }
3951
4751
  choosingAccount.delete(agent.id);
3952
4752
  event.currentTarget.disabled = true;
3953
- await post(`/api/agents/${agent.id}/login`, { method: door.id });
4753
+ trouble.delete(agent.id);
4754
+ const answer = await post(`/api/agents/${agent.id}/login`, { method: door.id });
4755
+ if (!answer.ok) trouble.set(agent.id, { kind: 'login', words: answer.body?.error ?? t('The connection did not finish.') });
3954
4756
  void paint();
3955
4757
  });
3956
4758
  if (door.note) key.title = t(door.note);
@@ -3962,9 +4764,27 @@ function agentsPanel({ onPaint = null, compact = false } = {}) {
3962
4764
  if (keyFirst) body.append(keyForm(agent));
3963
4765
  const acts = el('div', 'sm-agent-acts');
3964
4766
  if (!state.busyNow) {
3965
- if (!agent.detected && agent.install) acts.append(button('sm-btn primary small', t('Install'), async (event) => { event.currentTarget.disabled = true; await post(`/api/agents/${agent.id}/install`); void paint(); }));
4767
+ if (!agent.detected && installing.has(agent.id)) {
4768
+ const wait = button('sm-btn primary small is-busy', t('Installing…'), () => {});
4769
+ wait.disabled = true;
4770
+ wait.setAttribute('aria-busy', 'true');
4771
+ acts.append(wait);
4772
+ } else if (!agent.detected && agent.install?.command) acts.append(button('sm-btn primary small', wrongAt(agent.id, 'install') ? t('Try again') : t('Install'), async (event) => {
4773
+ event.currentTarget.disabled = true;
4774
+ event.currentTarget.textContent = t('Installing…');
4775
+ trouble.delete(agent.id);
4776
+ installing.add(agent.id);
4777
+ const answer = await post(`/api/agents/${agent.id}/install`);
4778
+ if (!answer.ok) { installing.delete(agent.id); trouble.set(agent.id, { kind: 'install', words: answer.body?.error ?? t('It did not install.') }); }
4779
+ void paint();
4780
+ }));
3966
4781
  else if (agent.detected && agent.login?.headless) for (const key of doorKeys()) acts.append(key);
3967
4782
  }
4783
+ // Installed by hand in a terminal (its own installer): one press looks for it again. In the
4784
+ // welcome its line is unfolded, and the key says what the person just did.
4785
+ const byHand = !agent.detected && agent.install && !agent.install.command;
4786
+ if (byHand && compact) openWays.add(agent.id);
4787
+ if (byHand) acts.append(button('sm-btn small', compact ? t('I did it') : t('Check again'), async (event) => { event.currentTarget.disabled = true; await post('/api/agents/probe'); void paint(); }));
3968
4788
  if (acts.childNodes.length) body.append(acts);
3969
4789
  const ask = askBlock(agent);
3970
4790
  if (ask) body.append(ask);
@@ -3983,18 +4803,29 @@ function agentsPanel({ onPaint = null, compact = false } = {}) {
3983
4803
  };
3984
4804
  const liveOn = () => {
3985
4805
  if (!list.isConnected || poll) return;
3986
- poll = setInterval(() => { if (!document.hidden) void paint(); }, 2500);
4806
+ poll = setInterval(() => { if (!document.hidden) void paint({ polled: true }); }, 2500);
3987
4807
  try {
3988
4808
  stream = new EventSource('/api/events');
3989
4809
  stream.onmessage = (message) => {
3990
4810
  try {
3991
4811
  const event = JSON.parse(message.data);
3992
4812
  if (event.type === 'connection.login.output' || event.type === 'connection.install.output') lastLine.set(event.payload.agent, { line: event.payload.line, url: event.payload.url ?? null });
4813
+ // An install or a sign-in that ended without working says why, in plain words.
4814
+ if (event.type === 'connection.install.finished' || event.type === 'connection.login.finished') {
4815
+ const { agent, trouble: cause, error, tail } = event.payload ?? {};
4816
+ const kind = event.type === 'connection.install.finished' ? 'install' : 'login';
4817
+ if (kind === 'install') { installing.delete(agent); if (!cause) lastLine.delete(agent); }
4818
+ if (cause) {
4819
+ const words = TROUBLE_WORDS[kind][cause]?.() ?? error ?? TROUBLE_WORDS[kind].unknown();
4820
+ trouble.set(agent, { kind, words: cause === 'refused-account' ? error : words, tone: cause === 'cancelled' ? 'quiet' : null, detail: (tail ?? []).slice(-3).join('\n') || error || null, card: troubleCard(agent, kind, cause) });
4821
+ } else trouble.delete(agent);
4822
+ }
3993
4823
  if (/^connection\./.test(event.type)) void paint();
3994
4824
  } catch { /* not ours */ }
3995
4825
  };
3996
4826
  } catch { /* no stream: the poll keeps it current */ }
3997
4827
  };
4828
+ const wrongAt = (id, kind) => trouble.get(id)?.kind === kind;
3998
4829
  const stop = () => { clearInterval(poll); poll = 0; stream?.close(); stream = null; };
3999
4830
  return { node: list, paint, live: liveOn, stop };
4000
4831
  }
@@ -4055,107 +4886,31 @@ function wizardScene(kind) {
4055
4886
  }
4056
4887
  return scene;
4057
4888
  }
4058
- let wizard = null;
4059
- let wizardThen = null; // what comes once the wizard closes: the chapters, after a bonjour
4060
- function openWizard({ then = null } = {}) {
4061
- if (wizard) return;
4062
- wizardThen = then;
4063
- wizard = el('dialog', 'sm-sheet sm-wide sm-wizard');
4064
- const inner = el('div', 'sm-sheet-body');
4065
- wizard.append(inner);
4066
- document.body.append(wizard);
4067
- let step = 0;
4068
- let panel = null;
4069
- let scene = null;
4070
- const steps = [t('Agents'), t('Projects'), t('Open')];
4071
- const KINDS_OF_STEP = ['agents', 'projects', 'open'];
4072
- const stop = () => { panel?.stop(); panel = null; };
4073
- const frame = (title, note, body, actions, { back = false } = {}) => {
4074
- stop();
4075
- inner.replaceChildren();
4076
- const head = el('header', 'sm-sheet-head');
4077
- const dots = el('ol', 'sm-steps');
4078
- steps.forEach((name, index) => { const item = el('li', index === step ? 'on' : index < step ? 'done' : null, name); dots.append(item); });
4079
- head.append(dots, closeKey(() => wizard.close()));
4080
- scene = wizardScene(KINDS_OF_STEP[step]);
4081
- const page = el('div', `sm-step${back ? ' back' : ''}`);
4082
- page.append(el('h3', null, title));
4083
- if (note) page.append(el('p', 'hint', note));
4084
- page.append(body, actions);
4085
- inner.append(head, scene, page);
4086
- };
4087
- async function agentsStep(options) {
4088
- const actions = el('div', 'actions');
4089
- const next = button('sm-btn primary', t('Continue'), () => { step = 1; projectsStep(); });
4090
- actions.append(next);
4091
- const fresh = agentsPanel({
4092
- compact: true,
4093
- onPaint: (ready, answer) => {
4094
- next.textContent = ready ? t('Continue') : t('Continue without agents');
4095
- // The scene lights the agents that are connected, and their wire to MADRE.
4096
- for (const agent of answer.agents) {
4097
- const on = agentState(agent, answer).ok;
4098
- scene?.querySelector(`.sm-scene-node[data-agent="${agent.id}"]`)?.classList.toggle('on', on);
4099
- scene?.querySelector(`.sm-wire[data-agent="${agent.id}"]`)?.classList.toggle('on', on);
4100
- }
4101
- },
4102
- });
4103
- frame(t('Connect your agents'), t('Agents are the AI tools that write code, such as Claude Code or Codex. MADRE works with the ones already on this computer: each one is connected once, and every project uses it.'), fresh.node, actions, options);
4104
- panel = fresh;
4105
- await fresh.paint();
4106
- fresh.live();
4107
- }
4108
- function projectsStep(options) {
4109
- // What is chosen here is added on the way to the next step: one key, not two.
4110
- const actions = el('div', 'actions');
4111
- const next = button('sm-btn primary', t('Continue'), async () => {
4112
- if (picker.count()) {
4113
- next.disabled = true;
4114
- const added = await picker.add();
4115
- next.disabled = false;
4116
- if (!added) return;
4117
- }
4118
- step = 2;
4119
- openStep();
4120
- });
4121
- const picker = projectPicker({ withAdd: false, onChange: (n) => { next.textContent = n ? t('Add and continue') : t('Continue'); } });
4122
- actions.append(button('sm-btn', t('Back'), () => { step = 0; void agentsStep({ back: true }); }), next);
4123
- frame(t('Add your projects'), t('A project is a folder you work in. Choose yours: adding them does not open them; in the next step you pick which to open.'), picker.node, actions, options);
4124
- }
4125
- function openStep() {
4126
- const projects = (data?.rooms ?? []).filter((room) => room.id !== data?.salas);
4127
- const chosen = new Set();
4128
- const pages = foldPages({ snug: true });
4129
- const list = el('div', 'sm-picker');
4130
- const foot = el('div', 'sm-picker-foot');
4131
- foot.append(pages.pager);
4132
- list.append(pages.grid, foot);
4133
- pages.show(projects, {
4134
- draw: (room) => foldTile({
4135
- name: room.name,
4136
- path: room.root ?? '',
4137
- note: room.open ? t('Already open') : null,
4138
- checked: Boolean(room.open) || chosen.has(room.id),
4139
- known: Boolean(room.open),
4140
- onToggle: (on) => { if (on) chosen.add(room.id); else chosen.delete(room.id); },
4141
- }),
4142
- empty: () => t('No projects yet. You can add them from Home whenever you like.'),
4143
- });
4144
- const actions = el('div', 'actions');
4145
- const go = button('sm-btn primary', t('Done'), async () => {
4146
- go.disabled = true;
4147
- for (const id of chosen) {
4148
- go.textContent = t('Opening {name}…', { name: projects.find((room) => room.id === id)?.name ?? id });
4149
- await startRoom({ id });
4150
- }
4151
- wizard.close();
4152
- });
4153
- actions.append(button('sm-btn', t('Back'), () => { step = 1; projectsStep({ back: true }); }), go);
4154
- frame(t('Open what you will use'), t('Each open project runs on this Mac on its own. The rest stay in Home, asleep, until you open them.'), list, actions);
4155
- }
4156
- wizard.addEventListener('close', () => { stop(); wizard.remove(); wizard = null; void loadAgents(); const after = wizardThen; wizardThen = null; after?.(); });
4157
- wizard.showModal();
4158
- void agentsStep();
4889
+ // THE WELCOME (2026-10-28, public/welcome.js): seven steps that leave MADRE ready — agents, an AI on
4890
+ // this computer, the memory's search and the first project —, adapted to where MADRE runs. It took
4891
+ // the place of the three steps of 1.0 (agents, projects, open). Home hands it its own panel of
4892
+ // agents and its picker of folders, so the welcome and Home never say a thing two ways.
4893
+ const welcomeHost = {
4894
+ agentsPanel: (options) => agentsPanel(options),
4895
+ projectPicker: (options) => projectPicker(options),
4896
+ mark: (id, size) => mark(id, size),
4897
+ closeKey: (onClick) => closeKey(onClick),
4898
+ agentState: (agent, answer) => agentState(agent, answer),
4899
+ projects: () => (data ? projectsInOrder().all : []),
4900
+ openProject: (room) => startRoom(room, { enter: true }),
4901
+ setLanguage: (code) => adoptLanguage(code),
4902
+ openLinks: () => openLinkSheet(),
4903
+ openMarket: () => void openHomeMarket('shop'),
4904
+ chapters: () => homeTour.openChapters('home'),
4905
+ saved: (welcome) => { welcomeSeen = welcome; drawAttention(); },
4906
+ closed: () => { void loadAgents(); void refresh(); },
4907
+ };
4908
+ function openHomeWelcome({ at = null, then = null } = {}) {
4909
+ welcomed = true;
4910
+ const opened = openWelcome({ at, then, host: welcomeHost });
4911
+ // The welcome covers Home now (its opening, or its window over the stage): the boot's ground goes.
4912
+ bootDone();
4913
+ return opened;
4159
4914
  }
4160
4915
 
4161
4916
  // ---- AJUSTES, as the room's (app.js, SETTINGS_SECTIONS and its sheets; 2026-10-10): a board of
@@ -4168,18 +4923,19 @@ function openWizard({ then = null } = {}) {
4168
4923
  const SET_SECTIONS = [
4169
4924
  ['You', 'How Home looks and what its bar holds', ['look', 'bar']],
4170
4925
  ['The agents', 'Who works on this Mac', ['agents', 'bishop', 'local']],
4171
- ['System', 'The projects of this Mac and the version', ['projects', 'release']],
4926
+ ['System', 'The projects of this Mac, the version and the manual', ['projects', 'release', 'manual']],
4172
4927
  ];
4173
4928
  // The room's own icons where the room has the category (app.js, SETTINGS_CATS); the bar, BISHOP
4174
4929
  // and the projects drawn here in the same hand: 20×20, one round stroke.
4175
4930
  const SET_CATS = {
4176
- look: { name: 'Appearance', icon: '<circle cx="10" cy="10" r="6.5" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M10 3.5a6.5 6.5 0 0 1 0 13z" fill="currentColor"/>' },
4177
- bar: { name: 'Top bar', icon: '<rect x="2.6" y="5.4" width="14.8" height="9.2" rx="3" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M6.2 10h2.2M11.6 10h2.2" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>' },
4178
- agents: { name: 'Agents', icon: '<circle cx="7" cy="8" r="2.6" fill="none" stroke="currentColor" stroke-width="1.6"/><circle cx="13.6" cy="8" r="2.6" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M2.8 16c.6-2.3 2.2-3.6 4.2-3.6s3.6 1.3 4.2 3.6M9.6 13c.9-.4 2.4-.6 4-.6 2 0 3.6 1.3 4.2 3.6" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/>' },
4179
- bishop: { name: 'Coordinator', icon: '<path d="M2.6 10c1.7-3.1 4.3-4.8 7.4-4.8s5.7 1.7 7.4 4.8c-1.7 3.1-4.3 4.8-7.4 4.8S4.3 13.1 2.6 10z" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><circle cx="10" cy="10" r="2.3" fill="currentColor"/>' },
4180
- local: { name: 'Local AI', icon: '<rect x="5" y="5" width="10" height="10" rx="2.4" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M8 2.6v2.4M12 2.6v2.4M8 15v2.4M12 15v2.4M2.6 8h2.4M2.6 12h2.4M15 8h2.4M15 12h2.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="10" cy="10" r="1.8" fill="currentColor"/>' },
4181
- projects: { name: 'Projects', icon: '<path d="M3.5 6.2c0-.9.7-1.6 1.6-1.6h3l1.6 1.8h5.2c.9 0 1.6.7 1.6 1.6v6.4c0 .9-.7 1.6-1.6 1.6H5.1c-.9 0-1.6-.7-1.6-1.6z" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/>' },
4182
- release: { name: 'Version', icon: '<path d="M15.6 10a5.6 5.6 0 1 1-1.64-3.96" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M15.7 3.6v3.2h-3.2" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>' },
4931
+ look: { name: 'Appearance', icon: trazoDrawing('appearance') },
4932
+ bar: { name: 'Top bar', icon: trazoDrawing('arrange') },
4933
+ agents: { name: 'Agents', icon: trazoDrawing('agents') },
4934
+ bishop: { name: 'Coordinator', icon: trazoDrawing('coordinator') },
4935
+ local: { name: 'Local AI', icon: trazoDrawing('spark') },
4936
+ projects: { name: 'Projects', icon: trazoDrawing('folder') },
4937
+ release: { name: 'Version', icon: trazoDrawing('refresh') },
4938
+ manual: { name: 'User manual', icon: trazoDrawing('book') },
4183
4939
  };
4184
4940
  const SET_ORDER = ['look', 'bar', 'agents', 'bishop', 'local', 'projects', 'release'];
4185
4941
  // The words the search knows, each pointing to the category that holds it (app.js, SETTINGS_INDEX).
@@ -4189,12 +4945,14 @@ const SET_INDEX = [
4189
4945
  ['bishop', 'Talk to the Coordinator'], ['bishop', 'Open the Coordinator in a new tab'],
4190
4946
  ['local', 'Ollama'], ['local', 'Automatic'], ['local', 'One by one'], ['local', 'Manual'],
4191
4947
  ['projects', 'Add a project'], ['projects', 'See the welcome again'], ['projects', 'The tour of MADRE 1.0'],
4192
- ['release', 'Check now'],
4948
+ ['release', 'Check now'], ['release', 'Uninstall MADRE'],
4193
4949
  ];
4194
4950
  const THEME_WORDS = { auto: () => t('Automatic'), light: () => t('Light'), dark: () => t('Dark') };
4195
- const catName = (id) => t(SET_CATS[id].name);
4196
- const setIcon = (id) => { const span = el('span', 'settings-icon'); span.innerHTML = `<svg viewBox="0 0 20 20" aria-hidden="true">${SET_CATS[id].icon}</svg>`; span.style.setProperty('--cat', 'var(--phosphor)'); return span; }; // trusted: our own SVG strings
4197
- const CHEVRON = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4.2 6.2 8 10l3.8-3.8" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>';
4951
+ // In the chat shell the projects at hand live in the sidebar, and Settings calls them so (2026-10-28).
4952
+ const SIDEBAR_CAT = trazoDrawing('sidebar');
4953
+ const catName = (id) => (id === 'bar' && homeShellOn() ? t('Sidebar') : t(SET_CATS[id].name));
4954
+ const setIcon = (id) => { const span = el('span', 'settings-icon'); span.innerHTML = `<svg viewBox="0 0 20 20" aria-hidden="true">${id === 'bar' && homeShellOn() ? SIDEBAR_CAT : SET_CATS[id].icon}</svg>`; span.style.setProperty('--cat', 'var(--phosphor)'); return span; }; // trusted: our own SVG strings
4955
+ const CHEVRON = trazo('chevron');
4198
4956
  const chevron = (className) => { const mark = el('span', `${className} chev-icon`); mark.innerHTML = CHEVRON; return mark; }; // trusted: our own SVG string
4199
4957
  const fold = (text) => String(text).normalize('NFD').replace(/\p{M}/gu, '').toLowerCase();
4200
4958
  const bishopRoom = () => data?.rooms.find((room) => room.id === data.salas) ?? null;
@@ -4240,9 +4998,16 @@ function customSeg(options, current, pick, size = '') {
4240
4998
  }
4241
4999
 
4242
5000
  // How each category stands, in a line, from what the lobby already knows; nothing is guessed.
5001
+ // The user manual (1.0.5): its own page in Home's language, and the same manual in PDF.
5002
+ function openManual() { window.open(`/manual?lang=${language}`, '_blank', 'noopener'); }
4243
5003
  function setStatus(id) {
5004
+ if (id === 'manual') return { line: t('With pictures, step by step. Also as a PDF.') };
4244
5005
  const looks = readLooks();
4245
- if (id === 'look') return { line: `${THEME_WORDS[looks.theme]()} · ${WALLPAPER_WORDS[looks.wallpaper]()} · ${ACCENT_WORDS[looks.accent]()}` };
5006
+ // The new design shows no wallpaper (salas-mac.css, .sm-sky), so the summary no longer names one
5007
+ // that is nowhere to be seen (QA 1.1.0, ACT-06).
5008
+ if (id === 'look') return { line: document.documentElement.classList.contains('chat-shell')
5009
+ ? `${THEME_WORDS[looks.theme]()} · ${ACCENT_WORDS[looks.accent]()}`
5010
+ : `${THEME_WORDS[looks.theme]()} · ${WALLPAPER_WORDS[looks.wallpaper]()} · ${ACCENT_WORDS[looks.accent]()}` };
4246
5011
  if (id === 'bar') {
4247
5012
  if (!pinsStored()) return { line: t('The open projects, as they open') };
4248
5013
  const count = pinsShown().length;
@@ -4276,6 +5041,13 @@ function setStatus(id) {
4276
5041
  function setQuick(id) {
4277
5042
  const rows = el('div', 'settings-quick');
4278
5043
  const add = (label, control) => { const row = el('div', 'settings-quick-row'); row.append(el('span', null, label), control); rows.append(row); };
5044
+ if (id === 'manual') {
5045
+ const pdf = el('a', 'sx-btn settings-manual-pdf', t('PDF'));
5046
+ pdf.href = `/assets/manual/madre-manual-${language}.pdf`;
5047
+ pdf.setAttribute('download', '');
5048
+ pdf.addEventListener('click', (event) => event.stopPropagation());
5049
+ add(t('Download it to print or share'), pdf);
5050
+ }
4279
5051
  if (id === 'look') {
4280
5052
  const { theme } = readLooks();
4281
5053
  const seg = el('div', 'settings-seg');
@@ -4284,7 +5056,7 @@ function setQuick(id) {
4284
5056
  }
4285
5057
  add(t('Theme'), seg);
4286
5058
  }
4287
- if (id === 'bar') add(t('Arrange the bar'), sxButton(t('Arrange'), (event) => { event.stopPropagation(); settingsSheet?.close(); pinsEdit(true); }));
5059
+ if (id === 'bar' && !homeShellOn()) add(t('Arrange the bar'), sxButton(t('Arrange'), (event) => { event.stopPropagation(); settingsSheet?.close(); pinsEdit(true); }));
4288
5060
  if (id === 'agents' && agentsSeen) {
4289
5061
  for (const agent of agentsSeen.agents.filter((one) => one.id !== 'madre' && one.detected)) {
4290
5062
  const state = agentState(agent, agentsSeen);
@@ -4321,16 +5093,48 @@ function lookPreview(looks) {
4321
5093
  const coord = el('div', 'hp-tile hp-coord');
4322
5094
  const head = el('div', 'hp-head');
4323
5095
  head.append(el('span', 'hp-mark'), el('b', null, t('Coordinator')));
4324
- coord.append(head, el('small', null, t('Calm')), el('span', 'hp-key', t('Talk to the Coordinator')));
5096
+ coord.append(head, el('small', null, t('Active')), el('span', 'hp-key', t('Talk to the Coordinator')));
4325
5097
  grid.append(coord);
4326
5098
  names.forEach((name, index) => {
4327
5099
  const card = el('div', 'hp-tile hp-card');
4328
5100
  const state = el('small', 'hp-state');
4329
- state.append(el('i'), index ? t('Asleep') : t('Calm'));
5101
+ state.append(el('i'), index ? t('Asleep') : t('Active'));
4330
5102
  card.append(el('b', null, name), state, el('span', 'hp-chat'), el('span', 'hp-strip'), el('span', `hp-key${index ? '' : ' on'}`, t('Open')));
4331
5103
  grid.append(card);
4332
5104
  });
4333
5105
  preview.append(bar, grid);
5106
+ // Home as it looks now (2026-10-28), in the chat shell: the sidebar, the bar, and flat cards on the
5107
+ // canvas, in the theme and accent chosen — the old preview drew the Home of glass and pills.
5108
+ if (root.classList.contains('home-shell')) {
5109
+ preview.classList.add('shell');
5110
+ const side = el('div', 'hps-side');
5111
+ const brand = el('i', 'hps-brand');
5112
+ side.append(brand);
5113
+ for (const [words, on] of [[t('Home'), true], [t('Coordinator'), false], [t('Market'), false]]) side.append(el('span', `hps-row${on ? ' on' : ''}`, words));
5114
+ side.append(el('small', 'hps-label', t('Projects')));
5115
+ names.forEach((name, index) => { const row = el('span', 'hps-row hps-project'); row.append(el('i', index ? 'asleep' : null), name); side.append(row); });
5116
+ const main = el('div', 'hps-main');
5117
+ const top = el('div', 'hps-top');
5118
+ top.append(el('b', null, t('Home')), el('span', 'hps-keys'));
5119
+ const tiles = el('div', 'hps-tiles');
5120
+ const coordTile = el('div', 'hps-tile hps-coord');
5121
+ const coordHead = el('div', 'hp-head');
5122
+ coordHead.append(el('span', 'hp-mark'), el('b', null, t('Coordinator')));
5123
+ coordTile.append(coordHead, el('span', 'hps-key on', t('Talk to the Coordinator')));
5124
+ const waiting = el('div', 'hps-tile hps-wait');
5125
+ waiting.append(el('b', null, t('Waiting on you')), el('strong', null, '0'));
5126
+ const cards = el('div', 'hps-tile hps-cards');
5127
+ names.forEach((name, index) => {
5128
+ const card = el('div', 'hps-card');
5129
+ const state = el('small', 'hp-state');
5130
+ state.append(el('i'), index ? t('Asleep') : t('Active'));
5131
+ card.append(el('b', null, name), state, el('span', 'hp-chat'), el('span', `hps-key${index ? '' : ' on'}`, t('Open')));
5132
+ cards.append(card);
5133
+ });
5134
+ tiles.append(coordTile, waiting, cards);
5135
+ main.append(top, tiles);
5136
+ preview.replaceChildren(side, main);
5137
+ }
4334
5138
  return preview;
4335
5139
  }
4336
5140
 
@@ -4436,9 +5240,12 @@ function fillLook(host) {
4436
5240
  }
4437
5241
  paperBox.append(tune);
4438
5242
  }
4439
- sxBlock(page, t('Wallpaper'), photo
4440
- ? t('The project\'s background can be a photograph, shown as a layer or as a mesh of its colors: choose how strong it looks and how much the photograph blurs.')
4441
- : t('Behind Home, and behind the conversation of the project served at this address. Light and dark each have their own.')).rows.append(paperBox);
5243
+ // The chat shell's look has no picture behind Home or a project (2026-10-26): no wallpaper to choose.
5244
+ if (!document.documentElement.classList.contains('chat-shell')) {
5245
+ sxBlock(page, t('Wallpaper'), photo
5246
+ ? t('The project\'s background can be a photograph, shown as a layer or as a mesh of its colors: choose how strong it looks and how much the photograph blurs.')
5247
+ : t('Behind Home, and behind the conversation of the project served at this address. Light and dark each have their own.')).rows.append(paperBox);
5248
+ }
4442
5249
 
4443
5250
  // Home's own: its cards, its text, the order of its projects. The conversation's bubbles and text
4444
5251
  // are each project's, in its own Settings.
@@ -4468,17 +5275,20 @@ function fillLook(host) {
4468
5275
  host.append(frame);
4469
5276
  }
4470
5277
  function fillBar(host) {
4471
- const block = sxBlock(host, t('Top bar'), t('The projects you keep at hand, in the order you choose. A project comes to the bar from its card: right-click it, or drag it to the bar.'));
5278
+ const side = homeShellOn();
5279
+ const block = side
5280
+ ? sxBlock(host, t('Sidebar'), t('The projects you keep at hand in the sidebar, in the order you choose. A project comes to it from its card: right-click it, or drag it onto the list.'))
5281
+ : sxBlock(host, t('Top bar'), t('The projects you keep at hand, in the order you choose. A project comes to the bar from its card: right-click it, or drag it to the bar.'));
4472
5282
  const ids = pinsShown();
4473
- if (!ids.length) sxRow(block, t('Nothing pinned'), null);
5283
+ if (!ids.length) sxRow(block, side ? t('No project in the sidebar yet') : t('Nothing pinned'), null);
4474
5284
  for (const id of ids) {
4475
5285
  const room = data.rooms.find((one) => one.id === id);
4476
5286
  sxRow(block, room.name, stateOf(room).words, sxButton(t('Remove'), () => pinRemove(id)));
4477
5287
  }
4478
5288
  const acts = el('div', 'sx-actions end');
4479
5289
  if (pinsStored()) acts.append(sxButton(t('Back to default'), () => pinsReset()));
4480
- acts.append(sxButton(t('Arrange the bar'), () => { settingsSheet?.close(); pinsEdit(true); }, { tone: 'primary' }));
4481
- host.append(acts);
5290
+ if (!side) acts.append(sxButton(t('Arrange the bar'), () => { settingsSheet?.close(); pinsEdit(true); }, { tone: 'primary' }));
5291
+ if (acts.childElementCount) host.append(acts);
4482
5292
  }
4483
5293
  function fillAgents(host, keep) {
4484
5294
  // The project's AJUSTES › Agents, here too: a sentence, then a card per agent.
@@ -4497,22 +5307,28 @@ function fillBishop(host) {
4497
5307
  }
4498
5308
  // LOCAL AI (src/local-ai.mjs): whether every project uses Ollama, the ones picked here, or each
4499
5309
  // one as it decides in its own Settings. The switch of each project is the same one its Settings
4500
- // show; Ollama itself and what it does are set in a project's Modules › Local AI.
5310
+ // show. Since 2026-10-20 Ollama itself is governed here too, as the agents are: the server, the
5311
+ // switch for the whole computer and the model every project uses. What it does in one project
5312
+ // (its roles) stays in that project's Settings › Local AI.
4501
5313
  const LOCAL_MODE_WORDS = { auto: () => t('Automatic'), pick: () => t('One by one'), manual: () => t('Manual') };
4502
5314
  const LOCAL_MODE_SAYS = {
4503
5315
  auto: () => t('Every project uses it, new ones too.'),
4504
5316
  pick: () => t('Only the projects you switch on below. New projects start without it.'),
4505
- manual: () => t('Each project decides in its own Modules › Local AI. New ones start with it.'),
5317
+ manual: () => t('Each project decides in its own Settings › Local AI. New ones start with it.'),
4506
5318
  };
4507
5319
  let localFailed = false; // the last read got no answer: the sheet says so instead of «Reading…» forever
4508
5320
  let localHardware = null; // what this computer can run and train (src/modules/local-models.mjs)
4509
- async function loadLocal() {
5321
+ let localOllama = null; // what /api/ollama said: the server, its models, and every model this computer may choose
5322
+ let localAllModels = false; // «See every model» was pressed
5323
+ async function loadLocal({ probe = false } = {}) {
4510
5324
  const answer = await fetch('/api/salas/local-ai', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
4511
- const ollama = await fetch('/api/ollama', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
5325
+ const ollama = probe ? await post('/api/ollama/probe').then((reply) => (reply.ok ? reply.body : null))
5326
+ : await fetch('/api/ollama', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
4512
5327
  if (ollama?.recommended?.hardware) localHardware = ollama.recommended.hardware;
5328
+ if (ollama?.ollama) localOllama = ollama;
4513
5329
  if (answer) localSeen = answer;
4514
5330
  localFailed = !answer;
4515
- settingsSheet?.sync({ detail: true });
5331
+ settingsSheet?.sync({ detail: true, only: 'local' });
4516
5332
  return answer;
4517
5333
  }
4518
5334
  async function saveLocal(patch) {
@@ -4520,7 +5336,7 @@ async function saveLocal(patch) {
4520
5336
  if (!answer.ok) { toast(answer.body?.error ?? t('Home did not answer.')); return; }
4521
5337
  localSeen = answer.body;
4522
5338
  if (localSeen.later?.length) toast(t('{names} will use it when restarted: it was started before this setting existed.', { names: localSeen.later.join(', ') }));
4523
- settingsSheet?.sync({ detail: true });
5339
+ settingsSheet?.sync({ detail: true, only: 'local' });
4524
5340
  }
4525
5341
  // The rail every settings sheet uses (app.js, sxSeg; styles.css, .sx-seg): the mark moves when chosen.
4526
5342
  function sxSeg(options, current, pick, { label = null } = {}) {
@@ -4553,11 +5369,11 @@ function fillLocal(host) {
4553
5369
  }
4554
5370
  if (!localSeen) { host.append(el('p', 'settings-reading', t('Reading…'))); return; }
4555
5371
  host.append(el('p', 'sx-intro', t('Ollama runs local AI: it searches and sums up each project\'s memory and answers as @madre, free and private. Choose which projects use it.')));
5372
+ drawLocalServer(host);
5373
+ drawLocalModel(host);
4556
5374
  const mode = sxBlock(host, t('Which projects'), LOCAL_MODE_SAYS[localSeen.mode]());
4557
5375
  sxRow(mode, t('Mode'), null, localModeSeg());
4558
- if (!localSeen.master) sxRow(mode, t('Local AI is off for every project.'), t('Turn it on in a project, in Modules › Local AI.'));
4559
- else if (!localSeen.ollama.running) sxRow(mode, t('Ollama is not running'), t('Projects keep working with their agents meanwhile. Start it from a project, in Modules › Local AI.'));
4560
- // What this computer can run and train, as a project shows it in Modules › Local AI.
5376
+ // What this computer can run and train, as a project shows it in Settings › Local AI.
4561
5377
  if (localHardware) drawHardware(host, localHardware, { el, sxBlock, sxRow, sxChip: (text, tone = '') => el('span', `sx-chip${tone ? ` ${tone}` : ''}`, text) });
4562
5378
  const list = sxBlock(host, t('Projects'), localSeen.mode === 'auto' ? t('All of them use it. Choose «One by one» or «Manual» to turn some off.') : t('A switch here is the same one the project shows in its Settings.'));
4563
5379
  if (!localSeen.projects.length) { sxRow(list, t('No projects yet'), null); return; }
@@ -4599,16 +5415,153 @@ function fillLocal(host) {
4599
5415
  list.rows.append(foot);
4600
5416
  }
4601
5417
  }
5418
+ // Ollama for the whole computer: is it there, is it running, is the local AI on at all.
5419
+ function drawLocalServer(host) {
5420
+ const info = localOllama?.ollama ?? null;
5421
+ const block = sxBlock(host, t('Ollama'), t('One for the whole computer: every project uses the same one.'));
5422
+ if (!info) { sxRow(block, t('Reading…'), null); return; }
5423
+ const recheck = sxButton(t('Check again'), async () => { recheck.disabled = true; await loadLocal({ probe: true }); });
5424
+ sxRow(block, t('Server'), info.running ? t('Running · {host}', { host: info.host }) : t('Not running'), recheck);
5425
+ // Where Ollama is (2026-10-28, src/server.mjs, /api/local-ai/host): this computer's, or another
5426
+ // one's — Windows' own from inside WSL, a computer with a graphics card —, tried before it is kept.
5427
+ const local = /^https?:\/\/(127\.0\.0\.1|localhost|\[::1\])(:\d+)?$/i.test(info.host ?? '');
5428
+ const address = el('form', 'sm-agent-key-form sm-ollama-host');
5429
+ const field = el('input');
5430
+ field.type = 'text';
5431
+ field.spellcheck = false;
5432
+ field.autocomplete = 'off';
5433
+ field.value = local ? '' : info.host ?? '';
5434
+ field.placeholder = 'http://192.168.1.40:11434';
5435
+ field.setAttribute('aria-label', t('Ollama address'));
5436
+ const test = sxButton(t('Test'), () => {});
5437
+ test.type = 'submit';
5438
+ const keep = async (host) => {
5439
+ test.disabled = true;
5440
+ const answer = await post('/api/local-ai/host', { host });
5441
+ test.disabled = false;
5442
+ if (!answer.ok) { toast(answer.body?.error ?? t('Home did not answer.')); return; }
5443
+ await loadLocal({ probe: true });
5444
+ };
5445
+ address.addEventListener('submit', (event) => { event.preventDefault(); void keep(field.value.trim()); });
5446
+ address.append(field, test);
5447
+ if (!local) address.append(sxButton(t('This computer'), () => void keep(null)));
5448
+ sxRow(block, t('Ollama address'), local ? t('This computer. Write another computer\'s address to use its AI.') : t('Another computer\'s. Every project uses it.'), address, { stack: true });
5449
+ if (!info.running) {
5450
+ const step = info.binary
5451
+ ? { label: t('Start Ollama'), path: '/api/ollama/start', note: t('Wakes Ollama on this computer. Nothing leaves it.') }
5452
+ : info.install?.display ? { label: t('Install Ollama'), path: '/api/ollama/install', note: info.install.note ?? info.install.display } : null;
5453
+ if (step) {
5454
+ const go = sxButton(step.label, async () => {
5455
+ go.disabled = true;
5456
+ const answer = await post(step.path);
5457
+ if (!answer.ok) { if (answer.body?.download) window.open(answer.body.download, '_blank', 'noopener'); toast(answer.body?.error ?? t('Home did not answer.')); go.disabled = false; return; }
5458
+ await loadLocal({ probe: true });
5459
+ }, { tone: 'primary' });
5460
+ sxRow(block, step.label, step.note, go);
5461
+ } else if (info.install?.download) {
5462
+ sxRow(block, t('Get Ollama'), null, sxButton(t('Download ↗'), () => window.open(info.install.download, '_blank', 'noopener'), { tone: 'primary' }));
5463
+ }
5464
+ sxRow(block, t('Meanwhile'), t('Projects keep working with their agents.'));
5465
+ }
5466
+ const master = el('label', 'settings-switch');
5467
+ const box = el('input');
5468
+ box.type = 'checkbox';
5469
+ box.checked = Boolean(localSeen.master);
5470
+ box.setAttribute('aria-label', t('Local AI'));
5471
+ box.addEventListener('change', async () => {
5472
+ box.disabled = true;
5473
+ await post('/api/ollama/settings', { enabled: box.checked });
5474
+ // Said to every open project at once, as a change of mode is.
5475
+ await saveLocal({});
5476
+ await loadLocal();
5477
+ });
5478
+ master.append(box, el('i'));
5479
+ sxRow(block, t('Local AI on this computer'), localSeen.master ? t('On. The projects you choose below use it.') : t('Off for every project.'), master);
5480
+ }
5481
+ // The model every project uses: MADRE's pick, or the person's, among the ones installed; then the
5482
+ // ones this computer runs that are not here yet, the recommended one first.
5483
+ const EMBEDDING = /embed|minilm|bge|nomic/i;
5484
+ // The model that fits this computer best, said the way the room's tags say things: a small pill in
5485
+ // the accent beside its name, never a grey bar the width of the row (2026-10-20).
5486
+ const RECOMMENDED_ICON = trazo('star-filled');
5487
+ function recommendedChip() {
5488
+ const chip = el('span', 'sx-recommend');
5489
+ chip.innerHTML = RECOMMENDED_ICON; // trusted: our own SVG string
5490
+ chip.append(el('span', null, t('Recommended for your computer')));
5491
+ return chip;
5492
+ }
5493
+ function drawLocalModel(host) {
5494
+ const info = localOllama?.ollama;
5495
+ if (!info?.running || !localSeen.master) return;
5496
+ const catalog = localOllama.recommended?.catalog ?? [];
5497
+ const known = (name) => catalog.find((one) => one.ollama === String(name).replace(/:latest$/, '')) ?? null;
5498
+ const best = catalog.find((one) => one.recommended) ?? null;
5499
+ const chosen = localSeen.model ?? null;
5500
+ const using = localSeen.ollama?.using ?? info.chatModel ?? null;
5501
+ const block = sxBlock(host, t('Model'), t('The one that answers as @madre and sums up the memory, in every project that uses the local AI.'));
5502
+ const pick = (model) => async () => { await saveLocal({ model }); await loadLocal(); };
5503
+ const inUse = () => el('span', 'sx-chip on', t('In use'));
5504
+ const autoWords = localSeen.ollama?.auto ? t('MADRE picks the best one installed: {model}.', { model: localSeen.ollama.auto }) : t('MADRE picks the best one installed.');
5505
+ sxRow(block, t('Automatic'), autoWords, chosen ? sxButton(t('Use'), pick(null)) : inUse());
5506
+ const chats = (info.models ?? []).filter((model) => !EMBEDDING.test(model.name) && !EMBEDDING.test(model.family ?? ''));
5507
+ for (const model of chats) {
5508
+ const face = known(model.name);
5509
+ const hint = [face?.maker, model.size ? gb(model.size) : null, face && face.run === 'no' ? t('May not fit in this computer\'s memory') : null].filter(Boolean).join(' · ');
5510
+ const row = sxRow(block, face?.label ?? model.name, hint, chosen && model.name === using ? inUse() : sxButton(t('Use'), pick(model.name)));
5511
+ if (face?.recommended) row.querySelector('.sx-words b')?.after(recommendedChip());
5512
+ }
5513
+ if (!chats.length) sxRow(block, t('No model yet'), t('Download one below: MADRE starts using it as soon as it arrives.'));
5514
+ // What this computer runs and has not got yet.
5515
+ const have = new Set(chats.map((model) => model.name.replace(/:latest$/, '')));
5516
+ const runs = catalog.filter((one) => one.run !== 'no' && !have.has(one.ollama))
5517
+ .sort((a, b) => Number(b.recommended) - Number(a.recommended) || b.params - a.params);
5518
+ if (!runs.length) return;
5519
+ const more = sxBlock(host, t('More models for your computer'), t('Only the ones that fit in its memory. Each downloads once and stays in Ollama.'));
5520
+ for (const one of localAllModels ? runs : runs.slice(0, 5)) {
5521
+ const hint = [one.maker, t(one.note), one.run === 'slow' ? t('Slow without a graphics card') : null].filter(Boolean).join(' · ');
5522
+ const get = sxButton(pulling.has(one.ollama) ? t('Downloading…') : t('Download'), async () => {
5523
+ get.disabled = true;
5524
+ const answer = await post('/api/ollama/pull', { model: one.ollama });
5525
+ if (!answer.ok) { toast(answer.status === 409 ? t('Another download is running. When it ends, try this one.') : answer.body?.error ?? t('Home did not answer.')); get.disabled = false; return; }
5526
+ get.textContent = t('Downloading…');
5527
+ watchPull(one.ollama);
5528
+ }, { tone: one.recommended ? 'primary' : null });
5529
+ // Redrawn while it downloads: it stays «Downloading…», not a second «Download».
5530
+ if (pulling.has(one.ollama)) get.disabled = true;
5531
+ const row = sxRow(more, one.label, hint, get);
5532
+ if (one.recommended) row.querySelector('.sx-words b')?.after(recommendedChip());
5533
+ }
5534
+ if (runs.length > 5) {
5535
+ const all = sxButton(localAllModels ? t('See fewer') : t('See every model ({n})', { n: runs.length }), () => { localAllModels = !localAllModels; settingsSheet?.sync({ detail: true }); });
5536
+ sxRow(more, '', null, all);
5537
+ }
5538
+ }
5539
+ // A download takes minutes: Home looks every few seconds until the model is there, then says so.
5540
+ const pulling = new Set();
5541
+ function watchPull(model) {
5542
+ if (pulling.has(model)) return;
5543
+ pulling.add(model);
5544
+ toast(t('Downloading {model}. It shows here when it arrives.', { model }));
5545
+ const started = Date.now();
5546
+ const look = async () => {
5547
+ await loadLocal({ probe: true });
5548
+ if ((localOllama?.ollama?.models ?? []).some((one) => one.name.replace(/:latest$/, '') === model)) { pulling.delete(model); toast(t('{model} is ready. Choose it in Settings › Local AI.', { model })); return; }
5549
+ if (Date.now() - started > 60 * 60 * 1000) { pulling.delete(model); return; }
5550
+ setTimeout(look, 8000);
5551
+ };
5552
+ setTimeout(look, 8000);
5553
+ }
4602
5554
  function fillProjects(host) {
4603
5555
  const block = sxBlock(host, t('Projects'), t('A project is a folder: MADRE gives it its own conversations and its own memory. Adding it does not open it; you open it from its card.'));
4604
5556
  sxRow(block, t('Add a project'), null, sxButton(t('Add'), () => { settingsSheet?.close(); openAddSheet(); }, { tone: 'primary' }));
4605
- sxRow(block, t('See the welcome again'), null, sxButton(t('Open'), () => { settingsSheet?.close(); welcomed = true; openWizard(); }));
5557
+ sxRow(block, t('See the welcome again'), t('Agents, AI on your computer, memory and a project, step by step.'), sxButton(t('Open'), () => { settingsSheet?.close(); openHomeWelcome({ at: 'hello' }); }));
4606
5558
  const back = homeTour.path() === 'back';
4607
5559
  sxRow(block, back ? t('The tour of MADRE 1.0') : t('Getting to know MADRE'), back ? t('Everything new, chapter by chapter. ? opens the gestures anywhere.') : t('The essentials, chapter by chapter. ? opens the gestures anywhere.'), sxButton(t('See the tour'), () => { settingsSheet?.close(); homeTour.openChapters(); }));
4608
5560
  }
4609
5561
  function fillRelease(host) {
4610
5562
  const info = versionSeen;
4611
- const block = sxBlock(host, t('Version'), info ? t('You run {version}. Home restarts with it from here.', { version: info.current }) : null);
5563
+ // Up to date there is nothing to restart with (QA 1.1.0, ACT-14).
5564
+ const block = sxBlock(host, t('Version'), info ? (info.available ? t('You run {version}. Home restarts with it from here.', { version: info.current }) : t('You run {version}, the newest.', { version: info.current })) : null);
4612
5565
  const check = info?.enabled ? sxButton(t('Check now'), async () => {
4613
5566
  check.disabled = true;
4614
5567
  const answer = await fetch('/api/version?force=1', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
@@ -4618,6 +5571,15 @@ function fillRelease(host) {
4618
5571
  settingsSheet?.sync({ detail: true });
4619
5572
  }) : null;
4620
5573
  sxRow(block, `MADRE ${info?.current ?? ''}`.trim(), info ? (info.available ? t('{version} available', { version: info.latest }) : info.enabled === false ? t('not checked') : t('up to date')) : t('Reading…'), check);
5574
+ // The one thing the daily usage notice says about this copy (src/heartbeat.mjs), in sight.
5575
+ if (info?.copyId) {
5576
+ const copy = sxButton(t('Copy'), async () => {
5577
+ try { await navigator.clipboard.writeText(info.copyId); copy.textContent = t('Copied'); setTimeout(() => { copy.textContent = t('Copy'); }, 1400); } catch { toast(t('Select it and copy it.'), 'error'); }
5578
+ });
5579
+ const row = sxRow(block, t('This copy\'s identifier'), t('Random and unique: this copy made it for itself. It lets the author tell one copy\'s errors from another\'s and find the fix for yours, without knowing who you are: no name, no projects.'), copy);
5580
+ row.querySelector('.sx-words')?.append(el('code', 'sm-install-id', info.copyId));
5581
+ }
5582
+ drawDonate(host);
4621
5583
  if (info?.available) {
4622
5584
  const notes = el('a', 'sx-btn', t('What it brings'));
4623
5585
  notes.href = info.release ?? 'https://madre.run';
@@ -4642,8 +5604,22 @@ function fillRelease(host) {
4642
5604
  const late = sxBlock(host, t('Projects on an older MADRE'), t('They keep running the version they started with until you restart them. What is running in them stops.'), { aside: behind.length > 1 ? sxButton(t('Restart all'), () => void restartAll(), { tone: 'primary' }) : null });
4643
5605
  for (const room of behind) sxRow(late, roomLabel(room), `MADRE ${room.open.version}`, sxButton(t('Restart'), () => { settingsSheet?.close(); void restartRoom(room); }));
4644
5606
  }
5607
+ // Uninstalling MADRE (2026-10-29): what goes and what stays is said before anything happens
5608
+ // (public/power.js, askUninstall).
5609
+ const leave = sxBlock(host, t('Uninstall MADRE'), t('Takes away what MADRE put on this computer: its conversations, memory and settings, and its folder inside your projects. Your projects and your AIs stay.'));
5610
+ sxRow(leave, t('Remove MADRE from this computer'), t('You will see the whole list before anything is removed.'), sxButton(t('Uninstall…'), () => void askUninstall(), { tone: 'danger' }));
4645
5611
  drawLegal(host);
4646
5612
  }
5613
+ // Supporting MADRE (2026-10-30): a donation on GitHub Sponsors, in the person's browser, under the
5614
+ // version and this copy's identifier, as a project's Settings › Version has it (app.js).
5615
+ function drawDonate(host) {
5616
+ const give = sxBlock(host, t('Support MADRE'), t('MADRE is free and made by one person. A donation helps keep it going and growing.'));
5617
+ const go = el('a', 'sx-btn primary', t('Donate'));
5618
+ go.href = SPONSORS_URL;
5619
+ go.target = '_blank';
5620
+ go.rel = 'noopener';
5621
+ sxRow(give, t('Donate on GitHub'), t('Once or every month, the amount you choose. GitHub keeps no commission.'), go);
5622
+ }
4647
5623
  async function updateHome(info, key, said) {
4648
5624
  key.disabled = true;
4649
5625
  said.textContent = '';
@@ -4685,7 +5661,7 @@ function openSettings(section = null) {
4685
5661
  win.id = 'settings';
4686
5662
  const head = el('header', 'custom-head settings-head');
4687
5663
  const search = el('label', 'settings-search');
4688
- search.innerHTML = '<svg viewBox="0 0 20 20" aria-hidden="true"><circle cx="9" cy="9" r="5.5" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M13.2 13.2 17 17" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'; // trusted: our own SVG
5664
+ search.innerHTML = trazo('search'); // trusted: our own SVG
4689
5665
  const input = el('input');
4690
5666
  input.type = 'search';
4691
5667
  input.placeholder = t('Search any setting');
@@ -4693,11 +5669,25 @@ function openSettings(section = null) {
4693
5669
  input.spellcheck = false;
4694
5670
  input.setAttribute('aria-label', t('Search any setting'));
4695
5671
  search.append(input);
4696
- head.append(el('span', 'custom-title', t('SETTINGS')), search, closeKey(() => dialog.close()));
5672
+ head.append(el('span', 'custom-title', t('Settings')), search, closeKey(() => dialog.close()));
4697
5673
  const body = el('div', 'sm-settings-body');
4698
5674
  win.append(head, body);
4699
5675
  dialog.append(win);
4700
5676
  document.body.append(dialog);
5677
+ // A window of Home in the chat shell (2026-10-28), as a project's Settings is one: not modal,
5678
+ // carried by its head, sized by its sides, its place kept (homeWindow). Its own × stays.
5679
+ const framed = homeWindow({ root: dialog, bar: head, close: () => dialog.close(), key: 'pulse.homeSettingsWindow', minW: 560, minH: 420, keys: false, size: { w: 980, h: 700 } });
5680
+ if (framed) {
5681
+ dialog.classList.add('sm-settings-framed');
5682
+ // Not modal, so Escape is asked here; it steps back the same way the modal sheet's does.
5683
+ dialog.addEventListener('keydown', (event) => {
5684
+ if (event.key !== 'Escape' || event.defaultPrevented) return;
5685
+ event.preventDefault();
5686
+ const ask = new Event('cancel', { cancelable: true });
5687
+ dialog.dispatchEvent(ask);
5688
+ if (!ask.defaultPrevented) dialog.close();
5689
+ });
5690
+ }
4701
5691
 
4702
5692
  const stop = () => { for (const one of state.stops.splice(0)) one(); };
4703
5693
  const card = (id) => {
@@ -4712,8 +5702,10 @@ function openSettings(section = null) {
4712
5702
  if (status.warn) node.append(el('p', 'settings-warn', status.warn));
4713
5703
  const quick = setQuick(id);
4714
5704
  if (quick) node.append(quick);
4715
- node.addEventListener('click', () => openCategory(id));
4716
- node.addEventListener('keydown', (event) => { if (event.target === node && (event.key === 'Enter' || event.key === ' ')) { event.preventDefault(); openCategory(id); } });
5705
+ // The manual is a page of its own, not a panel.
5706
+ const go = () => (id === 'manual' ? openManual() : openCategory(id));
5707
+ node.addEventListener('click', go);
5708
+ node.addEventListener('keydown', (event) => { if (event.target === node && (event.key === 'Enter' || event.key === ' ')) { event.preventDefault(); go(); } });
4717
5709
  return node;
4718
5710
  };
4719
5711
  const board = () => {
@@ -4721,7 +5713,7 @@ function openSettings(section = null) {
4721
5713
  for (const [name, sub, ids] of SET_SECTIONS) {
4722
5714
  const section = el('section', 'settings-section');
4723
5715
  const top = el('header');
4724
- top.append(el('b', null, t(name)), el('span', null, t(sub)));
5716
+ top.append(el('b', null, t(name)), el('span', null, t(homeShellOn() && sub === 'How Home looks and what its bar holds' ? 'How Home looks and what its sidebar holds' : sub)));
4725
5717
  const cards = el('div', 'settings-cards');
4726
5718
  for (const id of ids) cards.append(card(id));
4727
5719
  section.append(top, cards);
@@ -4767,9 +5759,9 @@ function openSettings(section = null) {
4767
5759
  stop();
4768
5760
  if (state.query.trim()) { body.replaceChildren(results()); return; }
4769
5761
  if (!state.open) { body.replaceChildren(board()); return; }
4770
- // Appearance has more to show than a sheet holds: it takes the whole window, as a category
4771
- // does in the room when a sheet would be cramped (app.js, «push»). The others open over the board.
4772
- const full = state.open === 'look';
5762
+ // Every category opens over the board from the side, Appearance too, as in a project's Settings
5763
+ // (2026-10-28: it took the whole window, and read as another screen rather than one of its sheets).
5764
+ const full = false;
4773
5765
  const sheet = el('div', `settings-sheet${full ? ' full' : ''}`);
4774
5766
  const scroll = el('div', 'settings-scroll');
4775
5767
  scroll.append(detail(state.open));
@@ -4780,6 +5772,7 @@ function openSettings(section = null) {
4780
5772
  body.replaceChildren(board(), scrim, sheet);
4781
5773
  };
4782
5774
  const openCategory = (id, landOn = null) => {
5775
+ if (id === 'manual') { openManual(); return; }
4783
5776
  state.open = id;
4784
5777
  draw();
4785
5778
  dialog.scrollTop = 0;
@@ -4808,8 +5801,11 @@ function openSettings(section = null) {
4808
5801
  // What the lobby learns while the window is open (an agent signs in, a version is found, a
4809
5802
  // project opens) reaches the cards and the sheet's line; a card that says the same is left alone,
4810
5803
  // so nothing under the pointer or the keyboard is drawn again for nothing.
4811
- const sync = ({ detail: again = false } = {}) => {
5804
+ // `only`: draw the open category again only when it is that one (a model downloading reloads Local
5805
+ // AI every few seconds, and redrew whatever was open — a key half pasted in Agents was lost).
5806
+ const sync = ({ detail: again = false, only = null } = {}) => {
4812
5807
  if (state.query.trim()) return;
5808
+ if (only && state.open !== only) again = false;
4813
5809
  for (const old of body.querySelectorAll('.settings-card')) {
4814
5810
  const fresh = card(old.dataset.cat);
4815
5811
  if (fresh.outerHTML !== old.outerHTML) old.replaceWith(fresh);
@@ -4824,12 +5820,12 @@ function openSettings(section = null) {
4824
5820
  // say so, and Appearance is drawn again with it.
4825
5821
  const paintLooks = () => { sync({ detail: state.open === 'look' }); };
4826
5822
  const show = (wanted) => {
4827
- if (!dialog.open) dialog.showModal();
5823
+ if (!dialog.open) { if (framed) { dialog.show(); framed.raise(); } else dialog.showModal(); }
4828
5824
  if (wanted && SET_FILL[wanted]) openCategory(wanted); else draw();
4829
5825
  };
4830
5826
  const close = () => dialog.close();
4831
5827
  settingsSheet = { show, paintLooks, sync, close };
4832
- dialog.addEventListener('close', () => { stop(); dialog.remove(); settingsSheet = null; });
5828
+ dialog.addEventListener('close', () => { stop(); framed?.drop(); dialog.remove(); settingsSheet = null; });
4833
5829
  show(section);
4834
5830
  }
4835
5831
  ui.gear.addEventListener('click', () => openSettings());
@@ -4844,6 +5840,9 @@ function translateStatic() {
4844
5840
  ui.add.textContent = t('Add a project');
4845
5841
  ui.bar.crumb.textContent = t('Home');
4846
5842
  ui.bar.open.setAttribute('aria-label', t('Projects on the bar'));
5843
+ document.querySelector('.sm-topbar:not(.sm-tb-home)')?.setAttribute('aria-label', t('Home'));
5844
+ document.querySelector('.sm-tb-home')?.setAttribute('aria-label', t('Reload and settings'));
5845
+ ui.colophon.setAttribute('aria-label', t('MADRE version'));
4847
5846
  ui.bar.agents.setAttribute('aria-label', t('Agents'));
4848
5847
  ui.bar.links.querySelector('span').textContent = t('Connections');
4849
5848
  document.querySelector('#sm-tb-market span')?.replaceChildren(t('Market'));
@@ -4882,7 +5881,335 @@ function translateStatic() {
4882
5881
  ui.memory.title.textContent = t('Memory');
4883
5882
  ui.decisions.title.textContent = t('Recent decisions');
4884
5883
  ui.attention.title.textContent = t('Needs you');
4885
- for (const kind of KINDS) KIND_WORDS[kind] = t(kind.toUpperCase());
5884
+ // A claim the room found false is said as everywhere else: a doubtful memory, not «aberration».
5885
+ for (const kind of KINDS) KIND_WORDS[kind] = t(kind === 'aberration' ? 'DOUBTFUL MEMORY' : kind.toUpperCase());
5886
+ sayHomeShell();
5887
+ }
5888
+
5889
+ // ---- HOME IN THE CHAT SHELL (2026-10-27) ------------------------------------------------------
5890
+ // Home framed as a project is (app.js, chatShell): a sidebar at the left that one key shows and
5891
+ // hides — MADRE, the ways to go, the projects at hand, the version and the house's keys at its
5892
+ // foot —, a bar of 48 px over the canvas with the page's name, the agents and the tools as quiet
5893
+ // icons, and the widgets flat on the canvas. The same classes as the room's sidebar (styles.css,
5894
+ // .side-*), so moving between Home and a project feels like one place. The projects at hand are
5895
+ // the ones the bar held (the pins: the open ones, until the person chooses), and a card dropped on
5896
+ // the list pins it there. Not on a phone, where the bar keeps them as before.
5897
+ const SIDE_KEY = 'pulse.homeSide';
5898
+ const SIDEBAR_GLYPH = trazo('sidebar');
5899
+ const HOME_GLYPH = trazo('home');
5900
+ // The Market drawn one way everywhere (2026-10-30): the basket with the modules inside; only the top bar's key moves on hover.
5901
+ const MARKET_GLYPH = trazo('market-key');
5902
+ const COORDINATOR_GLYPH = trazo('coordinator');
5903
+ const ALL_GLYPH = trazo('list');
5904
+ const homeShell = { side: null, list: null, said: '', open: false };
5905
+ const homeShellOn = () => root.classList.contains('home-shell');
5906
+ // A phone keeps Home as it was; a narrow window gets the sidebar over the canvas, shut at first.
5907
+ const SHELL_PHONE = '(max-width: 560px)';
5908
+ const SHELL_NARROW = '(max-width: 960px)';
5909
+ function sideKey(icon, label, run) {
5910
+ const key = button('shell-key', null, (event) => { event.stopPropagation(); run(); });
5911
+ key.innerHTML = icon; // trusted: our own SVG strings
5912
+ key.setAttribute('aria-label', label);
5913
+ key.title = label;
5914
+ return key;
5915
+ }
5916
+ function sideRow(icon, label, run, { here = false } = {}) {
5917
+ const row = button('side-row', null, run);
5918
+ row.innerHTML = icon; // trusted: our own SVG strings
5919
+ row.append(el('span', null, label));
5920
+ if (here) row.setAttribute('aria-current', 'page');
5921
+ return row;
5922
+ }
5923
+ function setSide(open, { keep = true } = {}) {
5924
+ homeShell.open = open;
5925
+ root.classList.toggle('home-side', open);
5926
+ homeShell.side?.toggleAttribute('inert', !open);
5927
+ if (keep && !window.matchMedia(SHELL_NARROW).matches) { try { localStorage.setItem(SIDE_KEY, open ? 'open' : 'shut'); } catch { /* as long as the page lasts */ } }
5928
+ }
5929
+ function buildHomeShell() {
5930
+ if (!root.classList.contains('chat-shell') || homeShell.side) return;
5931
+ const side = el('aside', 'sm-side');
5932
+ side.id = 'sm-side';
5933
+ const head = el('div', 'side-head');
5934
+ const brand = document.getElementById('sm-back')?.cloneNode(true);
5935
+ if (brand) { brand.removeAttribute('id'); brand.className = 'side-brand'; }
5936
+ homeShell.add = sideKey(ADD_ICON, t('Add a project'), () => ui.add.click());
5937
+ homeShell.hide = sideKey(SIDEBAR_GLYPH, t('Hide the sidebar'), () => setSide(false));
5938
+ head.append(homeShell.hide, ...(brand ? [brand] : []), el('span', 'side-grow'), homeShell.add);
5939
+ const nav = el('nav', 'side-nav');
5940
+ homeShell.rows = {
5941
+ add: sideRow(ADD_ICON, t('Add a project'), () => ui.add.click()),
5942
+ home: sideRow(HOME_GLYPH, t('Home'), () => window.scrollTo({ top: 0, behavior: motionStill() ? 'auto' : 'smooth' }), { here: true }),
5943
+ coordinator: sideRow(COORDINATOR_GLYPH, t('Coordinator'), () => openBishop()),
5944
+ market: sideRow(MARKET_GLYPH, t('Market'), () => openHomeMarket('shop')),
5945
+ };
5946
+ nav.append(...Object.values(homeShell.rows));
5947
+ const scroll = el('div', 'side-scroll');
5948
+ homeShell.label = el('div', 'side-label', t('Projects'));
5949
+ homeShell.list = el('div', 'side-projects');
5950
+ scroll.append(homeShell.label, homeShell.list);
5951
+ // A project's card dropped on the list keeps it here, where it was let go.
5952
+ scroll.addEventListener('dragover', (event) => {
5953
+ if (!pins.dropping || !event.dataTransfer?.types.includes(PIN_TYPE)) return;
5954
+ event.preventDefault();
5955
+ event.dataTransfer.dropEffect = 'copy';
5956
+ scroll.classList.add('is-drop');
5957
+ });
5958
+ scroll.addEventListener('dragleave', (event) => { if (!scroll.contains(event.relatedTarget)) scroll.classList.remove('is-drop'); });
5959
+ scroll.addEventListener('drop', (event) => {
5960
+ const id = event.dataTransfer?.getData(PIN_TYPE);
5961
+ scroll.classList.remove('is-drop');
5962
+ if (!id) return;
5963
+ event.preventDefault();
5964
+ const rows = [...homeShell.list.querySelectorAll('[data-room]')];
5965
+ const at = rows.findIndex((row) => { const box = row.getBoundingClientRect(); return event.clientY < box.top + box.height / 2; });
5966
+ pinsDropEnd();
5967
+ pinAdd(id, at < 0 ? rows.length : at);
5968
+ });
5969
+ const foot = el('div', 'side-foot');
5970
+ const who = el('div', 'side-who');
5971
+ homeShell.version = el('b', null, 'MADRE');
5972
+ const copy = el('a', 'side-copy', `© ${YEAR} ${AUTHOR}`);
5973
+ copy.href = AUTHOR_URL;
5974
+ copy.target = '_blank';
5975
+ copy.rel = 'noopener';
5976
+ who.append(homeShell.version, copy);
5977
+ homeShell.settings = sideKey(ui.gear.innerHTML, t('Settings'), () => openSettings());
5978
+ homeShell.power = sideKey(POWER_ICON, t('Restart or turn off MADRE'), () => openPowerMenu(homeShell.power));
5979
+ homeShell.power.setAttribute('aria-haspopup', 'menu');
5980
+ foot.append(who, homeShell.settings, homeShell.power);
5981
+ side.append(head, nav, scroll, foot);
5982
+ document.body.prepend(side);
5983
+ homeShell.side = side;
5984
+ arrangeHomeBar();
5985
+ // In the bar, while the sidebar is shut: its key, before the page's name.
5986
+ homeShell.show = sideKey(SIDEBAR_GLYPH, t('Show the sidebar'), () => setSide(true));
5987
+ homeShell.show.classList.add('sm-side-show');
5988
+ document.querySelector('.sm-top > .sm-topbar:first-child')?.prepend(homeShell.show);
5989
+ // Over the canvas on a narrow window: a press outside, or Escape, puts it away.
5990
+ homeShell.scrim = el('div', 'sm-side-scrim');
5991
+ homeShell.scrim.addEventListener('click', () => setSide(false, { keep: false }));
5992
+ document.body.append(homeShell.scrim);
5993
+ document.addEventListener('keydown', (event) => {
5994
+ if (event.key === 'Escape' && homeShell.open && window.matchMedia(SHELL_NARROW).matches && !document.querySelector('dialog[open]')) setSide(false, { keep: false });
5995
+ });
5996
+ const place = () => {
5997
+ const was = homeShellOn();
5998
+ const on = !window.matchMedia(SHELL_PHONE).matches;
5999
+ root.classList.toggle('home-shell', on);
6000
+ if (on !== was && data) drawPins();
6001
+ let kept = null;
6002
+ try { kept = localStorage.getItem(SIDE_KEY); } catch { /* no storage */ }
6003
+ if (window.matchMedia(SHELL_NARROW).matches) setSide(false, { keep: false });
6004
+ else setSide(kept ? kept === 'open' : true, { keep: false });
6005
+ };
6006
+ window.matchMedia(SHELL_PHONE).addEventListener?.('change', place);
6007
+ window.matchMedia(SHELL_NARROW).addEventListener?.('change', place);
6008
+ place();
6009
+ }
6010
+ // The projects at hand, each with its state as the room's sidebar says it: a press goes there, or
6011
+ // wakes it and goes in; ⌘-press opens it in a new tab. The rest are one row away, on Home itself.
6012
+ function drawSideProjects() {
6013
+ if (!homeShell.list || !data) return;
6014
+ if (data.version) homeShell.version.textContent = `MADRE ${data.version}`;
6015
+ const ids = pinsShown();
6016
+ const rooms = ids.map((id) => data.rooms.find((one) => one.id === id)).filter(Boolean);
6017
+ const said = JSON.stringify([language, rooms.map((room) => [room.id, room.name, room.open?.port ?? 0, busy.get(room.id) ?? stateOf(room).key, room.glance?.waitingCount ?? 0])]);
6018
+ if (said === homeShell.said) return;
6019
+ homeShell.said = said;
6020
+ homeShell.label.textContent = t('Projects');
6021
+ const MOOD = { calm: 'calm', working: 'working', waiting: 'waiting', outdated: 'quiet', quiet: 'quiet', asleep: 'asleep' };
6022
+ const rows = rooms.map((room) => {
6023
+ const state = stateOf(room);
6024
+ const waking = busy.get(room.id) === 'starting';
6025
+ const row = el(room.open ? 'a' : 'button', `side-project${room.open ? '' : ' asleep'}`);
6026
+ row.dataset.room = room.id;
6027
+ row.append(el('i', `side-dot ${waking ? 'working' : MOOD[state.key] ?? 'calm'}`), el('span', 'side-project-name', room.name));
6028
+ if (state.key === 'waiting') row.append(el('small', 'side-count', String(room.glance.waitingCount)));
6029
+ row.title = `${room.name} · ${waking ? t('Waking…') : state.words}`;
6030
+ if (room.open) row.href = addressOf(room);
6031
+ else { row.type = 'button'; row.addEventListener('click', (event) => { if (busy.has(room.id)) return; if (event.metaKey || event.ctrlKey) void startRoom(room); else void startRoom(room, { enter: true }); }); }
6032
+ row.addEventListener('contextmenu', (event) => pinsMenu(event, room));
6033
+ return row;
6034
+ });
6035
+ const all = sideRow(ALL_GLYPH, t('All your projects'), () => document.getElementById('sm-drawer')?.scrollIntoView({ behavior: motionStill() ? 'auto' : 'smooth', block: 'start' }));
6036
+ all.classList.add('side-all');
6037
+ if (!rooms.length) rows.push(el('p', 'side-empty', t('Open a project and it shows here.')));
6038
+ homeShell.list.replaceChildren(...rows, all);
6039
+ }
6040
+ function sayHomeShell() {
6041
+ if (!homeShell.side) return;
6042
+ homeShell.side.setAttribute('aria-label', t('Home'));
6043
+ const words = { add: t('Add a project'), home: t('Home'), coordinator: t('Coordinator'), market: t('Market') };
6044
+ for (const [key, row] of Object.entries(homeShell.rows)) row.querySelector('span').textContent = words[key];
6045
+ for (const [key, label] of [[homeShell.add, t('Add a project')], [homeShell.hide, t('Hide the sidebar')], [homeShell.show, t('Show the sidebar')], [homeShell.settings, t('Settings')], [homeShell.power, t('Restart or turn off MADRE')]]) { key.title = label; key.setAttribute('aria-label', label); }
6046
+ homeShell.said = '';
6047
+ drawSideProjects();
6048
+ }
6049
+ // ---- WINDOWS IN HOME (2026-10-28), as a project's are (app.js, marketAsWindow and its helpers):
6050
+ // the sheet carried by its bar, sized by its sides and corners, always whole inside the browser
6051
+ // window, the one touched last in front, and its place kept for the next time. Over the sidebar,
6052
+ // as a project's windows stand over its sidebar; the Market is the one that opens this way.
6053
+ const HOME_WINDOW_LAYER = 44;
6054
+ const HOME_WINDOW_INSET = 8;
6055
+ const homeWindows = [];
6056
+ function homeWindowForward(node) {
6057
+ const at = homeWindows.indexOf(node);
6058
+ if (at >= 0) homeWindows.splice(at, 1);
6059
+ homeWindows.push(node);
6060
+ homeWindows.forEach((one, index) => { one.style.zIndex = String(HOME_WINDOW_LAYER + index); one.classList.toggle('front', index === homeWindows.length - 1); });
6061
+ }
6062
+ // Depth of field in Home (2026-10-30), as in a project (app.js, paintDepth): while windows float
6063
+ // over Home, the page behind them — its bar and its widgets — recedes under one veil, a little more
6064
+ // for each window up to three, and clears the moment the last one closes. The sidebar stands over
6065
+ // the veil and stays sharp, as a project's does. One veil, not a filter on each piece, so the glass
6066
+ // of what is behind keeps working.
6067
+ const homeVeil = el('div', 'desk-veil');
6068
+ homeVeil.setAttribute('aria-hidden', 'true');
6069
+ document.body.append(homeVeil);
6070
+ function paintHomeDepth() {
6071
+ const open = [...document.querySelectorAll('.home-window')].filter((one) => one.isConnected && !one.hidden && (one.tagName !== 'DIALOG' || one.open) && one.getClientRects().length && !one.classList.contains('leaving'));
6072
+ const depth = Math.min(3, open.length);
6073
+ if (depth) homeVeil.style.setProperty('--desk-depth', String(depth)); else homeVeil.style.removeProperty('--desk-depth');
6074
+ root.classList.toggle('desk-behind', depth > 0);
6075
+ }
6076
+ let homeDepthFrame = 0;
6077
+ const scheduleHomeDepth = () => { cancelAnimationFrame(homeDepthFrame); homeDepthFrame = requestAnimationFrame(paintHomeDepth); };
6078
+ if (typeof MutationObserver === 'function') {
6079
+ // A window opened, closed, shown or put away, by whatever road.
6080
+ new MutationObserver(scheduleHomeDepth).observe(document.body, { subtree: true, childList: true, attributes: true, attributeFilter: ['hidden', 'open'] });
6081
+ document.addEventListener?.('close', scheduleHomeDepth, true);
6082
+ }
6083
+ function homeWindowBox(box, { minW, minH }) {
6084
+ const w = Math.round(Math.max(minW, Math.min(box.w, window.innerWidth - 2 * HOME_WINDOW_INSET)));
6085
+ const h = Math.round(Math.max(minH, Math.min(box.h, window.innerHeight - 2 * HOME_WINDOW_INSET)));
6086
+ // Partly past a side is allowed; the bar always stays in reach, never under the top edge.
6087
+ const x = Math.round(Math.max(120 - w, Math.min(window.innerWidth - 120, box.x)));
6088
+ const y = Math.round(Math.max(HOME_WINDOW_INSET, Math.min(window.innerHeight - 48, box.y)));
6089
+ return { x, y, w, h };
6090
+ }
6091
+ function homeWindow({ root, bar, close, key, minW = 360, minH = 360, keys = true, size = { w: 1040, h: 780 } }) {
6092
+ if (!homeShellOn()) return null;
6093
+ let framed = true;
6094
+ root.classList.add('surface', 'window', 'home-window');
6095
+ scheduleHomeDepth();
6096
+ let kept = null;
6097
+ try { kept = JSON.parse(localStorage.getItem(key) ?? 'null'); } catch { /* no storage */ }
6098
+ const fresh = () => {
6099
+ const w = Math.min(size.w, window.innerWidth - 32);
6100
+ const h = Math.min(size.h, window.innerHeight - 90);
6101
+ return { x: Math.max(16, Math.round((window.innerWidth - w) / 2)), y: 56, w, h };
6102
+ };
6103
+ let want = kept?.w && kept?.h ? kept : fresh();
6104
+ let box = null;
6105
+ const place = (next) => {
6106
+ want = { ...next };
6107
+ box = homeWindowBox(next, { minW, minH });
6108
+ root.style.left = `${box.x}px`;
6109
+ root.style.top = `${box.y}px`;
6110
+ root.style.width = `${box.w}px`;
6111
+ root.style.height = `${box.h}px`;
6112
+ };
6113
+ const remember = () => { try { localStorage.setItem(key, JSON.stringify(box)); } catch { /* as long as the page lasts */ } };
6114
+ place(want);
6115
+ // Its close, at the right of its bar, as every window's (styles.css, .surface-modes, .x-close).
6116
+ const group = el('span', 'surface-modes');
6117
+ const shut = button('surface-mode close x-close x-only', null, () => close());
6118
+ shut.setAttribute('aria-label', t('Close'));
6119
+ shut.innerHTML = `<span class="x-icon">${trazo('close')}</span>`; // trusted: our own SVG
6120
+ group.append(shut);
6121
+ if (keys) bar.append(group);
6122
+ // Carried by its bar, wherever the bar is not a key, a field or a tab.
6123
+ const hold = (handle, change, skip = () => false) => handle.addEventListener('pointerdown', (event) => {
6124
+ if (event.button !== 0 || !framed || skip(event)) return;
6125
+ event.preventDefault();
6126
+ event.stopPropagation();
6127
+ homeWindowForward(root);
6128
+ try { handle.setPointerCapture(event.pointerId); } catch { /* a pointer the page no longer holds */ }
6129
+ const start = { ...box };
6130
+ const from = { x: event.clientX, y: event.clientY };
6131
+ let frame = 0;
6132
+ root.classList.add('moving');
6133
+ const move = (moving) => { cancelAnimationFrame(frame); frame = requestAnimationFrame(() => place(change(start, moving.clientX - from.x, moving.clientY - from.y))); };
6134
+ const finish = () => {
6135
+ cancelAnimationFrame(frame);
6136
+ root.classList.remove('moving');
6137
+ for (const [type, run] of [['pointermove', move], ['pointerup', finish], ['pointercancel', finish], ['lostpointercapture', finish]]) handle.removeEventListener(type, run);
6138
+ remember();
6139
+ };
6140
+ handle.addEventListener('pointermove', move);
6141
+ handle.addEventListener('pointerup', finish);
6142
+ handle.addEventListener('pointercancel', finish);
6143
+ handle.addEventListener('lostpointercapture', finish);
6144
+ });
6145
+ hold(bar, (start, dx, dy) => ({ ...start, x: start.x + dx, y: start.y + dy }), (event) => Boolean(event.target.closest('button, input, label, a, select, textarea, [role="tab"]')));
6146
+ for (const side of ['n', 's', 'e', 'w', 'ne', 'nw', 'se', 'sw']) {
6147
+ const edge = el('div', `win-edge ${side}`);
6148
+ edge.setAttribute('aria-hidden', 'true');
6149
+ root.append(edge);
6150
+ hold(edge, (start, dx, dy) => {
6151
+ const next = { ...start };
6152
+ if (side.includes('e')) next.w = start.w + dx;
6153
+ if (side.includes('s')) next.h = start.h + dy;
6154
+ if (side.includes('w')) { next.w = Math.max(minW, start.w - dx); next.x = start.x + start.w - next.w; }
6155
+ if (side.includes('n')) { next.h = Math.max(minH, start.h - dy); next.y = start.y + start.h - next.h; }
6156
+ return next;
6157
+ });
6158
+ }
6159
+ root.addEventListener('pointerdown', () => { if (framed) homeWindowForward(root); }, true);
6160
+ const refit = () => { if (root.isConnected && framed) place(want); };
6161
+ window.addEventListener('resize', refit);
6162
+ homeWindowForward(root);
6163
+ return {
6164
+ raise: () => homeWindowForward(root),
6165
+ // Another size for now, not kept: a window fitted to what it shows (openHomeAdd).
6166
+ resize: (next) => { if (framed) place({ ...want, ...next }); },
6167
+ drop: () => {
6168
+ window.removeEventListener('resize', refit);
6169
+ const at = homeWindows.indexOf(root);
6170
+ if (at >= 0) homeWindows.splice(at, 1);
6171
+ homeWindows.at(-1)?.classList.add('front');
6172
+ },
6173
+ // Back to the whole screen: the same node, its place and its sides put away.
6174
+ release: () => {
6175
+ framed = false;
6176
+ window.removeEventListener('resize', refit);
6177
+ const at = homeWindows.indexOf(root);
6178
+ if (at >= 0) homeWindows.splice(at, 1);
6179
+ for (const side of ['left', 'top', 'width', 'height', 'z-index']) root.style.removeProperty(side);
6180
+ root.classList.remove('surface', 'window', 'home-window', 'front');
6181
+ scheduleHomeDepth();
6182
+ for (const edge of root.querySelectorAll(':scope > .win-edge')) edge.remove();
6183
+ group.remove();
6184
+ },
6185
+ };
6186
+ }
6187
+ // The bar's keys by family, a hairline between them as in a project (styles.css, .bar-family): the
6188
+ // projects' own — how they connect and their map —, then MADRE's — the Market and the modules —,
6189
+ // then Home's own after its line. The modules wear the project's piece, the same key there and here.
6190
+ function arrangeHomeBar() {
6191
+ const links = $('sm-tb-links');
6192
+ const market = $('sm-tb-market');
6193
+ const modules = $('sm-tb-modules');
6194
+ if (!links || !market || !modules) return;
6195
+ links.after(ui.macro);
6196
+ const line = el('span', 'sm-family');
6197
+ line.setAttribute('aria-hidden', 'true');
6198
+ market.before(line);
6199
+ modules.querySelector('svg')?.replaceWith(Object.assign(document.createElement('span'), { innerHTML: MODULES_GLYPH }).firstElementChild);
6200
+ // The map keeps its own key (salas-mac.html): since Trazo MADRE (2026-10-28) it is the planet with
6201
+ // its ring, as in the side panel, and its moons still go round while the pointer stays.
6202
+ }
6203
+ const MODULES_GLYPH = trazo('puzzle');
6204
+
6205
+ buildHomeShell();
6206
+ // «En marcha» (2026-10-30): the same key and panel as in a project (public/activity.js). Home's own
6207
+ // conversations are the Coordinator's, on this room's page.
6208
+ {
6209
+ const key = $('sm-tb-activity');
6210
+ const words = key?.querySelector(':scope > span');
6211
+ if (words) words.textContent = t('Running now');
6212
+ if (key) mountActivity({ key, badge: $('sm-tb-activity-count'), openChat: ({ chat, messageId }) => { location.href = `/#chat=${encodeURIComponent(chat)}${messageId ? `:${encodeURIComponent(messageId)}` : ''}`; }, toast: (said) => toast(said) });
4886
6213
  }
4887
6214
 
4888
6215
  translateStatic();
@@ -4918,8 +6245,9 @@ void loadAgents();
4918
6245
  void loadVersion();
4919
6246
  void loadWork();
4920
6247
  void loadDecisions();
4921
- // `#welcome`: the first-run wizard again, on purpose (to connect an agent or add projects in steps).
4922
- if (location.hash === '#welcome') { history.replaceState(null, '', location.pathname); welcomed = true; openWizard(); }
6248
+ void loadReminders({ opening: true });
6249
+ // `#welcome`: the welcome again, on purpose (to connect an agent or add projects in steps).
6250
+ if (location.hash === '#welcome') { history.replaceState(null, '', location.pathname); openHomeWelcome(); }
4923
6251
  // Sent here for the Macroverso (the key in BISHOP's room): straight into it, on a large screen.
4924
6252
  if (location.hash === '#macroverso' && data && !ui.macro.hidden) { history.replaceState(null, '', location.pathname); ui.macro.click(); }
4925
6253
  // Sent here for the Market (a project's MODULES, or a module offered in the conversation): straight in,
@@ -4927,10 +6255,12 @@ if (location.hash === '#macroverso' && data && !ui.macro.hidden) { history.repla
4927
6255
  // The Market's addresses: #mercado, #mercado=<module>, #modulos.
4928
6256
  if (/^#mercado(=|$)/.test(location.hash)) openHomeMarket('shop', decodeURIComponent(location.hash.split('=')[1] ?? '') || null);
4929
6257
  else if (location.hash === '#modulos') openHomeMarket('mine');
4930
- timer = setInterval(() => { if (!document.hidden && !busy.size && !pins.dropping && !pins.drag) void refresh(); }, 4000);
6258
+ timer = setInterval(() => { if (!document.hidden && !busy.size && !pins.dropping && !pins.drag) void refresh({ polled: true }); }, 4000);
4931
6259
  document.addEventListener('visibilitychange', () => { if (!document.hidden) { void refresh(); void loadAgents(); void loadWork(); void loadDecisions(); } });
4932
6260
  // The decisions are asked again every few minutes (the route itself asks the rooms no oftener).
4933
6261
  setInterval(() => { if (!document.hidden) void loadDecisions(); }, 5 * 60 * 1000);
6262
+ // A reminder comes due while Home is open: looked at every minute.
6263
+ setInterval(() => { if (!document.hidden) void loadReminders(); }, 60 * 1000);
4934
6264
 
4935
6265
  // Asking for a star or a review (review-ask.js), when Home is quiet: nothing waking or closing,
4936
6266
  // the bar not being arranged.