Files
open-design/design-templates/live-dashboard/example.html
b5eb8c1647 feat: generic skills + split skills/design-templates + finalize-design API (#955)
* feat: general-purpose skills with @-mention composition and user import

Lift skills from "one mode-bound skill per project" to a generic capability
the user can compose per turn:

- Daemon: scan multiple skill roots (user-skills under runtime data, then
  the bundled `skills/`); user-imported skills can shadow built-ins by id.
- New `POST /api/skills/import` and `DELETE /api/skills/:id` endpoints,
  with CONFLICT/BAD_REQUEST/NOT_FOUND error codes and built-in delete
  protection.
- ChatRequest gains `skillIds: string[]`; the chat run concatenates each
  picked skill's body (and merges craftRequires) into the system prompt
  for that turn only — the project's persistent `skillId` is untouched.
- Web composer: `@` popover now lists skills alongside project files;
  picks render as removable chips above the textarea and ride along with
  the request as `skillIds`.
- Settings → Library: import form (name/description/triggers/body),
  per-card delete for user skills, "user" origin badge.

* chore(web): drop welcome pet teaser + add ds→prompt-template mapping util

- SettingsDialog: remove the inline pet adoption teaser from the welcome
  panel so the first-run modal stays focused on configuration.
- New `inferPromptTemplateCategoriesForDs(ds)` helper that maps a design
  system's authored metadata to prompt-template gallery categories.
  Imported by the design-system gallery wiring on a sibling branch; no
  callers in this branch yet.

* feat: split skills/design-templates and add finalize-design API

Phase 0 of the skills/design-templates refactor (specs/current/
skills-and-design-templates.md):

- Move ~104 rendering catalogue entries from skills/ to design-templates/
  and keep skills/ for the small set of functional skills that *do work*
  on user input (utilities, briefs, packagers).
- Add design-templates/AGENTS.md and skills/AGENTS.md describing the
  contract, and a brand-agnostic craft/ surface for opt-in craft rules.
- Daemon: add DESIGN_TEMPLATES_DIR / USER_DESIGN_TEMPLATES_DIR roots and
  an /api/design-templates surface mirroring /api/skills. Asset/example
  routes still span both registries so existing srcdoc URLs keep
  resolving across the rename.
- Web: split LibrarySection into SkillsSection + DesignSystemsSection,
  rename the EntryView "Examples" tab to "Templates", and update locales
  + the New-project picker accordingly.

Adds the finalize-design endpoint:

- New apps/daemon/src/finalize-design.ts and packages/contracts/src/api/
  finalize.ts — one-shot synthesis of a project's transcript + active
  design system + current artifact into <projectDir>/DESIGN.md via the
  Anthropic Messages API. Per-project .finalize.lock mirrors the
  transcript-export hygiene from PR #493; provider credentials are not
  persisted by the daemon.

Other supporting changes:

- README + AGENTS.md updates to document the new directory split and
  craft/ surface, plus i18n strings across 13 locales.
- Test refactors and new coverage (finalize-design, runs, sidecar
  server, plus refreshed daemon integration tests).
- .gitignore: scope the *.exe ignore to /OpenDesign.exe so legitimate
  vendor binaries are no longer hidden.

* fix(merge): move clinical-case-report to design-templates/

Origin/main added the clinical-case-report skill under skills/ before
the skills/design-templates split landed. Its od.mode is prototype, so
per specs/current/skills-and-design-templates.md it is a design template
and belongs alongside the other rendering catalogue entries — not under
the slimmed-down functional skills/ root. Moving it keeps the EntryView
Templates tab consistent with origin/main's intent.

* feat(skills): curated design/creative catalogue + collapsible Settings rows

Seed ~100 curated design/creative skill stubs under skills/ sourced from
awesome-claude-skills (ComposioHQ) and awesome-agent-skills (VoltAgent).
Each stub carries an od.category tag so the new filter pill row in
Settings -> Skills can group them. The seed script
(scripts/seed-curated-design-skills.ts, pnpm seed:curated-design-skills)
is idempotent: it only creates folders that don't already exist, so
hand-edited stubs are never overwritten.

- Daemon: parse and surface od.category on SkillInfo with a strict slug
  normaliser; mirror the field on SkillSummary in @open-design/contracts.
  Category is purely a UI hint — system-prompt composition is unchanged.
- Web: rewrite SkillsSection from a left-list / right-detail grid into a
  vertical stack of collapsible rows mirroring the External MCP panel
  (header always visible with name + mode/source/category pills + per-row
  enable toggle; SKILL.md preview, file tree and inline edit form expand
  on demand). Add a Category filter row above the list. Reorder Settings
  nav so Skills + External MCP sit above the Composio/MCP cluster. Update
  composer placeholder/hint across 17 locales to advertise '@ files or
  skills · / for commands'.
- Docs: extend skills/AGENTS.md with the curated catalogue rules
  (idempotency, category vocabulary, no upstream vendoring).

Co-authored-by: Cursor <cursoragent@cursor.com>

* test(skills): teach localized-content + system-prompt tests about the skills/design-templates split

mrcfps blocking review on PR #955: the skills/design-templates split
(b5993385) moved ~110 SKILL.md entries out of `skills/` and into
`design-templates/`, but two repo-level tests still hard-coded the
single-root layout, so CI gates went red on the merged branch:

- `e2e/tests/localized-content.test.ts` only scanned `<repo>/skills`
  while the locale `skillCopy` map keeps id-keyed entries spanning
  both roots (ExamplesTab/Templates uses one lookup regardless of
  origin). Teach the helper to read both `skills/` and
  `design-templates/`, deduplicating ids so the union matches the
  localized claim.
- `apps/daemon/tests/prompts/system.test.ts` read
  `skills/live-artifact/SKILL.md`, which now lives under
  `design-templates/live-artifact/`. Update the absolute path so
  composeSystemPrompt's coverage of the live-artifact preamble is
  exercised again.

Also enroll the curated design/creative catalogue (PR #955, ~91
stubs sourced from awesome-claude-skills / awesome-agent-skills) in
the DE / FR / RU `_SKILL_IDS_WITH_EN_FALLBACK` lists. The stubs are
English-only by design (frontmatter advertises an upstream URL); the
fallback list is exactly the place to acknowledge "we know this id
exists, English copy is fine here" so the localized-content coverage
gate passes without forcing a translation task per locale.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(skills): always quote frontmatter name so importUserSkill round-trips numeric / boolean ids

mrcfps PR #955 review: `buildSkillMarkdown` emitted `name:
${escapeYamlString(name)}` without quotes, so YAML coerced names
like `123`, `true`, `false`, or `null` into non-string scalars on
re-parse. listSkills() then read `data.name` as a number/boolean
and the import flow's follow-up `findSkillById(skills, result.id)`
missed it, falling into `/api/skills/import`'s "imported skill
could not be re-read" 500 path for those ids.

Switch the emitter to a quoted scalar (`name: "..."`) — the
double-escape already in `escapeYamlString` makes the quoted form
safe — and add a round-trip test covering `123`, `true`, `false`,
`null`, and `0` to lock in the contract.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(web): drop staged-skill chips when the matching @<id> token leaves the draft

mrcfps PR #955 review: `submit()` always forwarded every id in
`stagedSkills`, but that state was only mutated on picker click and
chip removal. Hand-deleting an `@<id>` token from the textarea left
the chip staged, so the request still carried `skillIds: [<id>]` and
the daemon composed a skill the prompt no longer referenced.

Sync the chips with the draft inside `handleChange()` by pruning
`stagedSkills` whenever the new value no longer contains the
`@<id>` token (using the same whitespace boundary as
`removeStagedSkill`'s strip regex). Comment explains why this
prune does not run for `staged` file attachments — users frequently
add files via the upload button without leaving an `@<path>` token,
so a symmetric prune there would erase legitimate uploads.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(daemon): stage @-composed skills' side files alongside the active skill

codex PR #955 review: composing a per-turn `@`-picked skill into the
system prompt appended its body (with the `withSkillRootPreamble`
guidance pointing at relative paths under `<cwd>/.od-skills/<folder>/`)
but never staged the actual folder. `startChatRun` only copied
`activeSkillDir`, so when the project's primary skill was different
(or absent) the composed skill's references/, examples/, and scripts/
files lived only at their absolute repo path — agents that honour
the cwd-relative form (or that don't get `--add-dir`, e.g. Codex with
allowlisted gpt-image projects) couldn't reach them.

Thread the composed skills' dirs out of `composeDaemonSystemPrompt`
as `extraSkillDirs` and stage each one through the same
`stageActiveSkill` API used for the primary skill. Dedupe by folder
basename so a project whose primary skill is also `@`-composed isn't
copied twice. Each preamble already advertises its own folder, so the
prompt and the staged tree stay aligned without further changes.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(web): respect the Library disable toggle in the project @-mention picker

codex PR #955 review: only `EntryView` received `enabledSkills`
(filtered against `config.disabledSkills`); active projects still
got `skills={skills}` raw, so a skill the user disabled in Settings
kept appearing in the project's `@`-mention popover and could ride
along to the daemon via `skillIds`. That broke the Library toggle
for any project opened on the post-split branch.

Compute a functional-skills-only enabled subset
(`enabledFunctionalSkills`) and pass it into `<ProjectView>` instead.
Templates stay separate — design-templates are filtered through their
own `enabledDesignTemplates` memo for the Templates gallery — so
ProjectView's chat composer still only sees skills, never templates,
matching the pre-split prop surface.

Co-authored-by: Cursor <cursoragent@cursor.com>

* test(e2e): mock /api/design-templates for example-use-prompt flow

The Templates tab in EntryView fetches from /api/design-templates after
the skills/design-templates split (specs/current/skills-and-design-templates.md).
The example-use-prompt Playwright scenario only mocked /api/skills, so the
gallery card never appeared and the test timed out waiting on
example-card-warm-utility-example. Serve the same fixture summary on both
endpoints so the templates gallery renders the card the test clicks.

Co-authored-by: Cursor <cursoragent@cursor.com>

* test(tools-pack): create design-templates fixture for resources test

The packaging resources copy now bundles the new design-templates tree
alongside skills (see resources.ts BUNDLED_RESOURCE_TREES). The
copyBundledResourceTrees fixture only created skills, design-systems,
craft, etc., so the recursive copy crashed with ENOENT on
design-templates before it could check the prompt-templates assertion.
Add the missing fixture directory so the test exercises the same set
of resource trees the packaged build does.

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(skills): clone built-in side files into the shadow on first edit

mrcfps PR #955 review: editing a built-in skill wrote a USER_SKILLS_DIR
shadow folder that contained only a new SKILL.md. The next listSkills()
pass surfaced the shadow as the active dir, but every side-file resolver
(/api/skills/:id/files, /example, /assets/*, the system-prompt preamble,
and the per-turn cwd staging) reads through skill.dir. With nothing but
SKILL.md in the shadow, the bundled assets/, references/, scripts/, and
examples/ disappeared the moment the user hit save — a built-in like
last30days or live-artifact would break immediately after edit instead
of just having its body overridden.

Teach updateUserSkill() to take a `sourceDir` and clone every entry
except SKILL.md / dotfiles into the shadow on the very first edit. The
shadow stays self-contained, so all the resolvers keep working without
fallback bookkeeping. Subsequent edits detect the existing shadow and
skip the clone, so user tweaks under the side tree survive a re-save.

Wire `sourceDir: skill.dir` from server.ts's PUT /api/skills/:id handler
and add two regression tests:
- 'clones built-in side files into the shadow on the first edit' walks
  the file tree after save and asserts assets/template.html, references/
  notes.md, and scripts/helper.sh all round-trip from the built-in.
- 'preserves user-edited side files on subsequent edits' edits the
  staged assets/template.html, re-saves, and confirms the user content
  is still there.

Co-authored-by: Cursor <cursoragent@cursor.com>

* test(e2e): rename home tab from Examples to Templates

The Examples tab was renamed to Templates in EntryView (b5993385's
skills/design-templates split — entry.tabExamples became entry.tabTemplates
and the tab value moved from 'examples' to 'templates'), but
entry-chrome-flows still asserted the old label and testId. Update both.

* fix(skills+web): preserve template body in API mode and dir-based skill delete

Two follow-ups from PR #955 review:

1. ProjectView only received `enabledFunctionalSkills`, but
   `composedSystemPrompt()` still resolved `project.skillId` through that
   prop and `fetchSkill()`. Projects created from the new
   `/api/design-templates` surface keep a template id in `project.skillId`,
   so opening one in API mode dropped the template body from the system
   prompt and the upstream request ran without the project's primary
   template instructions. Now ProjectView takes a separate
   `designTemplates` prop (the unfiltered template list, so a
   later-disabled template still loads for projects already created from
   it) and `composedSystemPrompt()` plus the metadata / `isDeck` lookups
   fall back to that list, with `fetchDesignTemplate()` as the body-fetch
   fallback to `fetchSkill()`. The chat composer's `@`-picker keeps
   receiving only the enabled functional skills.

2. `DELETE /api/skills/:id` used `deleteUserSkill(USER_SKILLS_DIR, skill.id)`
   which re-slugified the frontmatter id and removed
   `<userSkillsDir>/<slug>/`. That matched the import shape but missed the
   install shape — `installFromTarget` writes the folder at
   `sanitizeRepoName(url)` (GitHub) or `path.basename(realpath)` (local
   symlink), neither of which is guaranteed to equal the slugified
   frontmatter `name`. A duplicate `app.delete('/api/skills/:id', ...)`
   handler at the install routes never fired because Express resolved the
   earlier registration first, leaving the install/uninstall path without
   working teardown. The handler now removes `skill.dir` (the absolute
   path listSkills already discovered) under a USER_SKILLS_DIR safety
   check, using `lstat` + `unlinkSync` so symlinked local installs unlink
   cleanly without recursing into the user's source tree. The dead
   duplicate handler is removed; `deleteUserSkill` is dropped from the
   server.ts import set (still exported and unit-tested in skills.ts).
   Regression coverage in `apps/daemon/tests/skills-delete-route.test.ts`
   pins both shapes plus the symlink-preserves-source case.

* test(daemon): point hyperframes system-prompt test at design-templates

The merge with main brought in a hyperframes system-prompt test that
reads `skills/hyperframes/SKILL.md`, but this branch's split moved
`hyperframes` into `design-templates/` (same migration as `live-artifact`
already handled above in this file). CI was failing with ENOENT on the
old path.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 17:48:34 +08:00

947 lines
36 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Acme · Team Dashboard</title>
<style>
:root {
--bg: #ffffff;
--bg-soft: #f7f6f3;
--bg-hover: #efeeec;
--ink: #37352f;
--ink-2: #787774;
--ink-3: #9b9a97;
--line: #ececea;
--line-strong: #d3d1cb;
--accent: #2eaadc;
--accent-ink: #0b6e91;
--pill-done-bg: #dbeddb; --pill-done-ink: #2b593f;
--pill-progress-bg: #fdecc8; --pill-progress-ink: #976d23;
--pill-blocked-bg: #ffe2dd; --pill-blocked-ink: #b13b2c;
--pill-todo-bg: #e9e5e3; --pill-todo-ink: #5a534f;
--pill-review-bg: #d3e5ef; --pill-review-ink: #1f5b78;
--shadow-card: 0 1px 0 rgba(15,15,15,0.04), 0 1px 2px rgba(15,15,15,0.04);
--radius-sm: 4px;
--radius-md: 6px;
--radius-lg: 10px;
}
* { box-sizing: border-box; }
html, body {
margin: 0; padding: 0;
background: var(--bg);
color: var(--ink);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
"Noto Sans", "PingFang SC", "Hiragino Sans GB", sans-serif;
font-size: 14px;
line-height: 1.5;
-webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
/* ---------- App shell ---------- */
.app {
display: grid;
grid-template-columns: 240px 1fr;
min-height: 100vh;
}
/* ---------- Sidebar ---------- */
.side {
background: var(--bg-soft);
border-right: 1px solid var(--line);
padding: 14px 8px;
user-select: none;
}
.ws {
display: flex; align-items: center; gap: 8px;
padding: 6px 8px; border-radius: var(--radius-sm);
cursor: pointer;
}
.ws:hover { background: var(--bg-hover); }
.ws-icon {
width: 22px; height: 22px; border-radius: 4px;
background: linear-gradient(135deg,#1f1f1f,#3a3a3a);
color: #fff; display: grid; place-items: center;
font-weight: 600; font-size: 12px;
}
.ws-name { font-weight: 600; flex: 1; font-size: 14px; }
.ws-caret { color: var(--ink-3); font-size: 12px; }
.side-search {
margin: 12px 4px 6px; padding: 5px 8px;
color: var(--ink-3); font-size: 13px;
display: flex; align-items: center; gap: 8px;
border-radius: var(--radius-sm); cursor: pointer;
}
.side-search:hover { background: var(--bg-hover); }
.side-search kbd {
margin-left: auto; font-family: inherit; font-size: 11px;
color: var(--ink-3); background: #fff; border: 1px solid var(--line);
padding: 1px 5px; border-radius: 3px;
}
.side-section {
margin-top: 14px; padding: 0 8px;
color: var(--ink-3); font-size: 12px; letter-spacing: .02em;
text-transform: uppercase;
}
.nav { margin-top: 4px; display: flex; flex-direction: column; gap: 1px; }
.nav-item {
display: flex; align-items: center; gap: 8px;
padding: 4px 8px; border-radius: var(--radius-sm);
color: var(--ink); cursor: pointer;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { background: #e8e6e1; font-weight: 500; }
.nav-icon { width: 18px; text-align: center; }
.nav-caret { margin-left: auto; color: var(--ink-3); font-size: 10px; }
/* ---------- Main ---------- */
.main {
display: flex; flex-direction: column;
min-width: 0;
}
.topbar {
height: 44px; padding: 0 16px;
border-bottom: 1px solid var(--line);
display: flex; align-items: center; gap: 12px;
color: var(--ink-2); font-size: 13px;
}
.crumbs span:not(:last-child)::after {
content: "/"; margin: 0 6px; color: var(--ink-3);
}
.topbar-spacer { flex: 1; }
.pill-live {
display: inline-flex; align-items: center; gap: 6px;
padding: 2px 8px 2px 6px; background: #fff;
border: 1px solid var(--line-strong); border-radius: 999px;
font-size: 12px; color: var(--ink-2);
}
.pill-live .dot {
width: 7px; height: 7px; border-radius: 50%;
background: #2ecc71; box-shadow: 0 0 0 0 rgba(46,204,113,.55);
animation: pulse 1.8s infinite;
}
.pill-live.stale .dot { background: #e6a23c; animation: none; }
/* "Sample data" — no real connector is bound. Stays grey and static
so the artifact does not claim a live data source it does not have. */
.pill-live.sample {
background: var(--bg-soft); color: var(--ink-3);
border-color: var(--line);
}
.pill-live.sample .dot {
background: var(--ink-4); animation: none; box-shadow: none;
}
@keyframes pulse {
0% { box-shadow: 0 0 0 0 rgba(46,204,113,.55); }
70% { box-shadow: 0 0 0 7px rgba(46,204,113,0); }
100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); }
}
.page {
padding: 56px max(80px, 8vw) 80px;
max-width: 1100px;
width: 100%;
align-self: center;
}
.page-cover {
height: 24px; /* keep airy like Notion default */
}
.page-emoji {
font-size: 64px; line-height: 1;
margin: -4px 0 12px; cursor: default;
}
h1.page-title {
font-size: 40px; line-height: 1.15;
font-weight: 700; letter-spacing: -0.01em;
margin: 0 0 8px; color: var(--ink);
}
.page-meta {
display: flex; align-items: center; gap: 14px;
color: var(--ink-2); font-size: 13px; margin-bottom: 28px;
}
.page-meta .updated { display: inline-flex; align-items: center; gap: 6px; }
.page-meta .updated .who {
width: 18px; height: 18px; border-radius: 50%;
background: #f1c40f; color: #5a4500;
display: inline-grid; place-items: center;
font-size: 11px; font-weight: 700;
}
.btn {
display: inline-flex; align-items: center; gap: 6px;
padding: 4px 10px; font-size: 13px; color: var(--ink);
background: #fff; border: 1px solid var(--line-strong);
border-radius: var(--radius-sm); cursor: pointer;
transition: background .15s ease, transform .15s ease;
}
.btn:hover { background: var(--bg-hover); }
.btn .ico { width: 14px; height: 14px; display: inline-block; }
.btn .ico.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }
/* ---------- Callout ---------- */
.callout {
background: var(--bg-soft);
border-radius: var(--radius-md);
padding: 14px 16px;
display: flex; gap: 12px; align-items: flex-start;
margin: 10px 0 28px;
color: var(--ink);
}
.callout .emj { font-size: 18px; line-height: 1.4; }
.callout small { color: var(--ink-2); }
/* ---------- KPI grid ---------- */
.kpis {
display: grid; grid-template-columns: repeat(4, 1fr);
gap: 1px; background: var(--line);
border: 1px solid var(--line); border-radius: var(--radius-md);
overflow: hidden; margin: 8px 0 32px;
}
.kpi {
background: #fff; padding: 18px 20px;
display: flex; flex-direction: column; gap: 4px;
}
.kpi .label {
color: var(--ink-2); font-size: 12px; letter-spacing: .03em;
text-transform: uppercase; font-weight: 500;
}
.kpi .value {
font-size: 32px; font-weight: 600; letter-spacing: -0.01em;
color: var(--ink);
font-variant-numeric: tabular-nums;
transition: color .25s ease;
}
.kpi .value.flash { color: var(--accent-ink); }
.kpi .delta { font-size: 12px; color: var(--ink-2); }
.kpi .delta.up { color: #2b8a3e; }
.kpi .delta.down { color: #c0392b; }
.kpi .delta .arr { display: inline-block; width: 10px; }
/* ---------- Section heading ---------- */
h2.h {
font-size: 18px; font-weight: 600;
margin: 32px 0 8px; letter-spacing: -0.005em;
}
.h-sub { color: var(--ink-2); font-size: 13px; margin-bottom: 12px; }
/* ---------- Two-col block ---------- */
.two-col {
display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px;
margin-bottom: 8px;
}
/* Sparkline card */
.card {
background: #fff; border: 1px solid var(--line);
border-radius: var(--radius-md); padding: 16px 18px;
}
.card-title {
display: flex; align-items: center; justify-content: space-between;
font-size: 13px; color: var(--ink-2); margin-bottom: 8px;
}
.card-title strong { color: var(--ink); font-weight: 600; }
.spark { width: 100%; height: 120px; }
.spark-axis { color: var(--ink-3); font-size: 11px; }
.spark-fill { fill: rgba(46,170,220,.10); }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.spark-dot { fill: var(--accent); }
.spark-grid line { stroke: var(--line); stroke-dasharray: 2 3; }
/* Activity feed */
.feed { display: flex; flex-direction: column; }
.feed-row {
display: flex; gap: 12px; padding: 10px 4px;
border-bottom: 1px solid var(--line);
}
.feed-row:last-child { border-bottom: none; }
.feed-row .av {
flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%;
display: grid; place-items: center;
color: #fff; font-size: 11px; font-weight: 700;
}
.feed-row .body { flex: 1; min-width: 0; font-size: 13px; }
.feed-row .body .who { font-weight: 600; }
.feed-row .body .what { color: var(--ink); }
.feed-row .body .target { color: var(--accent-ink); border-bottom: 1px dotted var(--accent); cursor: pointer; }
.feed-row .time { color: var(--ink-3); font-size: 12px; flex: 0 0 auto; }
.feed-row.new { background: rgba(46,170,220,.06); }
.feed-row.new .body .who::before {
content: "•"; color: var(--accent); margin-right: 6px;
}
/* ---------- Database table ---------- */
.db {
border: 1px solid var(--line); border-radius: var(--radius-md);
overflow: hidden; margin-top: 4px;
background: #fff;
}
.db-head, .db-row {
display: grid;
grid-template-columns: 32px 2.4fr 1fr 1fr 0.9fr 0.9fr;
align-items: center;
padding: 8px 12px;
border-bottom: 1px solid var(--line);
font-size: 13px;
}
.db-head {
background: var(--bg-soft); color: var(--ink-2);
font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
font-weight: 500;
}
.db-row:last-child { border-bottom: none; }
.db-row:hover { background: var(--bg-soft); }
.db-row.changed { animation: rowflash 1.4s ease; }
@keyframes rowflash {
0% { background: rgba(46,170,220,.18); }
100% { background: transparent; }
}
.db-cell.title { font-weight: 500; display: flex; align-items: center; gap: 6px; min-width: 0; }
.db-cell.title .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-cell .pill {
display: inline-flex; align-items: center; gap: 4px;
padding: 2px 8px; border-radius: 3px;
font-size: 12px; font-weight: 500;
}
.pill.done { background: var(--pill-done-bg); color: var(--pill-done-ink); }
.pill.progress { background: var(--pill-progress-bg); color: var(--pill-progress-ink); }
.pill.blocked { background: var(--pill-blocked-bg); color: var(--pill-blocked-ink); }
.pill.todo { background: var(--pill-todo-bg); color: var(--pill-todo-ink); }
.pill.review { background: var(--pill-review-bg); color: var(--pill-review-ink); }
.person {
display: inline-flex; align-items: center; gap: 6px;
}
.person .av {
width: 18px; height: 18px; border-radius: 50%;
color: #fff; display: grid; place-items: center;
font-size: 10px; font-weight: 700;
}
/* ---------- Footer ---------- */
.footer {
margin-top: 32px; padding-top: 16px;
border-top: 1px solid var(--line);
color: var(--ink-3); font-size: 12px;
display: flex; align-items: center; gap: 8px;
}
.footer .key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
background: var(--bg-soft); padding: 1px 5px; border-radius: 3px; color: var(--ink-2); }
/* ---------- Toast ---------- */
.toast {
position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
background: #1f1f1f; color: #fff; padding: 8px 14px;
border-radius: 8px; font-size: 13px;
opacity: 0; pointer-events: none;
transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-2px); }
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 980px) {
.app { grid-template-columns: 1fr; }
.side { display: none; }
.page { padding: 32px 20px 64px; }
.kpis { grid-template-columns: repeat(2, 1fr); }
.two-col { grid-template-columns: 1fr; }
.db-head, .db-row { grid-template-columns: 24px 1.8fr 0.8fr 0.8fr; }
.db-cell.due, .db-cell.priority { display: none; }
}
</style>
</head>
<body>
<div class="app">
<!-- ============ SIDEBAR ============ -->
<!-- Sidebar rows are interactive — every clickable .ws / .side-search /
.nav-item carries role="button" + tabindex="0" so keyboard users
can reach them. Activation handlers are wired in the script below. -->
<aside class="side">
<div class="ws" role="button" tabindex="0">
<div class="ws-icon">A</div>
<div class="ws-name">Acme Studio</div>
<div class="ws-caret">⌄</div>
</div>
<div class="side-search" role="button" tabindex="0">
<span>🔎</span><span>Search</span><kbd>⌘K</kbd>
</div>
<div class="side-search" role="button" tabindex="0">
<span>⌚</span><span>Updates</span>
</div>
<div class="side-search" role="button" tabindex="0">
<span>⚙️</span><span>Settings & members</span>
</div>
<div class="side-section">Workspace</div>
<div class="nav">
<div class="nav-item active" role="button" tabindex="0" aria-current="page">
<span class="nav-icon">📊</span><span>Team Dashboard</span>
</div>
<div class="nav-item" role="button" tabindex="0">
<span class="nav-icon">✅</span><span>Tasks</span>
<span class="nav-caret">›</span>
</div>
<div class="nav-item" role="button" tabindex="0">
<span class="nav-icon">📓</span><span>Docs</span>
<span class="nav-caret">›</span>
</div>
<div class="nav-item" role="button" tabindex="0">
<span class="nav-icon">🚀</span><span>Roadmap</span>
</div>
<div class="nav-item" role="button" tabindex="0">
<span class="nav-icon">🧠</span><span>Brain dump</span>
</div>
</div>
<div class="side-section">Private</div>
<div class="nav">
<div class="nav-item" role="button" tabindex="0"><span class="nav-icon">🗒️</span><span>Daily journal</span></div>
<div class="nav-item" role="button" tabindex="0"><span class="nav-icon">📥</span><span>Inbox</span></div>
</div>
<div class="side-section">Connections</div>
<div class="nav">
<div class="nav-item" role="button" tabindex="0"><span class="nav-icon">🔌</span><span>Notion · acme.so</span></div>
</div>
</aside>
<!-- ============ MAIN ============ -->
<main class="main">
<div class="topbar">
<div class="crumbs">
<span>Acme Studio</span>
<span>Workspace</span>
<span>Team Dashboard</span>
</div>
<div class="topbar-spacer"></div>
<div class="pill-live sample" id="livePill" title="No connector bound — values below are seeded sample data">
<span class="dot"></span>
<span id="liveText">Sample data</span>
</div>
</div>
<div class="page">
<div class="page-cover"></div>
<div class="page-emoji">📊</div>
<h1 class="page-title">Team Dashboard</h1>
<div class="page-meta">
<div class="updated">
<span class="who">SC</span>
<span>Last edited by <strong>Sarah Chen</strong></span>
</div>
<span>·</span>
<span id="updatedAt">Last refreshed just now</span>
<span style="flex:1"></span>
<button class="btn ghost" id="autoBtn" title="Auto refresh every 30s">
<span>⏱</span><span id="autoLbl">Auto · on</span>
</button>
<button class="btn primary" id="refreshBtn" title="Pull latest from Notion (sample mode — refreshes seeded data)">
<span class="ico" id="refreshIco">↻</span>
<span>Refresh from Notion</span>
</button>
</div>
<div class="callout">
<div class="emj">💡</div>
<div>
<div><strong>This page is a Live Artifact running on sample data.</strong>
The shape mirrors what the <strong>Acme Studio</strong> Notion workspace
would return through the Composio connector — but the numbers, names,
tasks and activity below are seeded fixtures, not a real workspace.</div>
<small>When a connector is bound, the pill switches to <em>Live · synced</em>
and the same renderer paints real data. Until then, refreshes only
tween the seeded fixture so the live behaviors stay demo-able offline.</small>
</div>
</div>
<!-- KPI -->
<div class="kpis">
<div class="kpi">
<div class="label">Total tasks</div>
<div class="value" id="kTotal">142</div>
<div class="delta up"><span class="arr">↑</span> 6 vs last week</div>
</div>
<div class="kpi">
<div class="label">Done this week</div>
<div class="value" id="kDone">23</div>
<div class="delta up"><span class="arr">↑</span> 4 vs last week</div>
</div>
<div class="kpi">
<div class="label">Active members</div>
<div class="value" id="kPeople">11<span style="color:var(--ink-3); font-size:18px; font-weight:500"> / 14</span></div>
<div class="delta">· Stable</div>
</div>
<div class="kpi">
<div class="label">Docs awaiting review</div>
<div class="value" id="kReview">7</div>
<div class="delta down"><span class="arr">↓</span> 2 vs last week</div>
</div>
</div>
<!-- Two col -->
<div class="two-col">
<div class="card">
<div class="card-title">
<strong>Tasks created · last 7 days</strong>
<span id="sparkSum">98 total</span>
</div>
<svg class="spark" viewBox="0 0 600 140" preserveAspectRatio="none" id="sparkSvg">
<!-- grid -->
<g class="spark-grid">
<line x1="0" y1="35" x2="600" y2="35"/>
<line x1="0" y1="70" x2="600" y2="70"/>
<line x1="0" y1="105" x2="600" y2="105"/>
</g>
<path class="spark-fill" id="sparkFill" d=""></path>
<path class="spark-line" id="sparkLine" d=""></path>
<g id="sparkDots"></g>
<g id="sparkLabels" class="spark-axis"></g>
</svg>
</div>
<div class="card">
<div class="card-title">
<strong>Recent activity</strong>
<span>From <span style="color:var(--accent-ink)">Notion</span></span>
</div>
<div class="feed" id="feed"></div>
</div>
</div>
<!-- Database -->
<h2 class="h">📋 Tasks · Active sprint</h2>
<div class="h-sub">Linked database · filtered by Status ≠ Done · sorted by Updated time</div>
<div class="db" id="db">
<div class="db-head">
<div></div>
<div>Name</div>
<div>Status</div>
<div>Assignee</div>
<div class="db-cell due">Due</div>
<div class="db-cell priority">Priority</div>
</div>
<!-- rows injected -->
</div>
<div class="footer">
<span>Source: Notion API · workspace <strong>acme.so</strong></span>
<span>·</span>
<span>Connector <span class="key">composio.notion</span></span>
<span>·</span>
<span id="footerTime"></span>
</div>
</div>
</main>
</div>
<div class="toast" id="toast">Synced — 3 changes from Notion</div>
<script>
(function(){
// ---------- Fake data state ----------
const PEOPLE = [
{ id: "SC", name: "Sarah Chen", color: "#f1c40f" },
{ id: "MK", name: "Mike Park", color: "#3498db" },
{ id: "LZ", name: "Lisa Zhao", color: "#e67e22" },
{ id: "DT", name: "Dave Torres", color: "#9b59b6" },
{ id: "AN", name: "Anna Nakamura",color: "#1abc9c" },
{ id: "RJ", name: "Raj Patel", color: "#e74c3c" }
];
const ROW_POOL = [
{ icon: "🚀", title: "Q3 Roadmap planning", status: "progress", who: "SC", due: "May 12", prio: "High" },
{ icon: "📐", title: "Design tokens v2 spec", status: "review", who: "LZ", due: "May 14", prio: "Med" },
{ icon: "🐛", title: "Fix mobile nav overflow on iOS", status: "blocked", who: "MK", due: "May 09", prio: "High" },
{ icon: "📊", title: "Pricing experiment readout", status: "todo", who: "DT", due: "May 18", prio: "Low" },
{ icon: "✍️", title: "Launch blog draft · Live Artifacts", status: "progress", who: "AN", due: "May 11", prio: "High" },
{ icon: "🔐", title: "Rotate Notion integration token", status: "todo", who: "RJ", due: "May 20", prio: "Med" },
{ icon: "🧪", title: "QA onboarding flow regressions", status: "review", who: "MK", due: "May 16", prio: "Med" },
{ icon: "🎨", title: "Refresh marketing OG images", status: "progress", who: "LZ", due: "May 13", prio: "Low" }
];
const ACTIVITY_TEMPLATES = [
(p, t) => ({ who: p, action: "moved", target: t, suffix: "to Done", icon: "✅" }),
(p, t) => ({ who: p, action: "created", target: t, suffix: "in Tasks", icon: "➕" }),
(p, t) => ({ who: p, action: "commented on", target: t, suffix: "", icon: "💬" }),
(p, t) => ({ who: p, action: "updated", target: t, suffix: "properties", icon: "✏️" }),
(p, t) => ({ who: p, action: "shared", target: t, suffix: "with Marketing", icon: "🔗" }),
(p, t) => ({ who: p, action: "added", target: t, suffix: "to sprint", icon: "📌" })
];
const SEED_FEED = [
{ who: "Sarah Chen", action: "moved", target: "Q3 Roadmap planning", suffix: "to In progress", icon: "🚀", mins: 3 },
{ who: "Mike Park", action: "commented on", target: "Fix mobile nav overflow on iOS", suffix: "", icon: "💬", mins: 11 },
{ who: "Lisa Zhao", action: "created", target: "Design tokens v2 spec", suffix: "in Docs", icon: "📐", mins: 26 },
{ who: "Anna Nakamura",action: "shared", target: "Launch blog draft · Live Artifacts", suffix: "with Marketing", icon: "🔗", mins: 41 },
{ who: "Dave Torres", action: "updated", target: "Pricing experiment readout", suffix: "properties", icon: "✏️", mins: 58 }
];
let kpi = { total: 142, done: 23, people: 11, peopleAll: 14, review: 7 };
let series = [8, 12, 15, 9, 18, 22, 14];
let dayLabels = ["Wed","Thu","Fri","Sat","Sun","Mon","Tue"];
let lastRefresh = new Date();
let autoOn = true;
let autoTimer = null;
// ---------- DOM refs ----------
const $ = (id) => document.getElementById(id);
const refreshBtn = $("refreshBtn");
const refreshIco = $("refreshIco");
const autoBtn = $("autoBtn");
const autoLbl = $("autoLbl");
const updatedAt = $("updatedAt");
const liveText = $("liveText");
const livePill = $("livePill");
const toast = $("toast");
const footerTime = $("footerTime");
// ---------- Helpers ----------
// Every dynamic value rendered into innerHTML below goes through e():
// task titles / activity strings / person names can come from a
// connector payload, and unescaped innerHTML is a working XSS sink.
function e(v) {
return String(v == null ? "" : v)
.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;")
.replaceAll('"', "&quot;").replaceAll("'", "&#39;");
}
function avatar(personId) {
const p = PEOPLE.find(x => x.id === personId);
if (!p) return "";
return `<span class="av" style="background:${e(p.color)}">${e(p.id)}</span>`;
}
function personChip(personId) {
const p = PEOPLE.find(x => x.id === personId);
if (!p) return "";
return `<span class="person">${avatar(personId)}<span>${e(p.name)}</span></span>`;
}
function timeAgo(date) {
const s = Math.max(0, Math.floor((Date.now() - date.getTime()) / 1000));
if (s < 5) return "just now";
if (s < 60) return s + "s ago";
const m = Math.floor(s / 60);
if (m < 60) return m + " min ago";
const h = Math.floor(m / 60);
if (h < 24) return h + " h ago";
return Math.floor(h/24) + " d ago";
}
function fmtDateTime(d) {
return d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) +
" · " + d.toLocaleDateString([], { month: "short", day: "numeric" });
}
function rand(arr) { return arr[Math.floor(Math.random() * arr.length)]; }
// Reduced-motion gate. The CSS @media block above already neutralizes
// CSS animations/transitions, but tweenText() schedules JS rAF updates
// and flash() toggles a transient highlight class — both keep moving
// for opted-out users unless we short-circuit them here.
function reduceMotion() {
return typeof window !== "undefined"
&& typeof window.matchMedia === "function"
&& window.matchMedia("(prefers-reduced-motion: reduce)").matches;
}
function tween(el, from, to, ms = 600) {
if (!el) return;
if (from === to || reduceMotion()) {
el.firstChild ? (el.childNodes[0].nodeValue = to) : (el.textContent = to);
return;
}
const start = performance.now();
function step(now) {
const t = Math.min(1, (now - start) / ms);
const eased = 1 - Math.pow(1 - t, 3);
const v = Math.round(from + (to - from) * eased);
el.firstChild ? (el.childNodes[0].nodeValue = v) : (el.textContent = v);
if (t < 1) requestAnimationFrame(step);
}
requestAnimationFrame(step);
}
// ---------- Render: KPI ----------
function renderKpi(prev) {
const flash = (el) => {
if (!el || reduceMotion()) return;
el.classList.add("flash");
setTimeout(() => el.classList.remove("flash"), 700);
};
if (prev) {
tweenText($("kTotal"), prev.total, kpi.total); if (prev.total !== kpi.total) flash($("kTotal"));
tweenText($("kDone"), prev.done, kpi.done); if (prev.done !== kpi.done) flash($("kDone"));
tweenText($("kReview"), prev.review, kpi.review); if (prev.review !== kpi.review) flash($("kReview"));
// people render keeps html — numeric values are safe but pass them
// through e() anyway so connector-driven payloads can flow through
// this same path without revisiting the markup.
$("kPeople").innerHTML = e(kpi.people) + `<span style="color:var(--ink-3); font-size:18px; font-weight:500"> / ${e(kpi.peopleAll)}</span>`;
if (prev.people !== kpi.people) flash($("kPeople"));
} else {
$("kTotal").textContent = kpi.total;
$("kDone").textContent = kpi.done;
$("kReview").textContent = kpi.review;
$("kPeople").innerHTML = e(kpi.people) + `<span style="color:var(--ink-3); font-size:18px; font-weight:500"> / ${e(kpi.peopleAll)}</span>`;
}
}
function tweenText(el, from, to, ms = 600) {
if (!el) return;
if (from === to || reduceMotion()) { el.textContent = String(to); return; }
const start = performance.now();
function step(now) {
const t = Math.min(1, (now - start) / ms);
const eased = 1 - Math.pow(1 - t, 3);
const v = Math.round(from + (to - from) * eased);
el.textContent = v;
if (t < 1) requestAnimationFrame(step);
}
requestAnimationFrame(step);
}
// ---------- Render: sparkline ----------
function renderSpark() {
const W = 600, H = 140, padL = 24, padR = 16, padT = 10, padB = 24;
const max = Math.max(...series, 1);
const stepX = (W - padL - padR) / (series.length - 1);
const pts = series.map((v, i) => {
const x = padL + i * stepX;
const y = padT + (1 - v / (max * 1.15)) * (H - padT - padB);
return [x, y];
});
const linePath = "M " + pts.map(p => p.join(" ")).join(" L ");
const fillPath = linePath + ` L ${pts[pts.length-1][0]} ${H - padB} L ${pts[0][0]} ${H - padB} Z`;
$("sparkLine").setAttribute("d", linePath);
$("sparkFill").setAttribute("d", fillPath);
const dots = pts.map(([x,y]) => `<circle class="spark-dot" cx="${x}" cy="${y}" r="3"/>`).join("");
$("sparkDots").innerHTML = dots;
const labels = dayLabels.map((d, i) => {
const x = padL + i * stepX;
return `<text x="${x}" y="${H - 6}" text-anchor="middle">${d}</text>`;
}).join("");
$("sparkLabels").innerHTML = labels;
$("sparkSum").textContent = series.reduce((a,b)=>a+b,0) + " total";
}
// ---------- Render: feed ----------
let feed = SEED_FEED.map(x => ({...x, when: new Date(Date.now() - x.mins * 60 * 1000), id: cryptoRandomId() }));
function cryptoRandomId() { return "f" + Math.random().toString(36).slice(2, 9); }
function renderFeed(highlightId) {
const el = $("feed");
// Drop the transient .new highlight under reduced-motion so the row
// doesn't get a coloured background pulse for users who opted out.
const effectiveHighlight = reduceMotion() ? null : highlightId;
el.innerHTML = feed.slice(0, 6).map(item => {
const initials = String(item.who||"").split(" ").map(s => s[0]).join("").slice(0,2).toUpperCase();
const color = personColor(item.who);
const cls = item.id === effectiveHighlight ? "feed-row new" : "feed-row";
const suffixHtml = item.suffix ? `<span class="what"> ${e(item.suffix)}</span>` : "";
return `
<div class="${cls}" data-id="${e(item.id)}">
<span class="av" style="background:${e(color)}">${e(initials)}</span>
<div class="body">
<span class="who">${e(item.who)}</span>
<span class="what"> ${e(item.action)}</span>
<span class="target"> ${e(item.icon || "")} ${e(item.target)}</span>
${suffixHtml}
</div>
<div class="time" title="${e(item.when.toLocaleString())}">${e(timeAgo(item.when))}</div>
</div>`;
}).join("");
}
function personColor(name) {
const p = PEOPLE.find(x => x.name === name);
return p ? p.color : "#7f8c8d";
}
// ---------- Render: db rows ----------
let rows = ROW_POOL.slice(0, 6).map((r, i) => ({...r, id: "r"+i, updated: Date.now() - (i+1)*1800000 }));
function renderRows(changedId) {
const head = document.querySelector(".db-head");
const db = $("db");
[...db.querySelectorAll(".db-row")].forEach(n => n.remove());
const sorted = [...rows].sort((a,b) => b.updated - a.updated);
const STATUS_LABEL = { done: "Done", progress: "In progress", blocked: "Blocked", todo: "To do", review: "In review" };
// Same reduced-motion gate as renderFeed: skip the .changed
// row-flash class so we don't paint a transient highlight for
// opted-out users (the rowflash CSS animation is already neutralized
// by the prefers-reduced-motion @media block above, but the class
// would still imply intent).
const effectiveChanged = reduceMotion() ? null : changedId;
sorted.forEach(r => {
const div = document.createElement("div");
div.className = "db-row" + (r.id === effectiveChanged ? " changed" : "");
div.dataset.id = r.id;
const statusKey = STATUS_LABEL[r.status] ? r.status : "todo";
const statusLabel = STATUS_LABEL[statusKey];
div.innerHTML = `
<div class="db-cell">${e(r.icon)}</div>
<div class="db-cell title"><span class="t">${e(r.title)}</span></div>
<div class="db-cell"><span class="pill ${statusKey}">${e(statusLabel)}</span></div>
<div class="db-cell">${personChip(r.who)}</div>
<div class="db-cell due">${e(r.due)}</div>
<div class="db-cell priority">${e(r.prio)}</div>
`;
db.appendChild(div);
});
}
// ---------- Refresh logic (the live bit) ----------
let busy = false;
async function refresh({silent = false} = {}) {
if (busy) return;
busy = true;
refreshIco.classList.add("spin");
livePill.classList.remove("stale");
liveText.textContent = "Syncing…";
// Simulate latency to a Notion API call.
await new Promise(r => setTimeout(r, 700 + Math.random() * 600));
const prev = {...kpi};
const changes = [];
// Mutate state in plausible directions.
const newDone = Math.random() < 0.7 ? 1 : 0;
if (newDone) {
kpi.done += 1;
kpi.total += Math.random() < 0.5 ? 1 : 0;
// flip a row to done
const candidates = rows.filter(r => r.status !== "done");
if (candidates.length) {
const r = rand(candidates);
r.status = "done";
r.updated = Date.now();
changes.push({ kind: "row", id: r.id, row: r });
}
} else {
// a brand new task created
const rest = ROW_POOL.filter(p => !rows.some(r => r.title === p.title));
const tmpl = rest.length ? rand(rest) : rand(ROW_POOL);
const r = { ...tmpl, id: "r" + Date.now(), status: "todo", updated: Date.now() };
rows = [r, ...rows].slice(0, 8);
kpi.total += 1;
changes.push({ kind: "row", id: r.id, row: r });
}
if (Math.random() < 0.4) {
kpi.review = Math.max(0, kpi.review + (Math.random() < 0.5 ? -1 : 1));
}
if (Math.random() < 0.25) {
kpi.people = Math.min(kpi.peopleAll, Math.max(6, kpi.people + (Math.random() < 0.5 ? -1 : 1)));
}
// Series shift: today's bucket gains 1-3
series = series.slice();
series[series.length - 1] = series[series.length - 1] + 1 + Math.floor(Math.random()*2);
// Add a new feed item
const lastChange = changes[changes.length - 1];
const person = rand(PEOPLE);
const tmpl = rand(ACTIVITY_TEMPLATES);
const targetTitle = lastChange ? lastChange.row.title : rand(ROW_POOL).title;
const evt = tmpl(person.name, targetTitle);
evt.when = new Date();
evt.id = cryptoRandomId();
feed = [evt, ...feed].slice(0, 8);
lastRefresh = new Date();
busy = false;
refreshIco.classList.remove("spin");
// Only mock-mode here — keep the "Sample data" badge so the artifact
// never falsely claims a real connector is bound.
liveText.textContent = "Sample data";
livePill.classList.remove("stale");
livePill.classList.add("sample");
renderKpi(prev);
renderSpark();
renderFeed(evt.id);
renderRows(lastChange ? lastChange.id : null);
updateTimes();
if (!silent) showToast("Refreshed sample data · 1 task moved, 1 activity added");
}
function showToast(msg) {
toast.textContent = msg;
toast.classList.add("show");
clearTimeout(showToast._t);
showToast._t = setTimeout(() => toast.classList.remove("show"), 1800);
}
function updateTimes() {
updatedAt.textContent = "Last refreshed " + timeAgo(lastRefresh);
footerTime.textContent = "Last sync · " + fmtDateTime(lastRefresh);
// Sample mode (no connector bound) is sticky — the artifact never
// claims "Live · synced" against fixture data. The pill only escalates
// to "Stale · …" if even the sample-refresh loop has not run for a
// while (e.g. the auto-refresh was paused).
if ((Date.now() - lastRefresh.getTime()) > 90 * 1000) {
livePill.classList.add("stale");
livePill.classList.remove("sample");
liveText.textContent = "Stale · " + timeAgo(lastRefresh);
} else {
livePill.classList.remove("stale");
livePill.classList.add("sample");
liveText.textContent = "Sample data";
}
}
// ---------- Keyboard activation for role=button divs ----------
// .ws / .side-search / .nav-item are styled as clickable rows but they
// are <div>, so keyboard users get nothing for free. Map Enter/Space
// onto a synthetic click and prevent the default Space scroll.
document.addEventListener("keydown", (ev) => {
if (ev.key !== "Enter" && ev.key !== " ") return;
const t = ev.target;
if (!(t instanceof HTMLElement)) return;
if (t.getAttribute("role") !== "button") return;
if (t.matches("button, a, input, select, textarea")) return;
ev.preventDefault();
t.click();
});
// ---------- Init ----------
function init() {
renderKpi();
renderSpark();
renderFeed();
renderRows();
updateTimes();
// "Refresh on open" — the moment the artifact mounts.
setTimeout(() => refresh({silent: true}), 600);
}
// ---------- Wire events ----------
refreshBtn.addEventListener("click", () => refresh());
autoBtn.addEventListener("click", () => {
autoOn = !autoOn;
autoLbl.textContent = "Auto · " + (autoOn ? "on" : "off");
if (autoOn) startAuto(); else stopAuto();
});
function startAuto() { stopAuto(); autoTimer = setInterval(() => refresh({silent: true}), 30 * 1000); }
function stopAuto() { if (autoTimer) clearInterval(autoTimer); autoTimer = null; }
setInterval(updateTimes, 5 * 1000);
// Tick relative timestamps in feed every 15s
setInterval(() => renderFeed(), 15 * 1000);
startAuto();
init();
})();
</script>
</body>
</html>