jt-workspace-dashboard 0.1.2 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,14 +21,14 @@ Publishing uses npm trusted publishing, linked to `.github/workflows/publish.yml
21
21
  {
22
22
  title: "Dashboard",
23
23
  ownerName: "Jeremy",
24
- labels: { ready: "Paused" }, // optional: Todoist label names (defaults below)
24
+ labels: { ready: "Paused" }, // optional: Todoist label names for every workspace (defaults below)
25
25
  workspaces: [
26
26
  {
27
27
  id: "personal", name: "Personal", accent: "#2B8A6E",
28
28
  todoist: { projectId: "…" }, // or projectIds: [...]
29
- sections: { ready: "Paused" }, // display names; ids are fixed
29
+ labels: { ready: "Ready to show" }, // optional: this workspace's label names (= section names)
30
30
  calendar: { ids: ["primary"], hide: ["Time Blocking"] }, // or false
31
- updateTask: "trig_…", updateLabel: "Sort inbox",
31
+ updateTask: "trig_…",
32
32
  features: { handoff: false, meetingAsks: false, showFollowUp: false, chatLink: false }
33
33
  }
34
34
  ]
@@ -37,19 +37,23 @@ Publishing uses npm trusted publishing, linked to `.github/workflows/publish.yml
37
37
 
38
38
  The page's database (only used for the update button's status line) is read at `meta/status-<workspace id>`.
39
39
 
40
+ **Loading:** the page shows the last tasks and today's calendar it saw (saved in the browser) instantly, then refreshes from Todoist in the background: on open, every 2 minutes, and when you come back to the tab after 30+ seconds.
41
+
40
42
  The page's declared capabilities must include `mcp` with Todoist (`find-tasks`, `find-completed-tasks`, `update-tasks`, `complete-tasks`, `uncomplete-tasks`, `delete-object`), Google Calendar (`list_events`), Claude Code Remote (`fire_trigger`), plus `host:claude_browser` (`preview_start`, `find`) if `chatLink` is on, and `db`.
41
43
 
42
44
  ## Todoist conventions
43
45
 
46
+ **Wording is the same everywhere:** a section's name on the dashboard is its Todoist label name. The only exception is the `ready` section: "Paused" for personal stuff, "Ready to show" for client work (set with the workspace's `labels.ready`). The update button is always "Update" and the side rail is always "Today".
47
+
44
48
  **Sections come from labels** (one status label per task; none = To do):
45
49
 
46
50
  | Section id | Default label | Shown as (default) |
47
51
  | --- | --- | --- |
48
52
  | `upcoming` | (no status label) | To do |
49
53
  | `today` | `In progress` | In progress |
50
- | `ready` | `Paused` | Paused / Ready to show |
51
- | `waiting` | `Waiting` | Waiting on others |
52
- | `handoff` | `Handoff` | Handoff prep (feature `handoff`) |
54
+ | `ready` | `Paused` (client work: `Ready to show`) | same as the label |
55
+ | `waiting` | `Waiting` | Waiting |
56
+ | `handoff` | `Handoff` | Handoff (feature `handoff`) |
53
57
  | `later` | `Later` | Later |
54
58
  | `meeting` | `Ask` | Under its meeting in the side rail (feature `meetingAsks`) |
55
59
  | `done` | completed in Todoist | Completed (last 7 days) |
@@ -60,6 +64,7 @@ The page's declared capabilities must include `mcp` with Todoist (`find-tasks`,
60
64
  Waiting on: Jon
61
65
  Link: https://… main source (Slack thread, Gmail, Fathom call)
62
66
  Figma: https://…
67
+ Notion: https://… project notes / longer docs (shows a Notes chip)
63
68
  Chat: https://claude.ai/chat/…
64
69
  Meeting: Jeremy-Tactus UX for Ask tasks: the meeting title it belongs to
65
70
  One or two lines of note.
package/dist/dashboard.js CHANGED
@@ -5,9 +5,10 @@
5
5
  "use strict";
6
6
  const CFG = window.DASHBOARD_CONFIG || {};
7
7
  const WORKSPACES = Array.isArray(CFG.workspaces) && CFG.workspaces.length ? CFG.workspaces : [{id: "main", name: "Dashboard", todoist: {}}];
8
- const LABELS = Object.assign({today: "In progress", ready: "Paused", waiting: "Waiting", later: "Later", handoff: "Handoff", meeting: "Ask", question: "Question"}, CFG.labels || {});
8
+ const BASE_LABELS = Object.assign({today: "In progress", ready: "Paused", waiting: "Waiting", later: "Later", handoff: "Handoff", meeting: "Ask", question: "Question"}, CFG.labels || {});
9
+ let LABELS = BASE_LABELS; // per workspace: BASE_LABELS + workspace.labels
9
10
  const OWNER_NAME = String(CFG.ownerName || "").slice(0, 40);
10
- const VERSION = "0.1.2";
11
+ const VERSION = "0.1.5";
11
12
 
12
13
  /* ---------- page skeleton ---------- */
13
14
  document.title = CFG.title || "Dashboard";
@@ -26,6 +27,7 @@
26
27
  chat: SVG('<path d="M8 2v3.2M8 10.8V14M2 8h3.2M10.8 8H14M3.8 3.8l2.2 2.2M10 10l2.2 2.2M12.2 3.8L10 6M6 10l-2.2 2.2"/>'),
27
28
  link: SVG('<path d="M7 9a3 3 0 0 0 4.2 0l2-2a3 3 0 0 0-4.2-4.2l-.6.6M9 7a3 3 0 0 0-4.2 0l-2 2a3 3 0 0 0 4.2 4.2l.6-.6"/>'),
28
29
  todo: SVG('<rect x="2.5" y="2.5" width="11" height="11" rx="2.5"/><path d="M5.5 8l1.8 1.8L10.5 6"/>'),
30
+ notes: SVG('<path d="M4 2.5h6l2.5 2.5v8.5H4z"/><path d="M6.5 7h4M6.5 9.5h4"/>'),
29
31
  cal: SVG('<rect x="2.5" y="3.5" width="11" height="10" rx="2"/><path d="M2.5 6.5h11M5.5 2v3M10.5 2v3"/>')
30
32
  };
31
33
  const CHEV = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 6l4 4 4-4" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
@@ -43,12 +45,13 @@
43
45
  function pickInitial(){ return wsFromHash() || WORKSPACES.find(w => w.id === store("dash.ws", "")) || WORKSPACES[0]; }
44
46
  function applyWorkspace(w){
45
47
  WS = w;
46
- const names = Object.assign({upcoming: "To do", today: "In progress", ready: "Paused", waiting: "Waiting on others", handoff: "Handoff prep", later: "Later"}, w.sections || {});
48
+ LABELS = Object.assign({}, BASE_LABELS, w.labels || {});
49
+ // Section names are the Todoist label names, so the dashboard and Todoist always say the same thing.
50
+ const names = Object.assign({upcoming: "To do", today: LABELS.today, ready: LABELS.ready, waiting: LABELS.waiting, handoff: LABELS.handoff, later: LABELS.later}, w.sections || {});
47
51
  LABEL = Object.assign({}, names, {done: "Complete", removed: "Removed"});
48
52
  SECTIONS = ["today", "ready", "waiting"].concat(feat("handoff") ? ["handoff"] : [], ["upcoming", "later"]);
49
53
  DRAGGABLE = ["today", "upcoming", "later"].concat(feat("handoff") ? ["handoff"] : []);
50
- EMPTY = {today: "Nothing in progress. Start something from " + names.upcoming + ".", ready: "Nothing in " + names.ready + ".", waiting: "Not waiting on anyone.",
51
- handoff: "Nothing approved and waiting for a handoff.", upcoming: "Things you haven't started show here.", later: "Nothing parked for later."};
54
+ EMPTY = {today: "Nothing in progress.", ready: "Nothing here.", waiting: "Not waiting on anyone.", handoff: "Nothing waiting for a handoff.", upcoming: "Nothing to do.", later: "Nothing parked for later."};
52
55
  PRIMARY = {today: [names.ready, "ready"], ready: ["Back to " + names.today.toLowerCase(), "today"], waiting: ["Back to " + names.today.toLowerCase(), "today"],
53
56
  handoff: ["Handed off", "done"], upcoming: ["Start", "today"], later: ["Start", "today"], done: ["Reopen", "today"]};
54
57
  // accent colour per workspace (light and dark)
@@ -59,13 +62,21 @@
59
62
  save("dash.ws", w.id);
60
63
  if(WORKSPACES.length > 1 && location.hash.slice(1) !== w.id){ try { history.replaceState(null, "", "#" + w.id); } catch(_){} }
61
64
  buildSections(); renderSwitcher();
62
- $("railTitle").textContent = w.railTitle || "Today";
65
+ $("railTitle").textContent = "Today";
63
66
  $("activeOnly").title = "Show only " + ["today", "ready", "waiting"].concat(feat("handoff") ? ["handoff"] : []).map(s => LABEL[s]).join(", ");
64
- $("updateLabel").textContent = w.updateLabel || "Update";
65
- items = (cache[w.id] || []); statusDoc = null; renderStatus(); watchStatus();
67
+ $("updateLabel").textContent = "Update";
68
+ const stored = cache[w.id] ? null : readCache(w.id);
69
+ items = cache[w.id] || (stored ? stored.items : []);
70
+ const calStored = store("dash.cal." + w.id, null);
71
+ dayData = calStored && calStored.date === isoDay(new Date()) ? calStored : null;
72
+ statusDoc = null; renderStatus(); watchStatus();
66
73
  render();
67
- loadTasks(); loadCalendar();
74
+ if(!items.length && db){ readDbCache(w.id).then(list => { if(list && w === WS && !cache[w.id] && !items.length){ items = list; render(); } }); }
75
+ clearTimeout(slowTimer);
76
+ if(!items.length && mcp) slowTimer = setTimeout(() => { if(!items.length && w === WS) setStatus("Loading your to-dos…"); }, 1500);
77
+ if(mcp){ loadTasks(); loadCalendar(); }
68
78
  }
79
+ let slowTimer = null;
69
80
  function renderSwitcher(){
70
81
  const box = $("wsSwitch"); box.replaceChildren(); box.hidden = WORKSPACES.length < 2;
71
82
  WORKSPACES.forEach(w => { const b = el("button", null, w.name || w.id); b.type = "button"; b.setAttribute("aria-pressed", String(w === WS)); b.onclick = () => { if(w !== WS){ closeDrawer(); applyWorkspace(w); } }; box.append(b); });
@@ -97,6 +108,19 @@
97
108
  /* ---------- state ---------- */
98
109
  let db = null, mcp = null, items = [], canWrite = true, undoState = null, toastTimer = null, refreshTimer = null;
99
110
  const cache = {};
111
+ const CACHE_V = 1;
112
+ const lastSaved = {};
113
+ function saveCache(wsId, list){
114
+ const body = JSON.stringify(list);
115
+ if(lastSaved[wsId] === body) return; lastSaved[wsId] = body;
116
+ try { localStorage.setItem("dash.cache." + wsId, JSON.stringify({v: CACHE_V, t: Date.now(), items: list})); } catch(_){}
117
+ if(db && body.length < 400000){ try { db.doc("cache/" + wsId).set({v: CACHE_V, t: Date.now(), items: body}).catch(() => {}); } catch(_){} }
118
+ }
119
+ async function readDbCache(wsId){
120
+ if(!db) return null;
121
+ try { const sn = await db.doc("cache/" + wsId).get(); const c = sn && sn.exists ? sn.data() : null; return c && c.v === CACHE_V ? JSON.parse(c.items) : null; } catch(_){ return null; }
122
+ }
123
+ function readCache(wsId){ try { const c = JSON.parse(localStorage.getItem("dash.cache." + wsId) || "null"); return c && c.v === CACHE_V && Array.isArray(c.items) ? c : null; } catch(_){ return null; } }
100
124
  const seenMap = store("pd.seen", {}), orderMap = store("pd.order", {});
101
125
  function saveSeen(id, t){ seenMap[id] = t; save("pd.seen", seenMap); }
102
126
  function saveOrder(id, o){ orderMap[id] = o; save("pd.order", orderMap); }
@@ -107,14 +131,14 @@
107
131
 
108
132
  /* ---------- Todoist adapter ---------- */
109
133
  const STATUS_KEYS = ["today", "ready", "waiting", "later", "handoff", "meeting"];
110
- const STATUS_LABELS = STATUS_KEYS.map(k => LABELS[k]);
134
+ const statusLabels = () => STATUS_KEYS.map(k => LABELS[k]);
111
135
  const parse = r => {
112
136
  const p = r && r.payload; if(p && typeof p === "object") return p;
113
137
  const txt = typeof p === "string" ? p : ((r && r.content) || []).filter(c => c.type === "text").map(c => c.text)[0] || "";
114
138
  try { return JSON.parse(txt); } catch(_){ const m = txt.match(/\{[\s\S]*\}/); try { return m ? JSON.parse(m[0]) : {}; } catch(_){ return {}; } }
115
139
  };
116
140
  const td = (tool, input) => mcp.callTool(CFG.todoistServer || "Todoist", tool, input, {cache: false});
117
- const KEYLINE = /^(Waiting on|Link|Figma|Chat|Meeting):[ \t]*(.*)$/;
141
+ const KEYLINE = /^(Waiting on|Link|Figma|Notion|Chat|Meeting):[ \t]*(.*)$/;
118
142
  function splitDesc(desc){
119
143
  const [head, ctx = ""] = String(desc || "").split(/^Context:[ \t]*$/m);
120
144
  const keys = {}, rest = [];
@@ -151,12 +175,14 @@
151
175
  return {id: t.id, title: t.content, description: String(t.description || ""), labels, section, order: orderMap[t.id] ?? (i + 1), projectId: t.projectId,
152
176
  note, log, subtasks, questions, _server: subtasks.concat(questions).map(x => ({id: x.id, d: x.d})),
153
177
  waitingOn: keys["Waiting on"] || "", url: safeUrl(keys.Link) || "https://app.todoist.com/app/task/" + t.id, todoistUrl: "https://app.todoist.com/app/task/" + t.id,
154
- figma: safeUrl(keys.Figma), chat: safeUrl(keys.Chat), meeting: keys.Meeting || "", due, overdue, newAt: Date.parse(t.addedAt) || 0, seenAt: seenMap[t.id] || 0};
178
+ figma: safeUrl(keys.Figma), notion: safeUrl(keys.Notion), chat: safeUrl(keys.Chat), meeting: keys.Meeting || "", due, overdue, newAt: Date.parse(t.addedAt) || 0, seenAt: seenMap[t.id] || 0};
155
179
  }
156
180
  function projectIds(){ const t = WS.todoist || {}; return [].concat(t.projectIds || [], t.projectId || []).filter(Boolean); }
157
181
  let loadSeq = 0;
182
+ let lastLoad = 0;
158
183
  async function loadTasks(){
159
184
  if(!mcp) return;
185
+ lastLoad = Date.now();
160
186
  const w = WS, seq = ++loadSeq, pids = projectIds();
161
187
  if(!pids.length){ setStatus("This workspace has no Todoist project set in its settings."); return; }
162
188
  try {
@@ -173,7 +199,7 @@
173
199
  const done = comp ? (parse(comp).tasks || []).filter(t => !t.parentId) : [];
174
200
  done.forEach(t => next.push({id: t.id, title: t.content, section: "done", _completed: true, labels: t.labels || [], description: String(t.description || ""), touchedAt: Date.parse(t.completedAt) || 0, subtasks: [], questions: [], _server: []}));
175
201
  });
176
- items = next; cache[w.id] = next; setStatus(""); render();
202
+ items = next; cache[w.id] = next; saveCache(w.id, next); setStatus(""); render();
177
203
  } catch(e){
178
204
  if(w !== WS) return;
179
205
  const c = e && e.code;
@@ -203,7 +229,7 @@
203
229
  else if(s === "removed"){ await td("delete-object", {type: "task", id}); }
204
230
  else {
205
231
  if(it._completed){ await td("uncomplete-tasks", {ids: [id]}); it._completed = false; }
206
- labels = (it.labels || []).filter(l => !STATUS_LABELS.includes(l)); if(LABELS[s]) labels.push(LABELS[s]);
232
+ labels = (it.labels || []).filter(l => !statusLabels().includes(l)); if(LABELS[s]) labels.push(LABELS[s]);
207
233
  desc = setLine(desc, "Waiting on", s === "waiting" ? (patch.waitingOn || it.waitingOn) : null);
208
234
  desc = setLine(desc, "Meeting", s === "meeting" ? (patch.meeting || it.meeting) : null);
209
235
  }
@@ -242,6 +268,7 @@
242
268
  .sort((a, b) => String((a.start || {}).dateTime || (a.start || {}).date).localeCompare(String((b.start || {}).dateTime || (b.start || {}).date)));
243
269
  dayData = {date: isoDay(n), meetings: evs.map((e, i) => { const st = e.start || {}, en = e.end || {};
244
270
  return {id: e.id || "e" + i, title: e.summary || "(No title)", url: e.htmlLink, time: st.dateTime ? fmt(st.dateTime) + (en.dateTime ? " – " + fmt(en.dateTime) : "") : "All day"}; })};
271
+ save("dash.cal." + w.id, dayData);
245
272
  } catch(e){ if(w !== WS) return; dayData = {date: isoDay(n), meetings: [], error: true}; }
246
273
  renderMeetings();
247
274
  }
@@ -281,6 +308,7 @@
281
308
  const u = safeUrl(it.url); if(u) pill(u, "Link", ICON.link, "Link");
282
309
  const f = safeUrl(it.figma), c = safeUrl(it.chat);
283
310
  if(f) pill(f, o.compact ? "" : "Figma", ICON.figma, "Figma");
311
+ const nn = safeUrl(it.notion); if(nn) pill(nn, o.compact ? "" : "Notes", ICON.notes, "Notion notes");
284
312
  if(c){ pill(c, o.compact ? "" : "Chat", ICON.chat, "Claude chat"); const a = row.lastChild; a.onclick = e => { e.preventDefault(); e.stopPropagation(); openChat(c); }; }
285
313
  const subs = it.subtasks || [];
286
314
  if(subs.length){ const n = el("span", "chip"); n.innerHTML = ICON.todo; n.append(document.createTextNode(subs.filter(x => x && x.d).length + "/" + subs.length)); n.title = "To-dos done"; row.append(n); }
@@ -582,7 +610,7 @@
582
610
  if(dayData.off){ ul.append(el("li", "empty", "No calendar for this workspace.")); }
583
611
  else if(dayData.error){ ul.append(el("li", "empty", "Couldn't load your calendar.")); }
584
612
  const m = meetingsList();
585
- if(!dayData.off && !dayData.error && !m.length) ul.append(el("li", "empty", "Nothing on the calendar today."));
613
+ if(!dayData.off && !dayData.error && !m.length) ul.append(el("li", "empty", "Nothing on your calendar today."));
586
614
  const asks = items.filter(i => i.section === "meeting");
587
615
  const used = new Set();
588
616
  const follow = feat("showFollowUp") ? sorted("ready").concat(sorted("waiting")) : [];
@@ -703,10 +731,10 @@
703
731
  btn.hidden = !mcp || !/^trig_[A-Za-z0-9]+$/.test(WS.updateTask || "");
704
732
  const running = s.state === "running" && Date.now() - (Number(s.startedAt) || 0) < 20 * 60 * 1000;
705
733
  btn.classList.toggle("busy", running);
706
- if(!btn.dataset.local){ btn.disabled = running; lbl.textContent = running ? (WS.updatingLabel || "Updating…") : (WS.updateLabel || "Update"); }
734
+ if(!btn.dataset.local){ btn.disabled = running; lbl.textContent = running ? "Updating…" : "Update"; }
707
735
  const t = ms => new Date(ms).toLocaleTimeString("en-US", {hour: "numeric", minute: "2-digit"});
708
736
  const day = ms => { const d = new Date(ms), n = new Date(); return d.toDateString() === n.toDateString() ? t(ms) : d.toLocaleDateString("en-US", {weekday: "short"}) + " " + t(ms); };
709
- st.textContent = running ? (WS.updatingLabel || "Updating…") : s.state === "done" && s.finishedAt ? "Updated " + day(Number(s.finishedAt)) : s.state === "error" && s.finishedAt ? "Last update had a problem" : "";
737
+ st.textContent = running ? "Updating…" : s.state === "done" && s.finishedAt ? "Updated " + day(Number(s.finishedAt)) : s.state === "error" && s.finishedAt ? "Last update had a problem" : "";
710
738
  $("updateTip").textContent = s.summary || "";
711
739
  }
712
740
  $("updateState").addEventListener("click", e => { e.stopPropagation(); $("updateTip").classList.toggle("show"); });
@@ -720,7 +748,7 @@
720
748
  lbl.textContent = "Starting…";
721
749
  await mcp.callTool(CFG.remoteServer || "Claude Code Remote", "fire_trigger", {trigger_id: w.updateTask}, {cache: false});
722
750
  if(w === WS) statusDoc = {state: "running", startedAt: Date.now()};
723
- toast((linked ? "Linked " + linked + " chat" + (linked === 1 ? "" : "s") + ". " : "") + (w.updateStartedMsg || "Updating now. New items show up in a few minutes."));
751
+ toast((linked ? "Linked " + linked + " chat" + (linked === 1 ? "" : "s") + ". " : "") + "Updating. New items show up here in a few minutes.");
724
752
  } catch(e){
725
753
  const c = e && e.code;
726
754
  toast(c === "server_not_connected" || c === "needs_reauth" ? "Reconnect Claude Code Remote in Settings → Connectors." :
@@ -737,15 +765,15 @@
737
765
  /* ---------- start ---------- */
738
766
  WS = pickInitial();
739
767
  setView(view); setActiveOnly(activeOnly);
768
+ applyWorkspace(WS); // paint the last known tasks right away, before the connectors are ready
740
769
  (async () => {
741
770
  const use = n => (window.claude && window.claude.use) ? window.claude.use(n).catch(() => null) : Promise.resolve(null);
742
771
  [db, mcp] = await Promise.all([use("db"), use("mcp")]);
743
- if(!mcp){ canWrite = false; applyWorkspace(WS); $("refreshed").textContent = "Open this page in Claude to see your dashboard."; return; }
744
- setStatus("Loading your to-dos…");
772
+ if(!mcp){ canWrite = false; render(); $("refreshed").textContent = "Open this page in Claude to see your dashboard."; return; }
745
773
  applyWorkspace(WS);
746
774
  setInterval(loadTasks, 120000);
747
775
  let calDay = new Date().toDateString();
748
776
  setInterval(() => { if(new Date().toDateString() !== calDay){ calDay = new Date().toDateString(); loadCalendar(); $("date").textContent = new Date().toLocaleDateString("en-US", {weekday: "long", month: "long", day: "numeric"}); } $("refreshed").textContent = greeting(); renderStatus(); }, 60000);
749
- document.addEventListener("visibilitychange", () => { if(!document.hidden) loadTasks(); });
777
+ document.addEventListener("visibilitychange", () => { if(!document.hidden && Date.now() - lastLoad > 30000) loadTasks(); });
750
778
  })();
751
779
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jt-workspace-dashboard",
3
- "version": "0.1.2",
3
+ "version": "0.1.5",
4
4
  "description": "Shared code for Jeremy's Claude dashboards: a Todoist + Google Calendar consolidator with workspaces.",
5
5
  "main": "dist/dashboard.js",
6
6
  "files": [