fsanyoto commited on
Commit
a9ff272
·
verified ·
1 Parent(s): a596902

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "current": "33c1374dd",
3
  "releases": []
4
  }
 
1
  {
2
+ "current": "91ce7adc",
3
  "releases": []
4
  }
VERSION CHANGED
@@ -1 +1 @@
1
- 33c1374dd
 
1
+ 91ce7adc
api/assistant_feed.py CHANGED
@@ -113,7 +113,7 @@ def post(rt, username, item):
113
  subject = ai_enrich.no_dashes(item.get("alertLabel") or item.get("label") or "Notice")
114
  body = ai_enrich.no_dashes(item.get("label") or "")
115
  source = str(item.get("topic") or "alert")
116
- fallback = {"automation": "Agents", "share": "A teammate"}.get(source, "Alerts")
117
  sender = ai_enrich.no_dashes(item.get("actor") or fallback)
118
  target = _target(item)
119
  inbox = item.get("inbox") if isinstance(item.get("inbox"), dict) else None
 
113
  subject = ai_enrich.no_dashes(item.get("alertLabel") or item.get("label") or "Notice")
114
  body = ai_enrich.no_dashes(item.get("label") or "")
115
  source = str(item.get("topic") or "alert")
116
+ fallback = {"automation": "Recurring", "share": "A teammate"}.get(source, "Alerts")
117
  sender = ai_enrich.no_dashes(item.get("actor") or fallback)
118
  target = _target(item)
119
  inbox = item.get("inbox") if isinstance(item.get("inbox"), dict) else None
api/intelligence_store.py CHANGED
@@ -66,7 +66,7 @@ def normalize_section(value):
66
  for key, label in SECTIONS.items():
67
  if text in (key, label.casefold()):
68
  return key
69
- raise IntelligenceError("bad_section", "Choose one of the six Brain sections.")
70
 
71
 
72
  def normalize_path(value, *, folder=False):
@@ -528,8 +528,10 @@ def _file(record, entry=None, *, session=None):
528
  "latestVersion": _head(record)["version"], "history": history, "limits": limits()}
529
 
530
 
531
- def list_files(session, *, section="", query="", folder="", offset=0, limit=100):
532
- """List or search readable titles and descriptions with section, folder and page filters."""
 
 
533
  _authorize(session)
534
  selected = normalize_section(section) if section else ""
535
  prefix = normalize_path(folder, folder=True) + "/" if folder else ""
@@ -551,6 +553,8 @@ def list_files(session, *, section="", query="", folder="", offset=0, limit=100)
551
  rows.append(row)
552
  folders = sorted({"/".join(row["path"].split("/")[:i]) for row in rows
553
  for i in range(1, len(row["path"].split("/")))})
 
 
554
  return {"files": rows[offset:offset + limit], "total": len(rows), "offset": offset,
555
  "limit": limit, "sections": sections(), "folders": folders, "limits": limits()}
556
 
 
66
  for key, label in SECTIONS.items():
67
  if text in (key, label.casefold()):
68
  return key
69
+ raise IntelligenceError("bad_section", "This Brain file has an unknown section.")
70
 
71
 
72
  def normalize_path(value, *, folder=False):
 
528
  "latestVersion": _head(record)["version"], "history": history, "limits": limits()}
529
 
530
 
531
+ def list_files(session, *, section="", query="", folder="", offset=0, limit=100, direct=False):
532
+ """List or search readable titles and descriptions with section, folder and page filters.
533
+
534
+ `direct` lists only files directly in `folder`; `folders` still names every folder below it."""
535
  _authorize(session)
536
  selected = normalize_section(section) if section else ""
537
  prefix = normalize_path(folder, folder=True) + "/" if folder else ""
 
553
  rows.append(row)
554
  folders = sorted({"/".join(row["path"].split("/")[:i]) for row in rows
555
  for i in range(1, len(row["path"].split("/")))})
556
+ if direct:
557
+ rows = [row for row in rows if "/" not in row["path"][len(prefix):]]
558
  return {"files": rows[offset:offset + limit], "total": len(rows), "offset": offset,
559
  "limit": limit, "sections": sections(), "folders": folders, "limits": limits()}
560
 
api/routes_agent_harness.py CHANGED
@@ -78,6 +78,7 @@ def activity_read_policy(session: Session, object):
78
  @router.get("/intelligence/files", dependencies=[Depends(_intelligence_no_cache)])
79
  def get_intelligence_files(path: str = "", section: str = "", version: int = 0,
80
  q: str = "", folder: str = "", offset: int = 0, limit: int = 100,
 
81
  session: Session = Depends(module_gate("intelligence"))):
82
  """List a workspace section, search, or read one current or historical Markdown file."""
83
  import intelligence_store as intelligence
@@ -86,7 +87,7 @@ def get_intelligence_files(path: str = "", section: str = "", version: int = 0,
86
  if path:
87
  return intelligence.read_file(session, path, version=version)
88
  return intelligence.list_files(session, section=section, query=q, folder=folder,
89
- offset=offset, limit=limit)
90
  except intelligence.IntelligenceError as exc:
91
  raise _intelligence_error(exc) from None
92
 
 
78
  @router.get("/intelligence/files", dependencies=[Depends(_intelligence_no_cache)])
79
  def get_intelligence_files(path: str = "", section: str = "", version: int = 0,
80
  q: str = "", folder: str = "", offset: int = 0, limit: int = 100,
81
+ direct: bool = False,
82
  session: Session = Depends(module_gate("intelligence"))):
83
  """List a workspace section, search, or read one current or historical Markdown file."""
84
  import intelligence_store as intelligence
 
87
  if path:
88
  return intelligence.read_file(session, path, version=version)
89
  return intelligence.list_files(session, section=section, query=q, folder=folder,
90
+ offset=offset, limit=limit, direct=direct)
91
  except intelligence.IntelligenceError as exc:
92
  raise _intelligence_error(exc) from None
93
 
api/routes_module_index.py CHANGED
@@ -44,7 +44,7 @@ def _access(module: str, session: Session = Depends(require_session)):
44
  except HTTPException as exc:
45
  if exc.status_code != 403:
46
  raise
47
- raise err(403, "forbidden", "Your account or workspace does not have access to Agents (automation).")
48
  return session
49
 
50
 
 
44
  except HTTPException as exc:
45
  if exc.status_code != 403:
46
  raise
47
+ raise err(403, "forbidden", "Your account or workspace does not have access to Recurring.")
48
  return session
49
 
50
 
api/routes_templates.py CHANGED
@@ -82,7 +82,7 @@ def list_templates(table: str = "", session: Session = Depends(require_session),
82
  """
83
  if module:
84
  if module not in ("sheet", "data", "app", "agents"):
85
- raise err(400, "unknown_module", "Choose Sheet, Record, App or Agents.")
86
  return _module_templates(session)
87
  fields, source = _target_or_refuse(session, table)
88
  vt = _templates()
 
82
  """
83
  if module:
84
  if module not in ("sheet", "data", "app", "agents"):
85
+ raise err(400, "unknown_module", "Choose Sheet, Record, App or Recurring.")
86
  return _module_templates(session)
87
  fields, source = _target_or_refuse(session, table)
88
  vt = _templates()
platform/core/registry.py CHANGED
@@ -203,25 +203,18 @@ REGISTRY = [
203
  'proof). No nav, no page. Wave 17 R8 ("I don\'t even know what it does. Delete '
204
  'them") made that literal: `validate_only` takes it out of the account menu too, '
205
  'which is the last place it was still visible. The proof survives; the door does not.'},
206
- # S67-T36 (owner instr 24, R25, 2026-09-28): Agents is TABLED. `archived` hides the UI only:
207
- # no rail row, no Settings module toggle, no Home section, no agent templates. The
208
- # `/automations` APIs, stored automations and their schedules are untouched and keep running.
209
- # ⭐ RESTORING IS THIS ONE LINE: delete `'archived': True` below and every door comes back.
210
- {'key': 'automation', 'label': 'Agents', 'brand': False, 'hq': True, 'validate': False,
211
- 'archived': True,
212
  'nav': True,
213
  'note': 'Wave 18 (C-AUTONAV): scheduled jobs that create and refresh user databases '
214
  '(website scrape-to-DB, the Instagram field). React-only surface (no PAGE_FUNCS '
215
  'entry, the no-new-Streamlit rule); admins hold it via "all", other users need the '
216
  'explicit grant, fail-closed default. '
217
- '⭐ WAVE 34 · R12. THE LABEL IS "Agents" AND THE KEY IS STILL `automation`. The '
218
- 'owner ruled the module becomes Agent: this is our agent deployment surface going '
219
- 'forward. Only the LABEL moved, because the key is a permission scope, a nav '
220
- 'placement key, a grant name and the `#/automation` route; renaming it would revoke '
221
- 'every stored grant and 404 every bookmark to buy a caption. ⚠ The plural is not a '
222
- 'slip: R15 and the wave PRD both spell the rail row "Agents", and the degraded '
223
- 'fallback row in Shell.tsx hard-codes that spelling, so a singular here would paint '
224
- 'two different words in one list depending on whether /nav answered.'},
225
  {'key': 'settings', 'label': 'Settings', 'brand': False, 'hq': True, 'validate': False,
226
  'nav': False, # sidebar sentinel (account group) — owner IA 2026-07-12
227
  'note': 'User scope settings: the Business Unit toggle (strict isolation) and the Data basis '
 
203
  'proof). No nav, no page. Wave 17 R8 ("I don\'t even know what it does. Delete '
204
  'them") made that literal: `validate_only` takes it out of the account menu too, '
205
  'which is the last place it was still visible. The proof survives; the door does not.'},
206
+ # Recurring is a live module, never archived: owner 2026-10-12, "we need to reappear the Agents module" and "rename Agent module to "Recurring"".
207
+ {'key': 'automation', 'label': 'Recurring', 'brand': False, 'hq': True, 'validate': False,
 
 
 
 
208
  'nav': True,
209
  'note': 'Wave 18 (C-AUTONAV): scheduled jobs that create and refresh user databases '
210
  '(website scrape-to-DB, the Instagram field). React-only surface (no PAGE_FUNCS '
211
  'entry, the no-new-Streamlit rule); admins hold it via "all", other users need the '
212
  'explicit grant, fail-closed default. '
213
+ 'THE LABEL IS "Recurring" AND THE KEY IS STILL `automation` (owner 2026-10-12). '
214
+ 'Only the LABEL moves, because the key is a permission scope, a nav placement key, '
215
+ 'a grant name and the `#/automation` route; renaming it would revoke every stored '
216
+ 'grant and 404 every bookmark. The degraded fallback row in Shell.tsx spells the '
217
+ 'same word, so the rail paints one label whether or not /nav answered.'},
 
 
 
218
  {'key': 'settings', 'label': 'Settings', 'brand': False, 'hq': True, 'validate': False,
219
  'nav': False, # sidebar sentinel (account group) — owner IA 2026-07-12
220
  'note': 'User scope settings: the Business Unit toggle (strict isolation) and the Data basis '
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- 14b137fda99bab49433598f7f8fa501bb6d5b4f0e4d389814bc20f8ab0bf435e
 
1
+ 2f32469f75aae44da59ed49c9df858a825b3ba801b5a47b1f3cebfe3d8f18a91
web/scripts/node_register.cjs ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // The ONE CommonJS register for a node test that loads app source (W-8547).
2
+ // node -r ./scripts/node_register.cjs <runner.cjs> or require("./scripts/node_register.cjs")
3
+ // A bare node loads no `src/customer-grid/*.tsx`. This makes three things loadable:
4
+ // .ts/.tsx transpiled by the project's own typescript (react-jsx, CommonJS); `import.meta` gets the
5
+ // D-312 stand-in, or node re-reads the module as ESM ("exports is not defined").
6
+ // .css an empty module: Vite bundles stylesheets, and node parses one as JavaScript.
7
+ // cjs .js a dependency that ships its CommonJS build as `.js` in a "type": "module" package
8
+ // (glide-data-grid `dist/cjs/`, phosphor-icons `dist/index.cjs.js`): node reads that build
9
+ // as ESM ("exports is not defined in ES module scope"). It is compiled as CommonJS.
10
+ // Proved by `python aios-web/web/_gate_node.py --selftest`.
11
+ "use strict";
12
+ const fs = require("fs");
13
+ const Module = require("module");
14
+
15
+ const META_STANDIN = '({ env: { BASE_URL: "/", MODE: "test", DEV: false, PROD: true, SSR: true }, '
16
+ + 'url: require("url").pathToFileURL(__filename).href, glob: () => ({}) })'; // glob: a Vite build feature
17
+ const CJS_AS_JS = /[\\/]node_modules[\\/](?:.*[\\/]cjs[\\/].*|.*\.cjs)\.js$/;
18
+
19
+ let ts = null;
20
+ function transpile(source, filename) {
21
+ ts = ts || require("typescript"); // lazy: a runner that loads no .ts needs no node_modules
22
+ const out = ts.transpileModule(source, { fileName: filename, compilerOptions: {
23
+ module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022, jsx: ts.JsxEmit.ReactJSX,
24
+ esModuleInterop: true } }).outputText;
25
+ return out.replace(/\bimport\.meta\b/g, META_STANDIN);
26
+ }
27
+
28
+ for (const ext of [".ts", ".tsx"]) {
29
+ Module._extensions[ext] = (mod, filename) =>
30
+ mod._compile(transpile(fs.readFileSync(filename, "utf8"), filename), filename, "commonjs");
31
+ }
32
+
33
+ Module._extensions[".css"] = () => {};
34
+
35
+ const loadJs = Module._extensions[".js"];
36
+ Module._extensions[".js"] = (mod, filename) => CJS_AS_JS.test(filename)
37
+ ? mod._compile(fs.readFileSync(filename, "utf8"), filename, "commonjs")
38
+ : loadJs(mod, filename);
web/src/artifacts/ArtifactsPage.tsx CHANGED
@@ -7,6 +7,7 @@ import type { NavEntry } from "../shell/nav";
7
  import { QueryRail, queryGroups } from "../query/queryParts";
8
  import { call, deleteArtifact, fetchArtifacts, fetchQueries, pauseArtifact, resumeArtifact, runArtifact } from "../query/queryApi";
9
  import type { ArtifactPendingDelete, ArtifactTurnResult, SavedQuery } from "../query/queryApi";
 
10
  import WorklistTable, { worklistFigure } from "./WorklistTable";
11
  import { ARTIFACT_UNAVAILABLE, artifactFileHref, fetchWorklist, safeWorklistLink, worklistText } from "./worklistApi";
12
  import type { Artifact, WorklistPage } from "./worklistApi";
@@ -359,7 +360,7 @@ export default function ArtifactsPage({ granted }: { granted: NavEntry[] }) {
359
 
360
  return <div className="ar-page">
361
  <aside className="ar-list" aria-label="Artifacts">
362
- <h1 className="ar-heading">Artifacts</h1>
363
  <div className="ar-list-scroll">
364
  {showDefaultNote ? <div className="ar-list-item">
365
  <div className="ar-row ar-selected ar-default-row" aria-current="true">
 
7
  import { QueryRail, queryGroups } from "../query/queryParts";
8
  import { call, deleteArtifact, fetchArtifacts, fetchQueries, pauseArtifact, resumeArtifact, runArtifact } from "../query/queryApi";
9
  import type { ArtifactPendingDelete, ArtifactTurnResult, SavedQuery } from "../query/queryApi";
10
+ import { ModuleHomeHead } from "../home/ModuleHomeHead";
11
  import WorklistTable, { worklistFigure } from "./WorklistTable";
12
  import { ARTIFACT_UNAVAILABLE, artifactFileHref, fetchWorklist, safeWorklistLink, worklistText } from "./worklistApi";
13
  import type { Artifact, WorklistPage } from "./worklistApi";
 
360
 
361
  return <div className="ar-page">
362
  <aside className="ar-list" aria-label="Artifacts">
363
+ <ModuleHomeHead title="Artifacts" module="artifacts" className="ar-head" />
364
  <div className="ar-list-scroll">
365
  {showDefaultNote ? <div className="ar-list-item">
366
  <div className="ar-row ar-selected ar-default-row" aria-current="true">
web/src/artifacts/artifacts.css CHANGED
@@ -1,6 +1,6 @@
1
  .ar-page { position: relative; display: flex; min-width: 0; max-width: 100%; min-height: 0; height: 100%; overflow-x: hidden; color: var(--lp-ink); background: var(--lp-surface); font-size: var(--lp-fs-sm); line-height: var(--lp-lh); }
2
  .ar-list { flex: 0 0 var(--lp-rail-w); width: var(--lp-rail-w); min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--lp-line); }
3
- .ar-heading { margin: 0; padding: 16px 12px; font-size: var(--lp-fs-lg); font-weight: var(--lp-fw-semibold); }
4
  .ar-list-scroll { overflow-y: auto; min-height: 0; padding: 0 8px 12px; scrollbar-gutter: stable; }
5
  .ar-list-item { padding: 8px 0; border-bottom: 1px solid var(--lp-line); }
6
  .ar-query-row { padding: 8px 4px 0 0; }
 
1
  .ar-page { position: relative; display: flex; min-width: 0; max-width: 100%; min-height: 0; height: 100%; overflow-x: hidden; color: var(--lp-ink); background: var(--lp-surface); font-size: var(--lp-fs-sm); line-height: var(--lp-lh); }
2
  .ar-list { flex: 0 0 var(--lp-rail-w); width: var(--lp-rail-w); min-width: 0; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--lp-line); }
3
+ .ar-list .ar-head { display: block; margin: 0; padding: 16px 12px; }
4
  .ar-list-scroll { overflow-y: auto; min-height: 0; padding: 0 8px 12px; scrollbar-gutter: stable; }
5
  .ar-list-item { padding: 8px 0; border-bottom: 1px solid var(--lp-line); }
6
  .ar-query-row { padding: 8px 4px 0 0; }
web/src/assistant/AssistantPage.tsx CHANGED
@@ -24,6 +24,7 @@ import { stopTurn, submitChat } from "./turnClient";
24
  import { SuggestionChips } from "./SuggestionChips";
25
  import { takePendingAsk } from "./askPending";
26
  import { MemoryPanel } from "./MemoryPanel";
 
27
  import {
28
  addressFromHash, interceptOpen, LinkedText, LOAD_FAILED, NOT_AVAILABLE, OpenInPlaceContext, OpenInPlaceHost,
29
  useOpenInPlace,
@@ -1238,6 +1239,7 @@ export default function AssistantPage({ granted }: AssistantPageProps) {
1238
  <div className="as-stream" ref={streamRef} onScroll={onConversationScroll}
1239
  aria-busy={conversationLoading}>
1240
  <div className="as-column">
 
1241
  <div className={`as-skeleton${conversationLoading ? "" : " as-skeleton--idle"}`}
1242
  role={conversationLoading ? "status" : undefined} aria-hidden={!conversationLoading}
1243
  aria-label={conversationLoading ? "Loading conversation" : undefined} />
 
24
  import { SuggestionChips } from "./SuggestionChips";
25
  import { takePendingAsk } from "./askPending";
26
  import { MemoryPanel } from "./MemoryPanel";
27
+ import { ModuleHomeHead } from "../home/ModuleHomeHead";
28
  import {
29
  addressFromHash, interceptOpen, LinkedText, LOAD_FAILED, NOT_AVAILABLE, OpenInPlaceContext, OpenInPlaceHost,
30
  useOpenInPlace,
 
1239
  <div className="as-stream" ref={streamRef} onScroll={onConversationScroll}
1240
  aria-busy={conversationLoading}>
1241
  <div className="as-column">
1242
+ {empty && conversationLoaded ? <ModuleHomeHead title="Assistant" module="assistant" /> : null}
1243
  <div className={`as-skeleton${conversationLoading ? "" : " as-skeleton--idle"}`}
1244
  role={conversationLoading ? "status" : undefined} aria-hidden={!conversationLoading}
1245
  aria-label={conversationLoading ? "Loading conversation" : undefined} />
web/src/automation/AutomationSurface.tsx CHANGED
@@ -623,7 +623,7 @@ export default function AutomationSurface() {
623
  /* ⭐ WAVE 34 · R12 — an aria-label IS user-facing copy. A screen reader announces this
624
  landmark by name, so leaving it "Automations" would have the module answer to two
625
  different words depending on how you read the page. */
626
- aria-label="Agents"
627
  >
628
  {/* The same three-bars fold control the Views rail carries — the two rails are
629
  one idea, so they must not fold with two different affordances. */}
 
623
  /* ⭐ WAVE 34 · R12 — an aria-label IS user-facing copy. A screen reader announces this
624
  landmark by name, so leaving it "Automations" would have the module answer to two
625
  different words depending on how you read the page. */
626
+ aria-label="Recurring"
627
  >
628
  {/* The same three-bars fold control the Views rail carries — the two rails are
629
  one idea, so they must not fold with two different affordances. */}
web/src/connectors/ConnectorsPage.tsx CHANGED
@@ -36,6 +36,7 @@ import WhatsAppSenderTabs from "./WhatsAppSenderTabs";
36
  import SlackSection from "../settings/channels/SlackSection";
37
  import { API_V1, CREDENTIALS, UNAUTHORIZED_EVENT, checkTenant } from "../apiContract";
38
  import { brandForConnector } from "./brandMarks";
 
39
  import ConnectorModal from "./ConnectorModal";
40
  import LoginsPanel from "./LoginsPanel";
41
  import LoopableApiTabs from "./LoopableApiTabs";
@@ -888,7 +889,7 @@ export default function ConnectorsPage({
888
 
889
  return (
890
  <div className="shell-conn conn-directory">
891
- <h1 className="conn-title">Connectors</h1>
892
 
893
  {load.phase === "loading" ? (
894
  <div className="shell-loading">
 
36
  import SlackSection from "../settings/channels/SlackSection";
37
  import { API_V1, CREDENTIALS, UNAUTHORIZED_EVENT, checkTenant } from "../apiContract";
38
  import { brandForConnector } from "./brandMarks";
39
+ import { ModuleHomeHead } from "../home/ModuleHomeHead";
40
  import ConnectorModal from "./ConnectorModal";
41
  import LoginsPanel from "./LoginsPanel";
42
  import LoopableApiTabs from "./LoopableApiTabs";
 
889
 
890
  return (
891
  <div className="shell-conn conn-directory">
892
+ <ModuleHomeHead title="Connectors" module="connectors" />
893
 
894
  {load.phase === "loading" ? (
895
  <div className="shell-loading">
web/src/connectors/connectors.css CHANGED
@@ -8,6 +8,11 @@
8
  margin-bottom: calc(var(--lp-r-sm) * 3);
9
  }
10
 
 
 
 
 
 
11
  .conn-directory .conn-tier-subtitle {
12
  margin: calc(var(--lp-r-sm) * -2) 0 calc(var(--lp-r-sm) * 4);
13
  color: var(--lp-muted);
 
8
  margin-bottom: calc(var(--lp-r-sm) * 3);
9
  }
10
 
11
+ /* The shared module head keeps the old title's 16px gap above the directory. */
12
+ .conn-directory > .home-page-head {
13
+ margin-bottom: calc(var(--lp-r-sm) * 4);
14
+ }
15
+
16
  .conn-directory .conn-tier-subtitle {
17
  margin: calc(var(--lp-r-sm) * -2) 0 calc(var(--lp-r-sm) * 4);
18
  color: var(--lp-muted);
web/src/home/HomePage.tsx CHANGED
@@ -30,6 +30,7 @@ import { AnchoredOverlay, BodyPortal, useOverlayLayer } from "../customer-grid/O
30
  import { GridPager } from "../customer-grid/GridPager";
31
  import DatabaseTile from "./DatabaseTile";
32
  import FolderNameDialog from "./FolderNameDialog";
 
33
  import HomeFind, { HomeFindFolder, homeFindDataStamps, homeFindFolderName, homeOpenedTileId, useHomeFind } from "./HomeFind";
34
  import { matchTiles, sortTiles } from "./homeFind";
35
  import type { HomeFindTile } from "./homeFind";
@@ -233,7 +234,7 @@ function OriginMark({ connector }: { connector: string | null }) {
233
  }
234
 
235
  /** The two layout marks: rows, and a 2x2 of tiles. The reference pair, in our stroke weight. */
236
- function ListIcon() {
237
  return (
238
  <svg viewBox="0 0 16 16" aria-hidden="true" className="home-layout-icon">
239
  <path d="M2.6 4.4h10.8M2.6 8h10.8M2.6 11.6h10.8" />
@@ -241,7 +242,7 @@ function ListIcon() {
241
  );
242
  }
243
 
244
- function GridIcon() {
245
  return (
246
  <svg viewBox="0 0 16 16" aria-hidden="true" className="home-layout-icon">
247
  <rect x="2.5" y="2.5" width="4.6" height="4.6" rx="1" />
@@ -444,7 +445,7 @@ function AppDeleteDialog({ application, onDelete, onCancel }: {
444
  * `<button>` sets `border/background/font/color` in its base rule, or it leaks the user agent's
445
  * chrome — the wave-19 item-3 "mystery outer lines and tinted fill").
446
  */
447
- function QuickCard({
448
  icon,
449
  title,
450
  detail,
@@ -1104,9 +1105,7 @@ export function HomeSurface({
1104
 
1105
  return (
1106
  <div className="shell-home">
1107
- <div className="home-page-head">
1108
- <h1 className="home-title">{moduleName}</h1>
1109
- </div>
1110
 
1111
  {mode === "home" ? <>
1112
  {databases.length === 0 ? <p className="home-empty">No databases are shared with your account yet.</p> : null}
 
30
  import { GridPager } from "../customer-grid/GridPager";
31
  import DatabaseTile from "./DatabaseTile";
32
  import FolderNameDialog from "./FolderNameDialog";
33
+ import { ModuleHomeHead } from "./ModuleHomeHead";
34
  import HomeFind, { HomeFindFolder, homeFindDataStamps, homeFindFolderName, homeOpenedTileId, useHomeFind } from "./HomeFind";
35
  import { matchTiles, sortTiles } from "./homeFind";
36
  import type { HomeFindTile } from "./homeFind";
 
234
  }
235
 
236
  /** The two layout marks: rows, and a 2x2 of tiles. The reference pair, in our stroke weight. */
237
+ export function ListIcon() {
238
  return (
239
  <svg viewBox="0 0 16 16" aria-hidden="true" className="home-layout-icon">
240
  <path d="M2.6 4.4h10.8M2.6 8h10.8M2.6 11.6h10.8" />
 
242
  );
243
  }
244
 
245
+ export function GridIcon() {
246
  return (
247
  <svg viewBox="0 0 16 16" aria-hidden="true" className="home-layout-icon">
248
  <rect x="2.5" y="2.5" width="4.6" height="4.6" rx="1" />
 
445
  * `<button>` sets `border/background/font/color` in its base rule, or it leaks the user agent's
446
  * chrome — the wave-19 item-3 "mystery outer lines and tinted fill").
447
  */
448
+ export function QuickCard({
449
  icon,
450
  title,
451
  detail,
 
1105
 
1106
  return (
1107
  <div className="shell-home">
1108
+ <ModuleHomeHead title={moduleName} module={mode === "agents" ? "automation" : mode === "home" ? undefined : mode} />
 
 
1109
 
1110
  {mode === "home" ? <>
1111
  {databases.length === 0 ? <p className="home-empty">No databases are shared with your account yet.</p> : null}
web/src/home/ModuleHomeHead.tsx ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /** The one subtitle per module home, keyed by route key: a few plain words, no full stop, no dash. */
2
+ export const MODULE_SUBTITLES = {
3
+ intelligence: "What your workspace knows",
4
+ data: "Every database in one place",
5
+ sheet: "Workbooks on live data",
6
+ app: "Apps built on your data",
7
+ automation: "Work that runs for you",
8
+ artifacts: "What the assistant made",
9
+ assistant: "Ask about your data",
10
+ connectors: "Connect your tools and data",
11
+ } as const;
12
+
13
+ export type ModuleSubtitleKey = keyof typeof MODULE_SUBTITLES;
14
+
15
+ /** The module home title row: one h1 and the module's subtitle from MODULE_SUBTITLES. */
16
+ export function ModuleHomeHead({ title, module, className }: {
17
+ title: string; module?: ModuleSubtitleKey; className?: string;
18
+ }) {
19
+ const subtitle = module ? MODULE_SUBTITLES[module] : undefined;
20
+ return <div className={className ? "home-page-head " + className : "home-page-head"}>
21
+ <div className="home-page-head-text">
22
+ <h1 className="home-title">{title}</h1>
23
+ {subtitle ? <p className="home-subtitle">{subtitle}</p> : null}
24
+ </div>
25
+ </div>;
26
+ }
27
+
28
+ export default ModuleHomeHead;
web/src/home/TemplatePicker.tsx CHANGED
@@ -6,7 +6,7 @@ import { createPickerTemplate, fetchTemplateSections, OPEN_APP_TEMPLATE_EVENT }
6
  import type { PickerTemplate, TemplateModule, TemplateSection } from "../sheet/templates/templatesApi";
7
  import "../styles/wave59/templates.css";
8
 
9
- const labels: Record<TemplateModule, string> = { sheet: "Sheet", data: "Record", app: "App", agents: "Agents" };
10
  const baseModules = ["sheet", "data", "app"] as const;
11
  const moduleOrder: TemplateModule[] = [...baseModules, "agents"];
12
  const connectorLabels: Record<string, string> = { odoo: "Odoo", amazon_sp: "Amazon", instagram: "Instagram" };
 
6
  import type { PickerTemplate, TemplateModule, TemplateSection } from "../sheet/templates/templatesApi";
7
  import "../styles/wave59/templates.css";
8
 
9
+ const labels: Record<TemplateModule, string> = { sheet: "Sheet", data: "Record", app: "App", agents: "Recurring" };
10
  const baseModules = ["sheet", "data", "app"] as const;
11
  const moduleOrder: TemplateModule[] = [...baseModules, "agents"];
12
  const connectorLabels: Record<string, string> = { odoo: "Odoo", amazon_sp: "Amazon", instagram: "Instagram" };
web/src/intelligence/FileView.tsx CHANGED
@@ -2,9 +2,7 @@ import { Fragment, createElement, useCallback, useEffect, useId, useMemo, useRef
2
  import type { ReactNode } from "react";
3
  // @ts-expect-error TS7016: Frozen marked 4.3.0 has no declarations; its consumed API is typed below.
4
  import { marked as untypedMarked } from "marked";
5
- import { X } from "@phosphor-icons/react";
6
- import { BodyPortal, useOverlayLayer } from "../customer-grid/OverlaySurface";
7
- import { fileDate, IntelligenceApiError, intelligenceProblem, sectionLabel } from "./intelligenceApi";
8
  import type { IntelligenceApi, IntelligenceFile, IntelligenceProposal } from "./intelligenceApi";
9
  import PromptView from "./PromptView";
10
  import Proposals from "./Proposals";
@@ -69,7 +67,7 @@ export function FileMarkdown({ body }: { body: string }) {
69
  export default function FileView({ path, api, onClose, initialHistory = false, onChanged }: {
70
  path: string; api: IntelligenceApi; onClose: () => void; initialHistory?: boolean; onChanged?: () => void;
71
  }) {
72
- const panelRef = useRef<HTMLElement>(null);
73
  const titleId = useId();
74
  const [file, setFile] = useState<IntelligenceFile | null>(null);
75
  const [problem, setProblem] = useState("");
@@ -89,8 +87,8 @@ export default function FileView({ path, api, onClose, initialHistory = false, o
89
  }, [api, path, retry]);
90
  const newProposal = admission?.api === api && admission.path === path && admission.retry === retry
91
  ? admission.proposal : null;
92
- useOverlayLayer({ panelRef, onDismiss: () => { if (!restoring.current) onClose(); }, dismissOnOutside: false,
93
- initialFocus: "[data-file-close]", restoreFocus: true, trapFocus: true });
94
  useEffect(() => {
95
  const abort = new AbortController();
96
  readRequest.current = abort;
@@ -111,14 +109,16 @@ export default function FileView({ path, api, onClose, initialHistory = false, o
111
  setFile(value); setProblem(""); setMissingFile(false); setLoading(false); onChanged?.();
112
  }
113
 
114
- return <BodyPortal><div className="intelligence-scrim">
115
- <section ref={panelRef} className="intelligence-drawer" role="dialog" aria-modal="true" aria-labelledby={titleId}
116
  data-testid="intelligence-file" aria-busy={loading}>
117
- <header className="intelligence-drawer-head">
118
- <div><p className="intelligence-meta">{file ? sectionLabel(file.section) : "Brain"}</p>
119
- <h2 id={titleId}>{file?.title || newProposal?.title || "File"}</h2></div>
120
- <button type="button" className="intelligence-button intelligence-icon-button" data-file-close
121
- aria-label="Close file" disabled={restoreBusy} onClick={onClose}><X size={20} aria-hidden="true" /></button>
 
 
 
122
  </header>
123
  {loading ? <div className="intelligence-skeleton" role="status" aria-label="Loading file"><span /><span /><span /></div> : null}
124
  {problem && !(missingFile && newProposal) ? <div className="intelligence-feedback" role="alert"><span>{problem}</span>
@@ -141,6 +141,5 @@ export default function FileView({ path, api, onClose, initialHistory = false, o
141
  <time dateTime={file.updated}>{fileDate(file.updated)}</time>
142
  </footer>
143
  </> : null}</>}
144
- </section>
145
- </div></BodyPortal>;
146
  }
 
2
  import type { ReactNode } from "react";
3
  // @ts-expect-error TS7016: Frozen marked 4.3.0 has no declarations; its consumed API is typed below.
4
  import { marked as untypedMarked } from "marked";
5
+ import { fileDate, IntelligenceApiError, intelligenceProblem } from "./intelligenceApi";
 
 
6
  import type { IntelligenceApi, IntelligenceFile, IntelligenceProposal } from "./intelligenceApi";
7
  import PromptView from "./PromptView";
8
  import Proposals from "./Proposals";
 
67
  export default function FileView({ path, api, onClose, initialHistory = false, onChanged }: {
68
  path: string; api: IntelligenceApi; onClose: () => void; initialHistory?: boolean; onChanged?: () => void;
69
  }) {
70
+ const backRef = useRef<HTMLButtonElement>(null);
71
  const titleId = useId();
72
  const [file, setFile] = useState<IntelligenceFile | null>(null);
73
  const [problem, setProblem] = useState("");
 
87
  }, [api, path, retry]);
88
  const newProposal = admission?.api === api && admission.path === path && admission.retry === retry
89
  ? admission.proposal : null;
90
+ // A file is a page: focus lands on Back, the control that returns to the folder.
91
+ useEffect(() => { backRef.current?.focus({ preventScroll: true }); }, []);
92
  useEffect(() => {
93
  const abort = new AbortController();
94
  readRequest.current = abort;
 
109
  setFile(value); setProblem(""); setMissingFile(false); setLoading(false); onChanged?.();
110
  }
111
 
112
+ return <section className="intelligence-file-page" aria-labelledby={titleId}
 
113
  data-testid="intelligence-file" aria-busy={loading}>
114
+ <header className="home-section-head intelligence-file-head">
115
+ <button ref={backRef} type="button" className="cg-btn" data-file-close aria-label="Back" title="Back"
116
+ disabled={restoreBusy} onClick={onClose}>
117
+ <svg viewBox="0 0 16 16" aria-hidden="true" className="home-layout-icon" fill="none" stroke="currentColor">
118
+ <path d="M10 3 5 8l5 5" />
119
+ </svg>
120
+ </button>
121
+ <h1 id={titleId} className="home-title">{file?.title || newProposal?.title || "File"}</h1>
122
  </header>
123
  {loading ? <div className="intelligence-skeleton" role="status" aria-label="Loading file"><span /><span /><span /></div> : null}
124
  {problem && !(missingFile && newProposal) ? <div className="intelligence-feedback" role="alert"><span>{problem}</span>
 
141
  <time dateTime={file.updated}>{fileDate(file.updated)}</time>
142
  </footer>
143
  </> : null}</>}
144
+ </section>;
 
145
  }
web/src/intelligence/Insights.tsx CHANGED
@@ -1,7 +1,18 @@
1
  import { useEffect, useState } from "react";
2
  import { ArrowClockwise } from "@phosphor-icons/react";
3
  import { intelligenceProblem } from "./intelligenceApi";
4
- import type { IntelligenceApi, IntelligenceInsights } from "./intelligenceApi";
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  export default function Insights({ api }: { api: IntelligenceApi }) {
7
  const [data, setData] = useState<IntelligenceInsights | null>(null);
@@ -19,7 +30,7 @@ export default function Insights({ api }: { api: IntelligenceApi }) {
19
  return () => abort.abort();
20
  }, [api, retry]);
21
  return <section className="intelligence-insights" data-testid="intelligence-insights" aria-label="Insights" aria-busy={loading}>
22
- <header className="intelligence-history-heading"><div><h2>Insights</h2><p className="intelligence-meta">Last 30 days</p></div>
23
  <button type="button" className="intelligence-button intelligence-icon-button" aria-label="Refresh insights" disabled={loading}
24
  onClick={() => setRetry((value) => value + 1)}><ArrowClockwise size={18} aria-hidden="true" /></button></header>
25
  {problem ? <div className="intelligence-feedback" role="alert"><span>{problem}</span>
@@ -31,10 +42,10 @@ export default function Insights({ api }: { api: IntelligenceApi }) {
31
  <div><dt>By agent</dt><dd data-testid="intelligence-agent-count">{data.totals.agent.toLocaleString()}</dd></div>
32
  </dl>
33
  {data.activity !== "included" ? <p className="intelligence-meta">{data.activity === "absent" ? "File changes only." : "Other activity unavailable."}</p> : null}
34
- {data.rows.length ? <div className="intelligence-insights-table" tabIndex={0} role="region" aria-label="Changes by person and section">
35
- <table><thead><tr><th scope="col">Person</th><th scope="col">Section</th><th scope="col">By hand</th><th scope="col">By agent</th></tr></thead>
36
- <tbody>{data.rows.map((row) => <tr key={JSON.stringify([row.person, row.section])}>
37
- <th scope="row">{row.person}</th><td>{data.sections.find((entry) => entry.key === row.section)?.label}</td>
38
  <td>{row.hand.toLocaleString()}</td><td>{row.agent.toLocaleString()}</td>
39
  </tr>)}</tbody></table>
40
  </div> : <p className="intelligence-empty">No changes in the last 30 days.</p>}
 
1
  import { useEffect, useState } from "react";
2
  import { ArrowClockwise } from "@phosphor-icons/react";
3
  import { intelligenceProblem } from "./intelligenceApi";
4
+ import type { IntelligenceApi, IntelligenceChangeCount, IntelligenceInsights } from "./intelligenceApi";
5
+
6
+ /** Sum the server's (person, section) rows into one row per person, in first-seen order. */
7
+ function byPerson(rows: IntelligenceChangeCount[]): Array<{ person: string; hand: number; agent: number }> {
8
+ const people = new Map<string, { person: string; hand: number; agent: number }>();
9
+ for (const row of rows) {
10
+ const entry = people.get(row.person) || { person: row.person, hand: 0, agent: 0 };
11
+ entry.hand += row.hand; entry.agent += row.agent;
12
+ people.set(row.person, entry);
13
+ }
14
+ return [...people.values()];
15
+ }
16
 
17
  export default function Insights({ api }: { api: IntelligenceApi }) {
18
  const [data, setData] = useState<IntelligenceInsights | null>(null);
 
30
  return () => abort.abort();
31
  }, [api, retry]);
32
  return <section className="intelligence-insights" data-testid="intelligence-insights" aria-label="Insights" aria-busy={loading}>
33
+ <header className="intelligence-history-heading"><p className="intelligence-meta">Last 30 days</p>
34
  <button type="button" className="intelligence-button intelligence-icon-button" aria-label="Refresh insights" disabled={loading}
35
  onClick={() => setRetry((value) => value + 1)}><ArrowClockwise size={18} aria-hidden="true" /></button></header>
36
  {problem ? <div className="intelligence-feedback" role="alert"><span>{problem}</span>
 
42
  <div><dt>By agent</dt><dd data-testid="intelligence-agent-count">{data.totals.agent.toLocaleString()}</dd></div>
43
  </dl>
44
  {data.activity !== "included" ? <p className="intelligence-meta">{data.activity === "absent" ? "File changes only." : "Other activity unavailable."}</p> : null}
45
+ {data.rows.length ? <div className="intelligence-insights-table" tabIndex={0} role="region" aria-label="Changes by person">
46
+ <table><thead><tr><th scope="col">Person</th><th scope="col">By hand</th><th scope="col">By agent</th></tr></thead>
47
+ <tbody>{byPerson(data.rows).map((row) => <tr key={row.person}>
48
+ <th scope="row">{row.person}</th>
49
  <td>{row.hand.toLocaleString()}</td><td>{row.agent.toLocaleString()}</td>
50
  </tr>)}</tbody></table>
51
  </div> : <p className="intelligence-empty">No changes in the last 30 days.</p>}
web/src/intelligence/IntelligencePage.tsx CHANGED
@@ -1,11 +1,26 @@
1
  import { useEffect, useId, useRef, useState } from "react";
2
  import type { FormEvent } from "react";
3
- import { ArrowClockwise, CaretLeft, CaretRight, FileText, Folder, MagnifyingGlass, Plus, X } from "@phosphor-icons/react";
4
  import { BodyPortal, useOverlayLayer } from "../customer-grid/OverlaySurface";
 
 
 
 
 
 
 
 
 
5
  import FileView from "./FileView";
6
  import Insights from "./Insights";
7
- import { INTELLIGENCE_SECTIONS, IntelligenceApiError, fileDate, intelligenceApi, intelligenceProblem, sectionLabel } from "./intelligenceApi";
8
- import type { IntelligenceApi, IntelligenceFile, IntelligenceList, IntelligenceQuery, IntelligenceSection } from "./intelligenceApi";
 
 
 
 
 
 
9
  import "../styles/sdlc73/intelligence.css";
10
 
11
  export interface IntelligencePageProps {
@@ -16,17 +31,61 @@ export interface IntelligencePageProps {
16
  initialHistory?: boolean;
17
  }
18
 
19
- function NewFile({ api, folder, section, onClose, onCreated }: {
20
- api: IntelligenceApi; folder: string; section: IntelligenceSection | "";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  onClose: () => void; onCreated: (file: IntelligenceFile) => void;
22
  }) {
23
  const panelRef = useRef<HTMLElement>(null);
24
  const titleId = useId();
25
  const [title, setTitle] = useState("");
26
- const [chosenSection, setSection] = useState<IntelligenceSection>(section || "playbooks");
27
  const [chosenFolder, setFolder] = useState(folder);
28
  const [markdown, setMarkdown] = useState("");
29
- const [tools, setTools] = useState("");
30
  const [busy, setBusy] = useState(false);
31
  const [problem, setProblem] = useState("");
32
  const writing = useRef(false);
@@ -39,8 +98,8 @@ function NewFile({ api, folder, section, onClose, onCreated }: {
39
  if (writing.current) return;
40
  writing.current = true; setBusy(true); setProblem("");
41
  try {
42
- const file = await api.createFile({ title, section: chosenSection, folder: chosenFolder, markdown,
43
- tools: chosenSection === "agent-prompts" ? tools.split(/\r?\n/).map((name) => name.trim()).filter(Boolean) : [] });
44
  if (alive.current) onCreated(file);
45
  } catch (error) {
46
  if (alive.current) setProblem(intelligenceProblem(error, "The file could not be saved. Try again."));
@@ -57,12 +116,7 @@ function NewFile({ api, folder, section, onClose, onCreated }: {
57
  disabled={busy} onClick={onClose}><X size={20} aria-hidden="true" /></button></header>
58
  <form className="intelligence-create" onSubmit={(event) => void save(event)} aria-busy={busy}>
59
  <label>Title<input data-new-title required value={title} disabled={busy} onChange={(event) => setTitle(event.target.value)} /></label>
60
- <label>Section<select value={chosenSection} disabled={busy} onChange={(event) => setSection(event.target.value as IntelligenceSection)}>
61
- {INTELLIGENCE_SECTIONS.map((entry) => <option key={entry.key} value={entry.key}>{entry.label}</option>)}
62
- </select></label>
63
  <label>Folder<input value={chosenFolder} disabled={busy} placeholder="Optional" onChange={(event) => setFolder(event.target.value)} /></label>
64
- {chosenSection === "agent-prompts" ? <label>Tools<textarea className="intelligence-tools-input" value={tools}
65
- disabled={busy} rows={3} placeholder="One tool per line" onChange={(event) => setTools(event.target.value)} /></label> : null}
66
  <label className="intelligence-markdown-field">Markdown<textarea value={markdown} disabled={busy} rows={12}
67
  onChange={(event) => setMarkdown(event.target.value)} /></label>
68
  <div className="intelligence-create-feedback" role="status">{problem}</div>
@@ -79,126 +133,195 @@ function SkeletonRows() {
79
  </div>;
80
  }
81
 
 
 
 
 
 
 
 
 
82
  export default function IntelligencePage({ api = intelligenceApi, initialQuery = "", initialPath = "",
83
  initialView = "files", initialHistory = false }: IntelligencePageProps) {
84
- const [search, setSearch] = useState(initialQuery);
85
- const [query, setQuery] = useState<IntelligenceQuery>({ q: initialQuery, section: "", folder: "", offset: 0, limit: 10 });
86
- const [page, setPage] = useState<IntelligenceList | null>(null);
 
 
 
 
 
 
 
87
  const [loading, setLoading] = useState(true);
88
  const [problem, setProblem] = useState("");
89
  const [retry, setRetry] = useState(0);
90
- const [path, setPath] = useState(initialPath);
91
  const [creating, setCreating] = useState(false);
92
- const [view, setView] = useState(initialView);
93
- const newFileRef = useRef<HTMLButtonElement>(null);
94
- const pageRef = useRef<HTMLElement>(null);
95
- const searchId = useId();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  useEffect(() => {
97
- const timer = window.setTimeout(() => setQuery((current) => current.q === search.trim() ? current
98
- : { ...current, q: search.trim(), offset: 0 }), 250);
 
 
 
 
 
 
 
 
 
99
  return () => window.clearTimeout(timer);
100
  }, [search]);
101
  useEffect(() => {
 
102
  const abort = new AbortController();
 
103
  setLoading(true); setProblem("");
104
- void api.listFiles(query, abort.signal).then((value) => {
105
  if (abort.signal.aborted) return;
106
  if (query.offset > 0 && query.offset >= value.total) {
107
  setQuery((current) => ({ ...current, offset: Math.max(0, Math.ceil(value.total / current.limit) - 1) * current.limit }));
108
  return;
109
  }
110
- setPage(value);
111
  }).catch((error: unknown) => {
112
  if (abort.signal.aborted) return;
113
- if (error instanceof IntelligenceApiError && [401, 403].includes(error.status)) { setPage(null); setPath(""); }
114
  setProblem(intelligenceProblem(error, "The file list could not be read. Try again."));
115
  }).finally(() => { if (!abort.signal.aborted) setLoading(false); });
116
  return () => abort.abort();
117
- }, [api, query, retry]);
118
 
119
- function scope(next: Partial<IntelligenceQuery>) { setQuery((current) => ({ ...current, ...next, offset: 0 })); }
 
 
 
120
  function choosePage(offset: number) {
121
  setQuery((current) => ({ ...current, offset }));
122
  pageRef.current?.scrollTo({ top: 0 });
123
  }
124
- function submitSearch(event: FormEvent) {
125
- event.preventDefault();
126
- scope({ q: search.trim() });
127
- }
128
  function created(file: IntelligenceFile) {
129
- setCreating(false); setSearch(""); scope({ q: "", folder: "", section: "" });
130
- setRetry((value) => value + 1);
131
- // The create drawer restores its opener before the file drawer captures it.
132
- window.requestAnimationFrame(() => { newFileRef.current?.focus(); setPath(file.path); });
 
 
 
 
 
 
133
  }
134
- const empty = !!page && !page.files.length && !loading && !problem;
135
- const folders = [...new Set([...(page?.folders || []), ...(query.folder ? [query.folder] : [])])];
136
- const newButton = <button ref={newFileRef} type="button" className="intelligence-button" data-testid="intelligence-new"
137
- onClick={() => setCreating(true)}><Plus size={18} aria-hidden="true" />New file</button>;
138
 
139
- return <section className="intelligence-page" ref={pageRef} aria-label="Brain" data-testid="intelligence-page">
140
- <header className="intelligence-head"><div><h1>Brain</h1><p>What your workspace knows.</p></div>{view === "files" && !empty ? newButton : null}</header>
141
- <div className="intelligence-view-switch" role="group" aria-label="Brain view">
142
- <button type="button" className="intelligence-button" aria-pressed={view === "files"} onClick={() => setView("files")}>Files</button>
143
- <button type="button" className="intelligence-button" aria-pressed={view === "insights"} onClick={() => setView("insights")}>Insights</button>
 
 
 
 
 
 
 
 
 
 
144
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  {view === "insights" ? <Insights api={api} /> : <>
146
- <form className="intelligence-search" role="search" onSubmit={submitSearch}>
147
- <label className="intelligence-search-field" htmlFor={searchId}><MagnifyingGlass size={20} aria-hidden="true" />
148
- <input id={searchId} type="search" aria-label="Search Brain" placeholder="Search files" value={search}
149
- onChange={(event) => setSearch(event.target.value)} /></label>
150
- <button type="submit" className="intelligence-button">Find</button>
151
- </form>
152
- <div className="intelligence-layout">
153
- <aside className="intelligence-folders" aria-label="Folders"><h2>Folders</h2>
154
- <button type="button" className="intelligence-button intelligence-folder" aria-pressed={!query.folder} onClick={() => scope({ folder: "" })}>
155
- <Folder size={18} aria-hidden="true" />All files</button>
156
- {folders.map((folder) => <button key={folder} type="button" className="intelligence-button intelligence-folder" title={folder}
157
- aria-pressed={query.folder === folder} onClick={() => scope({ folder })}><Folder size={18} aria-hidden="true" /><span>{folder}</span></button>)}
158
- </aside>
159
- <div className="intelligence-content">
160
- <label className="intelligence-mobile-folders">Folder<select value={query.folder} onChange={(event) => scope({ folder: event.target.value })}>
161
- <option value="">All files</option>{folders.map((folder) => <option key={folder} value={folder}>{folder}</option>)}
162
- </select></label>
163
- <div className="intelligence-filter-row"><div className="intelligence-filters" role="group" aria-label="File sections">
164
- <button type="button" className="intelligence-button" aria-pressed={!query.section} onClick={() => scope({ section: "" })}>All</button>
165
- {INTELLIGENCE_SECTIONS.map((section) => <button key={section.key} type="button" className="intelligence-button"
166
- aria-pressed={query.section === section.key} onClick={() => scope({ section: section.key })}>{section.label}</button>)}
167
- </div><button type="button" className="intelligence-button intelligence-icon-button" aria-label="Refresh files" disabled={loading}
168
- onClick={() => setRetry((value) => value + 1)}><ArrowClockwise size={18} aria-hidden="true" /></button></div>
169
- {problem ? <div className="intelligence-feedback" role="alert" data-testid="intelligence-error">
170
- <span>{problem}{page?.files.length ? " Showing the last list." : ""}</span>
171
- <button type="button" className="intelligence-button" onClick={() => setRetry((value) => value + 1)}>Retry</button></div> : null}
172
- <div aria-busy={loading}>
173
- {page?.files.length ? <ul className="intelligence-list" data-testid="intelligence-list" aria-label="Brain files">
174
- {page.files.map((file) => <li key={file.path}><button type="button" className="intelligence-button intelligence-row"
175
- data-file-path={file.path} onClick={() => setPath(file.path)} aria-haspopup="dialog">
176
- <FileText className="intelligence-file-icon" size={24} aria-hidden="true" />
177
- <span className="intelligence-row-text"><span className="intelligence-row-heading"><span className="intelligence-title">{file.title}</span>
178
- <span className="intelligence-tag">{sectionLabel(file.section)}</span></span>
179
- <span className="intelligence-description" title={file.description}>{file.description || "No description yet."}</span>
180
- <span className="intelligence-recency">{file.lastUsed ? <>Last used <time dateTime={file.lastUsed}>{fileDate(file.lastUsed)}</time></> : "Use not recorded"}</span>
181
- </span><CaretRight className="intelligence-row-chevron" size={16} aria-hidden="true" />
182
- </button></li>)}
183
- </ul> : null}
184
- {loading ? <SkeletonRows /> : null}
185
- {empty ? <div className="intelligence-empty" data-testid="intelligence-empty"><p>{query.q || query.section || query.folder ? "No files found." : "No files yet."}</p>{newButton}</div> : null}
186
  </div>
187
- {page && page.total > 10 ? <div className="intelligence-pager" aria-label="File pages" data-testid="intelligence-pager">
188
- <label>Files per page <select value={query.limit} onChange={(event) => scope({ limit: Number(event.target.value) })} disabled={loading || !!problem}>
189
- <option value={10}>10</option><option value={20}>20</option></select></label>
190
- <span role="status">{(page.offset + 1).toLocaleString()} to {(page.offset + page.files.length).toLocaleString()} of {page.total.toLocaleString()}</span>
191
- <div><button type="button" className="intelligence-button intelligence-icon-button" aria-label="Previous page" disabled={loading || !!problem || page.offset === 0}
192
- onClick={() => choosePage(Math.max(0, page.offset - page.limit))}><CaretLeft size={18} aria-hidden="true" /></button>
193
- <button type="button" className="intelligence-button intelligence-icon-button" aria-label="Next page"
194
- disabled={loading || !!problem || page.offset + page.files.length >= page.total} onClick={() => choosePage(page.offset + page.limit)}>
195
- <CaretRight size={18} aria-hidden="true" /></button></div>
196
- </div> : null}
197
  </div>
198
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  </>}
200
- {path ? <FileView key={path} path={path} api={api} initialHistory={initialHistory}
201
- onChanged={() => setRetry((value) => value + 1)} onClose={() => setPath("")} /> : null}
202
- {creating ? <NewFile api={api} folder={query.folder} section={query.section} onClose={() => setCreating(false)} onCreated={created} /> : null}
203
- </section>;
204
  }
 
1
  import { useEffect, useId, useRef, useState } from "react";
2
  import type { FormEvent } from "react";
3
+ import { Brain, ChartBar, FileText, X } from "@phosphor-icons/react";
4
  import { BodyPortal, useOverlayLayer } from "../customer-grid/OverlaySurface";
5
+ import { FolderMark } from "../customer-grid/icons";
6
+ import { GridPager } from "../customer-grid/GridPager";
7
+ import { GridIcon, HomeTilePage, ListIcon, QuickCard } from "../home/HomePage";
8
+ import HomeFind from "../home/HomeFind";
9
+ import FolderNameDialog from "../home/FolderNameDialog";
10
+ import { ModuleHomeHead } from "../home/ModuleHomeHead";
11
+ import { HOME_LAYOUT_KEY, parseLayout } from "../home/homeModel";
12
+ import type { HomeLayout } from "../home/homeModel";
13
+ import type { HomeSort } from "../home/homeFind";
14
  import FileView from "./FileView";
15
  import Insights from "./Insights";
16
+ import { BRAIN_FILE_SECTION, IntelligenceApiError, fileDate, intelligenceApi, intelligenceProblem } from "./intelligenceApi";
17
+ import type { IntelligenceApi, IntelligenceFile, IntelligenceFileRow, IntelligenceList, IntelligenceQuery } from "./intelligenceApi";
18
+ import "../styles/wave50/rail.css";
19
+ import "../styles/wave57/home-app.css";
20
+ import "../styles/wave58/app-data.css";
21
+ import "../styles/wave61/home.css";
22
+ import "../styles/wave61/rails.css";
23
+ import "../styles/sdlc72/home.css";
24
  import "../styles/sdlc73/intelligence.css";
25
 
26
  export interface IntelligencePageProps {
 
31
  initialHistory?: boolean;
32
  }
33
 
34
+ /** Where Brain is: every state lives in the hash so Back and Shell's remount restore it. */
35
+ interface BrainAddress { folder: string; view: "files" | "insights"; path: string; q: string }
36
+ const BRAIN_HASH = "#/intelligence";
37
+ const PAGE_SIZES = [10, 20] as const;
38
+
39
+ function isBrainHash(hash: string): boolean {
40
+ return hash === BRAIN_HASH || hash.startsWith(BRAIN_HASH + "?");
41
+ }
42
+ function readAddress(hash: string): BrainAddress {
43
+ const params = new URLSearchParams(hash.split("?")[1] || "");
44
+ return { folder: params.get("folder") || "", view: params.get("view") === "insights" ? "insights" : "files",
45
+ path: params.get("path") || "", q: params.get("q") || "" };
46
+ }
47
+ function addressHash(address: BrainAddress): string {
48
+ const params = new URLSearchParams();
49
+ if (address.folder) params.set("folder", address.folder);
50
+ if (address.view === "insights") params.set("view", "insights");
51
+ if (address.path) params.set("path", address.path);
52
+ if (address.q) params.set("q", address.q);
53
+ const query = params.toString();
54
+ return query ? `${BRAIN_HASH}?${query}` : BRAIN_HASH;
55
+ }
56
+ /** The folders one level below `folder`, from the server's list of every ancestor prefix. */
57
+ function childFolders(folders: readonly string[], folder: string): string[] {
58
+ const prefix = folder ? folder + "/" : "";
59
+ const children = new Set<string>();
60
+ for (const entry of folders) {
61
+ if (!entry.startsWith(prefix) || entry === folder) continue;
62
+ const name = entry.slice(prefix.length).split("/")[0];
63
+ if (name) children.add(prefix + name);
64
+ }
65
+ return [...children].sort((a, b) => a.localeCompare(b, undefined, { sensitivity: "base" }));
66
+ }
67
+ const folderLabel = (folder: string) => folder.split("/").pop() || folder;
68
+ /** A folder name becomes one path segment the server accepts: letters, digits, dot, dash, underscore. */
69
+ function folderSegment(name: string): string {
70
+ const segment = name.trim().replace(/\s+/g, "-").replace(/[^a-zA-Z0-9._-]/g, "");
71
+ return segment === "." || segment === ".." ? "" : segment;
72
+ }
73
+ const fileFolder = (path: string) => path.split("/").slice(0, -1).join("/");
74
+ const stamp = (row: IntelligenceFileRow) => Math.max(Date.parse(row.updated) || 0, Date.parse(row.lastUsed || "") || 0);
75
+ function sortFiles(rows: readonly IntelligenceFileRow[], sort: HomeSort): IntelligenceFileRow[] {
76
+ return [...rows].sort((a, b) => (sort === "recent" ? stamp(b) - stamp(a) : 0)
77
+ || a.title.localeCompare(b.title, undefined, { sensitivity: "base" }) || a.path.localeCompare(b.path));
78
+ }
79
+
80
+ function NewFile({ api, folder, onClose, onCreated }: {
81
+ api: IntelligenceApi; folder: string;
82
  onClose: () => void; onCreated: (file: IntelligenceFile) => void;
83
  }) {
84
  const panelRef = useRef<HTMLElement>(null);
85
  const titleId = useId();
86
  const [title, setTitle] = useState("");
 
87
  const [chosenFolder, setFolder] = useState(folder);
88
  const [markdown, setMarkdown] = useState("");
 
89
  const [busy, setBusy] = useState(false);
90
  const [problem, setProblem] = useState("");
91
  const writing = useRef(false);
 
98
  if (writing.current) return;
99
  writing.current = true; setBusy(true); setProblem("");
100
  try {
101
+ // New files take one section and no tools. The assistant and MCP still write every section.
102
+ const file = await api.createFile({ title, section: BRAIN_FILE_SECTION, folder: chosenFolder, markdown, tools: [] });
103
  if (alive.current) onCreated(file);
104
  } catch (error) {
105
  if (alive.current) setProblem(intelligenceProblem(error, "The file could not be saved. Try again."));
 
116
  disabled={busy} onClick={onClose}><X size={20} aria-hidden="true" /></button></header>
117
  <form className="intelligence-create" onSubmit={(event) => void save(event)} aria-busy={busy}>
118
  <label>Title<input data-new-title required value={title} disabled={busy} onChange={(event) => setTitle(event.target.value)} /></label>
 
 
 
119
  <label>Folder<input value={chosenFolder} disabled={busy} placeholder="Optional" onChange={(event) => setFolder(event.target.value)} /></label>
 
 
120
  <label className="intelligence-markdown-field">Markdown<textarea value={markdown} disabled={busy} rows={12}
121
  onChange={(event) => setMarkdown(event.target.value)} /></label>
122
  <div className="intelligence-create-feedback" role="status">{problem}</div>
 
133
  </div>;
134
  }
135
 
136
+ function BackButton({ onClick }: { onClick: () => void }) {
137
+ return <button type="button" className="cg-btn" aria-label="Back" title="Back" onClick={onClick}>
138
+ <svg viewBox="0 0 16 16" aria-hidden="true" className="home-layout-icon" fill="none" stroke="currentColor">
139
+ <path d="M10 3 5 8l5 5" />
140
+ </svg>
141
+ </button>;
142
+ }
143
+
144
  export default function IntelligencePage({ api = intelligenceApi, initialQuery = "", initialPath = "",
145
  initialView = "files", initialHistory = false }: IntelligencePageProps) {
146
+ const [address, setAddress] = useState<BrainAddress>(() => isBrainHash(window.location.hash)
147
+ ? readAddress(window.location.hash) : { folder: "", view: initialView, path: initialPath, q: initialQuery });
148
+ const [search, setSearch] = useState(address.q);
149
+ const [sort, setSort] = useState<HomeSort>("recent");
150
+ const [layout, setLayoutState] = useState<HomeLayout>(() => {
151
+ try { return parseLayout(localStorage.getItem(HOME_LAYOUT_KEY)); } catch { return "grid"; }
152
+ });
153
+ const [query, setQuery] = useState<IntelligenceQuery>({ q: address.q, folder: address.folder, offset: 0, limit: 10 });
154
+ // The list remembers its folder, so entering a folder never paints the last folder's tiles.
155
+ const [loaded, setLoaded] = useState<{ scope: string; value: IntelligenceList } | null>(null);
156
  const [loading, setLoading] = useState(true);
157
  const [problem, setProblem] = useState("");
158
  const [retry, setRetry] = useState(0);
 
159
  const [creating, setCreating] = useState(false);
160
+ const [folderAnchor, setFolderAnchor] = useState<HTMLElement | null>(null);
161
+ const pageRef = useRef<HTMLDivElement>(null);
162
+ const { view, path } = address;
163
+ const page = loaded?.scope === query.folder ? loaded.value : null;
164
+
165
+ function apply(next: BrainAddress) {
166
+ setAddress(next); setSearch(next.q);
167
+ setQuery((current) => current.folder === next.folder && current.q === next.q ? current
168
+ : { ...current, folder: next.folder, q: next.q, offset: 0 });
169
+ }
170
+ function go(next: BrainAddress) {
171
+ const hash = addressHash(next);
172
+ if (window.location.hash !== hash) window.location.hash = hash;
173
+ apply(next);
174
+ }
175
+ function setPath(next: string) { go({ ...address, path: next }); }
176
+ useEffect(() => {
177
+ const onHash = () => { if (isBrainHash(window.location.hash)) apply(readAddress(window.location.hash)); };
178
+ window.addEventListener("hashchange", onHash);
179
+ return () => window.removeEventListener("hashchange", onHash);
180
+ }, []);
181
  useEffect(() => {
182
+ const timer = window.setTimeout(() => {
183
+ const q = search.trim();
184
+ setQuery((current) => current.q === q ? current : { ...current, q, offset: 0 });
185
+ setAddress((current) => {
186
+ if (current.q === q) return current;
187
+ const next = { ...current, q };
188
+ // Typing must not remount the page, so the query rides the hash without a hashchange.
189
+ if (isBrainHash(window.location.hash)) window.history.replaceState(window.history.state, "", addressHash(next));
190
+ return next;
191
+ });
192
+ }, 250);
193
  return () => window.clearTimeout(timer);
194
  }, [search]);
195
  useEffect(() => {
196
+ if (path || view === "insights") return;
197
  const abort = new AbortController();
198
+ const scope = query.folder;
199
  setLoading(true); setProblem("");
200
+ void api.listFiles({ ...query, direct: !query.q.trim() }, abort.signal).then((value) => {
201
  if (abort.signal.aborted) return;
202
  if (query.offset > 0 && query.offset >= value.total) {
203
  setQuery((current) => ({ ...current, offset: Math.max(0, Math.ceil(value.total / current.limit) - 1) * current.limit }));
204
  return;
205
  }
206
+ setLoaded({ scope, value });
207
  }).catch((error: unknown) => {
208
  if (abort.signal.aborted) return;
209
+ if (error instanceof IntelligenceApiError && [401, 403].includes(error.status)) setLoaded(null);
210
  setProblem(intelligenceProblem(error, "The file list could not be read. Try again."));
211
  }).finally(() => { if (!abort.signal.aborted) setLoading(false); });
212
  return () => abort.abort();
213
+ }, [api, query, retry, path, view]);
214
 
215
+ function setLayout(next: HomeLayout) {
216
+ setLayoutState(next);
217
+ try { localStorage.setItem(HOME_LAYOUT_KEY, next); } catch { /* A private window keeps the choice in memory. */ }
218
+ }
219
  function choosePage(offset: number) {
220
  setQuery((current) => ({ ...current, offset }));
221
  pageRef.current?.scrollTo({ top: 0 });
222
  }
223
+ function enterFolder(folder: string) { go({ folder, view: "files", path: "", q: "" }); }
 
 
 
224
  function created(file: IntelligenceFile) {
225
+ setCreating(false);
226
+ go({ folder: fileFolder(file.path), view: "files", path: file.path, q: "" });
227
+ }
228
+ const fileHref = (row: IntelligenceFileRow) => addressHash({ ...address, view: "files", path: row.path });
229
+
230
+ if (path) {
231
+ return <div className="intelligence-file-home" role="region" aria-label="Brain" data-testid="intelligence-page">
232
+ <FileView key={path} path={path} api={api} initialHistory={initialHistory}
233
+ onChanged={() => setRetry((value) => value + 1)} onClose={() => setPath("")} />
234
+ </div>;
235
  }
 
 
 
 
236
 
237
+ const folders = page ? childFolders(page.folders, query.folder) : [];
238
+ const files = page ? sortFiles(page.files, sort) : [];
239
+ const empty = !!page && !page.files.length && !folders.length && !problem;
240
+ const parent = query.folder.split("/").slice(0, -1).join("/");
241
+
242
+ return <div className="shell-home intelligence-home" ref={pageRef} role="region" aria-label="Brain" data-testid="intelligence-page">
243
+ <ModuleHomeHead title="Brain" module="intelligence" />
244
+ <div className="home-cards is-app">
245
+ <QuickCard icon={<span className="intelligence-card-icon" aria-hidden="true"><Brain size={16} /></span>}
246
+ title="Create new" detail="Write a new Brain file." onClick={() => setCreating(true)} />
247
+ <QuickCard icon={<span className="intelligence-card-icon" aria-hidden="true"><ChartBar size={16} /></span>}
248
+ title="Insights" detail="See who changed Brain files." onClick={() => go({ ...address, view: "insights", path: "" })} />
249
+ <QuickCard icon={<span className="home-card-icon" aria-hidden="true"><FolderMark size={16} /></span>}
250
+ title="New folder" detail="Group Brain files into folders."
251
+ onClick={(event) => setFolderAnchor(event.currentTarget)} />
252
  </div>
253
+ {folderAnchor ? <FolderNameDialog anchor={folderAnchor} title="New folder"
254
+ siblingNames={folders.map(folderLabel)}
255
+ onSubmit={(name) => {
256
+ const segment = folderSegment(name);
257
+ setFolderAnchor(null);
258
+ if (segment) enterFolder(query.folder ? `${query.folder}/${segment}` : segment);
259
+ }}
260
+ onDismiss={() => setFolderAnchor(null)} /> : null}
261
+
262
+ {view === "insights" ? <div className="home-section-head">
263
+ <BackButton onClick={() => go({ ...address, view: "files" })} />
264
+ <span className="home-folder-name">Insights</span>
265
+ </div> : null}
266
  {view === "insights" ? <Insights api={api} /> : <>
267
+ <div className="home-recents-bar">
268
+ <div className="home-layout-toggle home-find-toolbar" role="group" aria-label="Layout">
269
+ <HomeFind moduleName="Brain" query={search} sort={sort} onQueryChange={setSearch} onSortChange={setSort} />
270
+ <div className="home-find-layout">
271
+ <button type="button" className={"home-layout-btn" + (layout === "list" ? " is-on" : "")}
272
+ aria-pressed={layout === "list"} aria-label="List" title="List" onClick={() => setLayout("list")}>
273
+ <ListIcon />
274
+ </button>
275
+ <button type="button" className={"home-layout-btn" + (layout === "grid" ? " is-on" : "")}
276
+ aria-pressed={layout === "grid"} aria-label="Grid" title="Grid" onClick={() => setLayout("grid")}>
277
+ <GridIcon />
278
+ </button>
279
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  </div>
 
 
 
 
 
 
 
 
 
 
281
  </div>
282
+
283
+ {problem ? <div className="intelligence-feedback" role="alert" data-testid="intelligence-error">
284
+ <span>{problem}{page?.files.length ? " Showing the last list." : ""}</span>
285
+ <button type="button" className="intelligence-button" onClick={() => setRetry((value) => value + 1)}>Retry</button></div> : null}
286
+ {!page && loading ? <SkeletonRows /> : null}
287
+ {page ? <>
288
+ {query.folder || folders.length ? <section className="home-section" aria-label="Brain folders">
289
+ {query.folder ? <div className="home-section-head">
290
+ <BackButton onClick={() => enterFolder(parent)} />
291
+ <span className="home-folder-name">{query.folder.split("/").join(" / ")}</span>
292
+ </div> : null}
293
+ {folders.length ? <HomeTilePage items={folders} layout={layout} scopeKey={query.folder}>
294
+ {(pageItems) => pageItems.map((folder) => <button type="button" className="home-tile" key={folder}
295
+ onClick={() => enterFolder(folder)}>
296
+ <span className="home-tile-chip home-folder-glyph" aria-hidden="true"><FolderMark size={16} /></span>
297
+ <span className="home-tile-text">
298
+ <span className="home-tile-name">{folderLabel(folder)}</span>
299
+ <span className="home-tile-ago">Folder</span>
300
+ </span>
301
+ </button>)}
302
+ </HomeTilePage> : null}
303
+ </section> : null}
304
+ {files.length ? <section className="home-section" aria-busy={loading}>
305
+ <h2 className="home-section-title">Brain files</h2>
306
+ <div className={"home-tiles home-paged-grid is-" + layout} data-testid="intelligence-list">
307
+ {files.map((row) => <a key={row.path} className="home-tile cg-view-row" href={fileHref(row)} data-file-path={row.path}
308
+ title={row.description || undefined}>
309
+ <span className="home-tile-chip home-app-glyph" aria-hidden="true"><FileText size={16} /></span>
310
+ <span className="home-tile-text">
311
+ <span className="home-tile-name">{row.title}</span>
312
+ <span className="home-tile-ago">{[fileFolder(row.path) !== query.folder ? fileFolder(row.path) : "",
313
+ `Edited ${fileDate(row.updated)}`].filter(Boolean).join(" · ")}</span>
314
+ </span>
315
+ </a>)}
316
+ </div>
317
+ {page.total > PAGE_SIZES[0] ? <GridPager offset={page.offset} size={query.limit} sizes={PAGE_SIZES}
318
+ total={page.total} pending={loading} itemsLabel="Items" onPage={choosePage}
319
+ onSize={(size) => setQuery((current) => ({ ...current, limit: size === 20 ? 20 : 10, offset: 0 }))} /> : null}
320
+ </section> : null}
321
+ {empty ? <p className="home-empty" data-testid="intelligence-empty" role="status">
322
+ {query.q ? "No Brain files match that." : query.folder ? "This folder is empty." : "No Brain files yet."}</p> : null}
323
+ </> : null}
324
  </>}
325
+ {creating ? <NewFile api={api} folder={query.folder} onClose={() => setCreating(false)} onCreated={created} /> : null}
326
+ </div>;
 
 
327
  }
web/src/intelligence/intelligenceApi.ts CHANGED
@@ -10,6 +10,8 @@ export const INTELLIGENCE_SECTIONS = [
10
  { key: "agent-memory", label: "Agent memory" },
11
  ] as const;
12
  export type IntelligenceSection = typeof INTELLIGENCE_SECTIONS[number]["key"];
 
 
13
  export interface IntelligenceFileRow {
14
  path: string;
15
  title: string;
@@ -95,8 +97,11 @@ export interface IntelligenceList {
95
  }
96
  export interface IntelligenceQuery {
97
  q: string;
98
- section: IntelligenceSection | "";
 
99
  folder: string;
 
 
100
  offset: number;
101
  limit: number;
102
  }
@@ -126,9 +131,6 @@ export class IntelligenceApiError extends Error {
126
  export function intelligenceProblem(error: unknown, fallback: string): string {
127
  return error instanceof IntelligenceApiError ? error.message : fallback;
128
  }
129
- export function sectionLabel(section: IntelligenceSection): string {
130
- return INTELLIGENCE_SECTIONS.find((entry) => entry.key === section)?.label || "File";
131
- }
132
  export function fileDate(value: string): string {
133
  return new Intl.DateTimeFormat(undefined, { dateStyle: "medium", timeStyle: "short" }).format(new Date(value));
134
  }
@@ -270,8 +272,8 @@ export const intelligenceApi: IntelligenceApi = {
270
  }, `proposals/${encodeURIComponent(id)}/${decision}`);
271
  },
272
  listFiles(query, signal) {
273
- const params = new URLSearchParams({ q: query.q, section: query.section, folder: query.folder,
274
- offset: String(query.offset), limit: String(query.limit) });
275
  return request(`?${params}`, { method: "GET", signal }, readList);
276
  },
277
  readFile(path, signal) { return request(`?${new URLSearchParams({ path })}`, { method: "GET", signal }, readFile); },
 
10
  { key: "agent-memory", label: "Agent memory" },
11
  ] as const;
12
  export type IntelligenceSection = typeof INTELLIGENCE_SECTIONS[number]["key"];
13
+ /** The screen shows one kind, Brain files. A file made there is stored in this section. */
14
+ export const BRAIN_FILE_SECTION: IntelligenceSection = "playbooks";
15
  export interface IntelligenceFileRow {
16
  path: string;
17
  title: string;
 
97
  }
98
  export interface IntelligenceQuery {
99
  q: string;
100
+ /** Optional server filter. The Brain screen does not send it. */
101
+ section?: IntelligenceSection | "";
102
  folder: string;
103
+ /** Only files directly in `folder`, as a module home level shows them. */
104
+ direct?: boolean;
105
  offset: number;
106
  limit: number;
107
  }
 
131
  export function intelligenceProblem(error: unknown, fallback: string): string {
132
  return error instanceof IntelligenceApiError ? error.message : fallback;
133
  }
 
 
 
134
  export function fileDate(value: string): string {
135
  return new Intl.DateTimeFormat(undefined, { dateStyle: "medium", timeStyle: "short" }).format(new Date(value));
136
  }
 
272
  }, `proposals/${encodeURIComponent(id)}/${decision}`);
273
  },
274
  listFiles(query, signal) {
275
+ const params = new URLSearchParams({ q: query.q, ...(query.section ? { section: query.section } : {}), folder: query.folder,
276
+ ...(query.direct ? { direct: "true" } : {}), offset: String(query.offset), limit: String(query.limit) });
277
  return request(`?${params}`, { method: "GET", signal }, readList);
278
  },
279
  readFile(path, signal) { return request(`?${new URLSearchParams({ path })}`, { method: "GET", signal }, readFile); },
web/src/shell/Shell.tsx CHANGED
@@ -41,6 +41,7 @@ import { Database } from "@phosphor-icons/react/dist/csr/Database";
41
  import { House } from "@phosphor-icons/react/dist/csr/House";
42
  import { List } from "@phosphor-icons/react/dist/csr/List";
43
  import { Plug } from "@phosphor-icons/react/dist/csr/Plug";
 
44
  import { Table } from "@phosphor-icons/react/dist/csr/Table";
45
  import { ArtifactsGlyph } from "./icons";
46
  import { OverlayScroll } from "../ui/OverlayScroll";
@@ -347,6 +348,7 @@ function boardedFor(
347
  [ASSISTANT_ROUTE, "analyst", "Assistant"],
348
  [ARTIFACTS_ROUTE, "analyst", "Artifacts"],
349
  [INTELLIGENCE_ROUTE, "intelligence", "Brain"],
 
350
  ];
351
  for (const [r, key, label] of BOARDED) {
352
  if (route === r && !entries.some((e) => e.key === key)
@@ -2317,9 +2319,8 @@ function ShellFrame() {
2317
  // NO_ENTRIES, not a fresh `[]`: a new array identity on every render would
2318
  // re-run the hash effect below on every render for no reason.
2319
  const entries = nav.phase === "ready" ? nav.entries : NO_ENTRIES;
2320
- // S67-T36 (R25): Agents is ARCHIVED in `core/registry.py`, so `/nav` carries no `automation`
2321
- // row. Every Agents door this frame draws keys off that one fact (the rail row, the gallery,
2322
- // Home's section through `autoTiles`), so un-archiving the row restores them all.
2323
  const agentsOnNav = Boolean(findAutomation(entries));
2324
  // Wave 18: a fresh TENANT (server says `no_databases`) is welcomed, not warned.
2325
  const tenantEmptyState =
@@ -3072,6 +3073,7 @@ function ShellFrame() {
3072
  // split is a PROPERTY of the row now (`shapeNav` stamps `surface`) and `databaseEntries` is the
3073
  // one accessor — which also returns the BRANDED `DatabaseEntry[]`, so handing a database
3074
  // surface the raw `entries` is a compile error rather than one extra tile nobody looks at.
 
3075
  /**
3076
  * ⭐⭐ W31-T11 (owner item 6b) — WHAT TO DRAW WHERE AUTOMATION GOES WHEN IT IS NOT THERE.
3077
  *
@@ -3157,12 +3159,13 @@ function ShellFrame() {
3157
  ? "unavailable"
3158
  : "absent";
3159
  const intelligenceSlot: RailSlot = railSlot(!!intelligence);
 
3160
  const analystSlot: RailSlot = railSlot(!!analyst);
3161
  // S68-T54 (R37): Artifacts rides the SAME `analyst` grant, but it is its own rail row, so it
3162
  // gets its own slot from the one rule (verify_wiring: one `railSlot(` per conditional row).
3163
  const artifactsSlot: RailSlot = railSlot(!!analyst);
3164
- // Workspace holds Brain, Artifacts, App, Sheet and Record. App, Sheet and Record are always rows.
3165
- const workspaceVisible = !railLoading && hasVisibleRailSlot([intelligenceSlot, artifactsSlot, "row", "row", "row"]);
3166
  const financeAppKey = /^#\/finance\/([^/?#]+)/.exec(hash)?.[1];
3167
  const financeCurrent = Boolean(financeAppKey);
3168
  // WAVE 23 C10 — the flyout's search. A plain label substring, case-folded: this list is at
@@ -3505,6 +3508,40 @@ function ShellFrame() {
3505
  <span className="shell-nav-label">Record</span>
3506
  </button>
3507
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3508
  {/* ⛔ "+ Create new…" IS NO LONGER A RAIL ROW (item 15a, ruling R9). It moved into the
3509
  Database flyout's footer, where the things it creates actually live — and where the
3510
  three `.shell-dbfly-make` buttons used to be. See the footer below, and
@@ -3725,11 +3762,11 @@ function ShellFrame() {
3725
  <div className="shell-db-frame">
3726
  <div className="shell-auto-host">
3727
  {/* USER-VISIBLE: ErrorBoundary renders "{surface} could not be shown" (T40, QA) */}
3728
- <Lazily key="agents-surface" surface="Agents"><AutomationSurface /></Lazily>
3729
  </div>
3730
  </div>
3731
  ) : (
3732
- <Lazily key="agents-gallery" surface="Agents">
3733
  <AgentsGalleryPage
3734
  initialStarredOnly={window.location.hash.includes("filter=starred")}
3735
  entries={dbEntries}
 
41
  import { House } from "@phosphor-icons/react/dist/csr/House";
42
  import { List } from "@phosphor-icons/react/dist/csr/List";
43
  import { Plug } from "@phosphor-icons/react/dist/csr/Plug";
44
+ import { Robot } from "@phosphor-icons/react/dist/csr/Robot";
45
  import { Table } from "@phosphor-icons/react/dist/csr/Table";
46
  import { ArtifactsGlyph } from "./icons";
47
  import { OverlayScroll } from "../ui/OverlayScroll";
 
348
  [ASSISTANT_ROUTE, "analyst", "Assistant"],
349
  [ARTIFACTS_ROUTE, "analyst", "Artifacts"],
350
  [INTELLIGENCE_ROUTE, "intelligence", "Brain"],
351
+ ["automation", "automation", "Recurring"],
352
  ];
353
  for (const [r, key, label] of BOARDED) {
354
  if (route === r && !entries.some((e) => e.key === key)
 
2319
  // NO_ENTRIES, not a fresh `[]`: a new array identity on every render would
2320
  // re-run the hash effect below on every render for no reason.
2321
  const entries = nav.phase === "ready" ? nav.entries : NO_ENTRIES;
2322
+ // Every Recurring door (the rail row, the gallery, Home's section through `autoTiles`) keys off
2323
+ // the `automation` row on `/nav`, which a member sees only with the `automation` grant.
 
2324
  const agentsOnNav = Boolean(findAutomation(entries));
2325
  // Wave 18: a fresh TENANT (server says `no_databases`) is welcomed, not warned.
2326
  const tenantEmptyState =
 
3073
  // split is a PROPERTY of the row now (`shapeNav` stamps `surface`) and `databaseEntries` is the
3074
  // one accessor — which also returns the BRANDED `DatabaseEntry[]`, so handing a database
3075
  // surface the raw `entries` is a compile error rather than one extra tile nobody looks at.
3076
+ const automation = findAutomation(entries);
3077
  /**
3078
  * ⭐⭐ W31-T11 (owner item 6b) — WHAT TO DRAW WHERE AUTOMATION GOES WHEN IT IS NOT THERE.
3079
  *
 
3159
  ? "unavailable"
3160
  : "absent";
3161
  const intelligenceSlot: RailSlot = railSlot(!!intelligence);
3162
+ const automationSlot: RailSlot = railSlot(!!automation);
3163
  const analystSlot: RailSlot = railSlot(!!analyst);
3164
  // S68-T54 (R37): Artifacts rides the SAME `analyst` grant, but it is its own rail row, so it
3165
  // gets its own slot from the one rule (verify_wiring: one `railSlot(` per conditional row).
3166
  const artifactsSlot: RailSlot = railSlot(!!analyst);
3167
+ // Workspace holds Brain, Artifacts, App, Sheet, Record and Recurring. App, Sheet and Record are always rows.
3168
+ const workspaceVisible = !railLoading && hasVisibleRailSlot([intelligenceSlot, artifactsSlot, "row", "row", "row", automationSlot]);
3169
  const financeAppKey = /^#\/finance\/([^/?#]+)/.exec(hash)?.[1];
3170
  const financeCurrent = Boolean(financeAppKey);
3171
  // WAVE 23 C10 — the flyout's search. A plain label substring, case-folded: this list is at
 
3508
  <span className="shell-nav-label">Record</span>
3509
  </button>
3510
 
3511
+ {/* Recurring is the last Workspace row (owner 2026-10-12). Its label comes off the payload; the grant decides it. */}
3512
+ {automation ? (
3513
+ <a
3514
+ className={
3515
+ "shell-nav-item shell-nav-auto" +
3516
+ (active && active.key === automation.key ? " is-active" : "")
3517
+ }
3518
+ href={automation.href}
3519
+ aria-current={active && active.key === automation.key ? "page" : undefined}
3520
+ onClick={expandOnNavClick}
3521
+ onMouseEnter={navCollapsed ? tipEnter(automation.label) : undefined}
3522
+ onMouseLeave={navCollapsed ? tipLeave : undefined}
3523
+ >
3524
+ <Robot {...NAV_GLYPH} weight={active && active.key === automation.key ? "fill" : "regular"} />
3525
+ <span className="shell-nav-label">{automation.label}</span>
3526
+ </a>
3527
+ ) : automationSlot === "unavailable" ? (
3528
+ <div
3529
+ className="shell-nav-item shell-nav-auto is-unavailable"
3530
+ title={nav.phase === "error" ? navFailureMessage : "This list could not be loaded in full. Reload to retry."}
3531
+ >
3532
+ <Robot {...NAV_GLYPH} weight="regular" />
3533
+ <span className="shell-nav-label shell-nav-label--muted">Recurring</span>
3534
+ <span className="shell-nav-note-dot" aria-hidden="true" />
3535
+ </div>
3536
+ ) : (
3537
+ <div
3538
+ className="shell-nav-item shell-nav-auto is-rail-skeleton"
3539
+ aria-hidden="true"
3540
+ hidden
3541
+ style={{ display: "none" }}
3542
+ />
3543
+ )}
3544
+
3545
  {/* ⛔ "+ Create new…" IS NO LONGER A RAIL ROW (item 15a, ruling R9). It moved into the
3546
  Database flyout's footer, where the things it creates actually live — and where the
3547
  three `.shell-dbfly-make` buttons used to be. See the footer below, and
 
3762
  <div className="shell-db-frame">
3763
  <div className="shell-auto-host">
3764
  {/* USER-VISIBLE: ErrorBoundary renders "{surface} could not be shown" (T40, QA) */}
3765
+ <Lazily key="agents-surface" surface="Recurring"><AutomationSurface /></Lazily>
3766
  </div>
3767
  </div>
3768
  ) : (
3769
+ <Lazily key="agents-gallery" surface="Recurring">
3770
  <AgentsGalleryPage
3771
  initialStarredOnly={window.location.hash.includes("filter=starred")}
3772
  entries={dbEntries}
web/src/shell/moduleLabels.ts CHANGED
@@ -1 +1 @@
1
- export const AGENTS_MODULE_LABEL = "Agents";
 
1
+ export const AGENTS_MODULE_LABEL = "Recurring";
web/src/shell/nav.ts CHANGED
@@ -1047,7 +1047,7 @@ export interface NavEntry {
1047
  * which of those rows a DATABASE list is entitled to draw. A key here that the
1048
  * server never sends simply never matches.
1049
  *
1050
- * Intelligence and the dormant automation surface never appear as databases.
1051
  */
1052
  export const SURFACE_KEYS: ReadonlySet<string> = new Set(["automation", "intelligence"]);
1053
 
 
1047
  * which of those rows a DATABASE list is entitled to draw. A key here that the
1048
  * server never sends simply never matches.
1049
  *
1050
+ * Intelligence and Recurring (key `automation`) never appear as databases.
1051
  */
1052
  export const SURFACE_KEYS: ReadonlySet<string> = new Set(["automation", "intelligence"]);
1053
 
web/src/styles/sdlc73/intelligence.css CHANGED
@@ -1,10 +1,17 @@
1
- .intelligence-page {
2
- width: 100%; height: 100%; min-width: 0; overflow: auto;
3
- padding: var(--lp-content-inset); color: var(--lp-ink); font-size: var(--lp-fs-sm);
 
 
 
 
 
4
  }
5
- .intelligence-head, .intelligence-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
6
- .intelligence-head h1, .intelligence-drawer h2 { margin: 0; font-size: var(--lp-fs-lg); font-weight: var(--lp-fw-semibold); }
7
- .intelligence-head p { margin: 8px 0 0; color: var(--lp-muted); }
 
 
8
  .intelligence-button {
9
  border: 0; background: transparent; font: inherit; color: inherit;
10
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
@@ -13,59 +20,27 @@
13
  }
14
  .intelligence-button svg { flex-shrink: 0; }
15
  .intelligence-button:disabled { opacity: var(--lp-home-disabled-opacity); cursor: not-allowed; }
16
- .intelligence-button:focus-visible, .intelligence-page select:focus-visible,
17
- .intelligence-drawer :is(input, textarea, select, a, pre, [tabindex]):focus-visible {
18
  outline: 2px solid var(--lp-blue-deep); outline-offset: 2px;
19
  }
20
  .intelligence-button[aria-pressed="true"] { background: var(--lp-blue-tint); color: var(--lp-blue-deep); }
21
  .intelligence-icon-button { width: 36px; padding: 8px; }
22
  .intelligence-primary { background: var(--lp-primary); color: var(--lp-surface); }
23
- .intelligence-search { display: flex; align-items: center; gap: 8px; margin: var(--lp-section-gap) 0; max-width: 760px; }
24
- .intelligence-search-field {
25
- display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; padding: 0 12px;
26
- border: 1px solid var(--lp-line); border-radius: var(--lp-r-sm); color: var(--lp-muted);
27
- }
28
- .intelligence-search-field:focus-within { outline: 2px solid var(--lp-blue-deep); outline-offset: 2px; }
29
- .intelligence-search input {
30
- border: 0; background: transparent; color: var(--lp-ink); font: inherit;
31
- height: 40px; width: 100%; min-width: 0; outline: none;
32
- }
33
- .intelligence-search > button { min-height: 40px; }
34
- .intelligence-layout { display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: var(--lp-section-gap); }
35
- .intelligence-folders h2 { margin: 8px 12px 12px; color: var(--lp-muted); font-size: var(--lp-fs-2xs); font-weight: 500; }
36
- .intelligence-folder { width: 100%; justify-content: flex-start; color: var(--lp-muted); }
37
- .intelligence-folder span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
38
- .intelligence-content { min-width: 0; }
39
- .intelligence-filter-row { display: flex; align-items: flex-start; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--lp-line); }
40
- .intelligence-filters { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 0; }
41
- .intelligence-filters .intelligence-button { padding: 8px; font-size: var(--lp-fs-2xs); }
42
- .intelligence-list { list-style: none; margin: 0; padding: 0; }
43
- .intelligence-list > li { border-bottom: 1px solid var(--lp-line); }
44
- .intelligence-row { display: flex; width: 100%; padding: 20px 12px; text-align: left; justify-content: flex-start; gap: 16px; }
45
- .intelligence-file-icon { color: var(--lp-muted); align-self: flex-start; margin-top: 4px; }
46
- .intelligence-row-text { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 6px; }
47
- .intelligence-row-heading { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
48
- .intelligence-title { font-size: var(--lp-fs-sm); font-weight: var(--lp-fw-semibold); overflow-wrap: anywhere; }
49
- .intelligence-tag { padding: 2px 6px; background: var(--lp-wash); color: var(--lp-muted); border-radius: var(--lp-r-sm); font-size: var(--lp-fs-2xs); }
50
- .intelligence-description { color: var(--lp-muted); font-size: var(--lp-fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
51
- .intelligence-recency, .intelligence-meta, .intelligence-file-by { color: var(--lp-muted); font-size: var(--lp-fs-2xs); }
52
- .intelligence-row-chevron { color: var(--lp-muted); }
53
  .intelligence-meta { margin: 0 0 8px; }
54
  .intelligence-feedback { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 0; color: var(--lp-muted); }
55
  .intelligence-feedback span { overflow-wrap: anywhere; }
56
  .intelligence-empty { padding: 64px 16px; text-align: center; color: var(--lp-muted); }
57
- .intelligence-empty p { margin: 0 0 12px; }
58
  .intelligence-skeleton { display: flex; flex-direction: column; gap: 12px; padding: 24px 12px; }
59
  .intelligence-skeleton span { height: 12px; max-width: 360px; background: var(--lp-wash); border-radius: var(--lp-r-sm); }
60
  .intelligence-skeleton span:first-child { width: 48%; height: 16px; }
61
  .intelligence-skeleton span:last-child { width: 24%; }
62
- .intelligence-pager { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: flex-end; padding: 16px 0; color: var(--lp-muted); font-size: var(--lp-fs-2xs); }
63
- .intelligence-pager > label { margin-right: auto; }
64
- .intelligence-pager select, .intelligence-mobile-folders select, .intelligence-create :is(input, select, textarea) {
65
  border: 1px solid var(--lp-line); border-radius: var(--lp-r-sm); background: var(--lp-surface); color: var(--lp-ink); font: inherit; padding: 8px;
66
  }
67
- .intelligence-pager > div { display: flex; gap: 4px; }
68
- .intelligence-mobile-folders { display: none; }
69
  .intelligence-scrim { position: fixed; inset: 0; z-index: var(--cg-z-drawer); background: color-mix(in srgb, var(--lp-ink) 18%, transparent); }
70
  .intelligence-drawer {
71
  position: absolute; inset: 0 0 0 auto; width: min(680px, 100%); padding: var(--lp-content-inset);
@@ -92,7 +67,6 @@
92
  .intelligence-create label { display: flex; flex-direction: column; gap: 8px; font-size: var(--lp-fs-xs); }
93
  .intelligence-create :is(input, select) { min-height: 40px; width: 100%; }
94
  .intelligence-create textarea { resize: vertical; min-height: 200px; line-height: 1.6; }
95
- .intelligence-create .intelligence-tools-input { min-height: 88px; }
96
  .intelligence-prompt { display: flex; flex-direction: column; gap: var(--lp-section-gap); }
97
  .intelligence-prompt-tools { border-top: 1px solid var(--lp-line); padding-top: 16px; }
98
  .intelligence-prompt-tools h3 { margin: 0 0 12px; font-size: var(--lp-fs-sm); font-weight: var(--lp-fw-semibold); }
@@ -113,7 +87,6 @@
113
  .intelligence-view-switch { display: flex; gap: 4px; margin-top: 16px; }
114
  .intelligence-drawer .intelligence-view-switch { margin-top: 0; }
115
  .intelligence-history, .intelligence-insights { min-width: 0; }
116
- .intelligence-insights { margin-top: var(--lp-section-gap); }
117
  .intelligence-history-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
118
  .intelligence-history h3, .intelligence-insights h2 { margin: 0 0 12px; font-size: var(--lp-fs-sm); font-weight: var(--lp-fw-semibold); }
119
  .intelligence-history-list { list-style: none; margin: 0 0 24px; padding: 0; max-height: 280px; overflow: auto; }
@@ -141,16 +114,6 @@
141
  .intelligence-primary:not(:disabled):hover { background: var(--lp-primary-hover); }
142
  }
143
  @media (max-width: 640px) {
144
- .intelligence-page, .intelligence-drawer { padding: 16px; }
145
- .intelligence-layout { grid-template-columns: minmax(0, 1fr); }
146
- .intelligence-folders { display: none; }
147
- .intelligence-mobile-folders { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; color: var(--lp-muted); font-size: var(--lp-fs-xs); }
148
- .intelligence-mobile-folders select { flex: 1; min-width: 0; }
149
- .intelligence-head { align-items: center; gap: 8px; }
150
- .intelligence-head p { font-size: var(--lp-fs-xs); }
151
- .intelligence-head .intelligence-button { padding: 8px; }
152
- .intelligence-row { padding: 20px 4px; gap: 12px; }
153
- .intelligence-row-chevron { display: none; }
154
- .intelligence-pager { gap: 8px; }
155
  }
156
  @media (prefers-reduced-motion: reduce) { .intelligence-drawer { animation: none; } }
 
1
+ /* Brain mounts the shared module home (.shell-home); these rules cover only what Brain adds. */
2
+ .intelligence-card-icon { display: inline-flex; flex: 0 0 auto; width: 16px; height: 16px; color: var(--lp-primary); }
3
+ .intelligence-card-icon svg { display: block; }
4
+ .intelligence-home > .home-section-head { margin-bottom: 16px; }
5
+ .intelligence-file-home { width: 100%; height: 100%; min-width: 0; }
6
+ .intelligence-file-page {
7
+ height: 100%; min-width: 0; overflow: auto; box-sizing: border-box; padding: var(--lp-content-inset);
8
+ display: flex; flex-direction: column; gap: var(--lp-section-gap); color: var(--lp-ink); font-size: var(--lp-fs-sm);
9
  }
10
+ .intelligence-file-page > * { width: 100%; max-width: 840px; }
11
+ .intelligence-file-head { flex-shrink: 0; }
12
+ .intelligence-file-head .home-title { margin: 0; min-width: 0; overflow-wrap: anywhere; }
13
+ .intelligence-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
14
+ .intelligence-drawer h2 { margin: 0; font-size: var(--lp-fs-lg); font-weight: var(--lp-fw-semibold); }
15
  .intelligence-button {
16
  border: 0; background: transparent; font: inherit; color: inherit;
17
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
 
20
  }
21
  .intelligence-button svg { flex-shrink: 0; }
22
  .intelligence-button:disabled { opacity: var(--lp-home-disabled-opacity); cursor: not-allowed; }
23
+ .intelligence-button:focus-visible,
24
+ :is(.intelligence-drawer, .intelligence-file-page) :is(input, textarea, select, a, pre, [tabindex]):focus-visible {
25
  outline: 2px solid var(--lp-blue-deep); outline-offset: 2px;
26
  }
27
  .intelligence-button[aria-pressed="true"] { background: var(--lp-blue-tint); color: var(--lp-blue-deep); }
28
  .intelligence-icon-button { width: 36px; padding: 8px; }
29
  .intelligence-primary { background: var(--lp-primary); color: var(--lp-surface); }
30
+ .intelligence-meta, .intelligence-file-by { color: var(--lp-muted); font-size: var(--lp-fs-2xs); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  .intelligence-meta { margin: 0 0 8px; }
32
  .intelligence-feedback { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 0; color: var(--lp-muted); }
33
  .intelligence-feedback span { overflow-wrap: anywhere; }
34
  .intelligence-empty { padding: 64px 16px; text-align: center; color: var(--lp-muted); }
 
35
  .intelligence-skeleton { display: flex; flex-direction: column; gap: 12px; padding: 24px 12px; }
36
  .intelligence-skeleton span { height: 12px; max-width: 360px; background: var(--lp-wash); border-radius: var(--lp-r-sm); }
37
  .intelligence-skeleton span:first-child { width: 48%; height: 16px; }
38
  .intelligence-skeleton span:last-child { width: 24%; }
39
+ /* The module home is washed, so its skeleton bars take the hairline ink to stay visible. */
40
+ .intelligence-home .intelligence-skeleton span { background: var(--lp-line); }
41
+ .intelligence-create :is(input, select, textarea) {
42
  border: 1px solid var(--lp-line); border-radius: var(--lp-r-sm); background: var(--lp-surface); color: var(--lp-ink); font: inherit; padding: 8px;
43
  }
 
 
44
  .intelligence-scrim { position: fixed; inset: 0; z-index: var(--cg-z-drawer); background: color-mix(in srgb, var(--lp-ink) 18%, transparent); }
45
  .intelligence-drawer {
46
  position: absolute; inset: 0 0 0 auto; width: min(680px, 100%); padding: var(--lp-content-inset);
 
67
  .intelligence-create label { display: flex; flex-direction: column; gap: 8px; font-size: var(--lp-fs-xs); }
68
  .intelligence-create :is(input, select) { min-height: 40px; width: 100%; }
69
  .intelligence-create textarea { resize: vertical; min-height: 200px; line-height: 1.6; }
 
70
  .intelligence-prompt { display: flex; flex-direction: column; gap: var(--lp-section-gap); }
71
  .intelligence-prompt-tools { border-top: 1px solid var(--lp-line); padding-top: 16px; }
72
  .intelligence-prompt-tools h3 { margin: 0 0 12px; font-size: var(--lp-fs-sm); font-weight: var(--lp-fw-semibold); }
 
87
  .intelligence-view-switch { display: flex; gap: 4px; margin-top: 16px; }
88
  .intelligence-drawer .intelligence-view-switch { margin-top: 0; }
89
  .intelligence-history, .intelligence-insights { min-width: 0; }
 
90
  .intelligence-history-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
91
  .intelligence-history h3, .intelligence-insights h2 { margin: 0 0 12px; font-size: var(--lp-fs-sm); font-weight: var(--lp-fw-semibold); }
92
  .intelligence-history-list { list-style: none; margin: 0 0 24px; padding: 0; max-height: 280px; overflow: auto; }
 
114
  .intelligence-primary:not(:disabled):hover { background: var(--lp-primary-hover); }
115
  }
116
  @media (max-width: 640px) {
117
+ .intelligence-file-page, .intelligence-drawer { padding: 16px; }
 
 
 
 
 
 
 
 
 
 
118
  }
119
  @media (prefers-reduced-motion: reduce) { .intelligence-drawer { animation: none; } }
web/src/styles/sdlc73/shell.css CHANGED
@@ -27,3 +27,8 @@
27
  display: none;
28
  }
29
  }
 
 
 
 
 
 
27
  display: none;
28
  }
29
  }
30
+
31
+ /* Recurring rests at the sibling icon opacity; index.css still dims `.shell-nav-auto` from wave 19. */
32
+ .shell-nav-auto:not(.is-active):not(.is-unavailable) .shell-nav-icon {
33
+ opacity: 0.55;
34
+ }
web/src/styles/wave55/apps.css CHANGED
@@ -12,6 +12,13 @@
12
  margin-bottom: 0;
13
  }
14
 
 
 
 
 
 
 
 
15
  .home-app-create {
16
  height: 32px;
17
  padding: 0 12px;
 
12
  margin-bottom: 0;
13
  }
14
 
15
+ /* One module home subtitle: a single muted line under the title (ModuleHomeHead). */
16
+ .home-page-head .home-subtitle {
17
+ margin: 8px 0 0;
18
+ color: var(--lp-muted);
19
+ font-size: var(--lp-fs-sm);
20
+ }
21
+
22
  .home-app-create {
23
  height: 32px;
24
  padding: 0 12px;
web/wiring_rows/hotfix73_report2.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Mount contracts for the SDLC 73 hotfix report 2 (Brain home, Recurring, module subtitles)."""
2
+
3
+ ROWS = [
4
+ ("H1 Brain home mounts the shared module head",
5
+ "home/ModuleHomeHead.tsx",
6
+ r'export function ModuleHomeHead\(\{ title, module, className \}[\s\S]*?MODULE_SUBTITLES\[module\]'
7
+ r'[\s\S]*?<h1 className="home-title">\{title\}</h1>[\s\S]*?className="home-subtitle"',
8
+ "intelligence/IntelligencePage.tsx",
9
+ r'<ModuleHomeHead title="Brain" module="intelligence" />'),
10
+ ("H4 every module home reads its subtitle from the one map",
11
+ "home/ModuleHomeHead.tsx",
12
+ r'export const MODULE_SUBTITLES = \{[\s\S]*?intelligence: "What your workspace knows",'
13
+ r'[\s\S]*?connectors: "Connect your tools and data",',
14
+ "home/HomePage.tsx",
15
+ r'<ModuleHomeHead title=\{moduleName\} module=\{mode === "agents" \? "automation" : mode === "home" \? undefined : mode\} />'),
16
+ ]