jt-workspace-dashboard 0.1.4 → 0.1.6
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 +3 -0
- package/dist/dashboard.js +68 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,6 +29,7 @@ Publishing uses npm trusted publishing, linked to `.github/workflows/publish.yml
|
|
|
29
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
31
|
updateTask: "trig_…",
|
|
32
|
+
notes: { dataSource: "collection id", minSteps: 3 }, // automatic Notion notes pages (or all: true)
|
|
32
33
|
features: { handoff: false, meetingAsks: false, showFollowUp: false, chatLink: false }
|
|
33
34
|
}
|
|
34
35
|
]
|
|
@@ -37,6 +38,8 @@ Publishing uses npm trusted publishing, linked to `.github/workflows/publish.yml
|
|
|
37
38
|
|
|
38
39
|
The page's database (only used for the update button's status line) is read at `meta/status-<workspace id>`.
|
|
39
40
|
|
|
41
|
+
**Project notes pages:** a workspace with `notes` gets a Notion page per project, created by the page itself (no Claude tokens) in that Notion database: every task when `notes.all` is true (client work), otherwise once a task has `notes.minSteps` steps (default 3). The page gets the task's links, note, context and steps, the task gets a `Notion:` line (Notes chip), and completing the task sets the page's Status to Done. The update tasks add longer notes to the page's Notes section. Needs `Notion` → `notion-create-pages`, `notion-update-page` in the page's capabilities.
|
|
42
|
+
|
|
40
43
|
**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
44
|
|
|
42
45
|
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`.
|
package/dist/dashboard.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
const BASE_LABELS = Object.assign({today: "In progress", ready: "Paused", waiting: "Waiting", later: "Later", handoff: "Handoff", meeting: "Ask", question: "Question"}, CFG.labels || {});
|
|
9
9
|
let LABELS = BASE_LABELS; // per workspace: BASE_LABELS + workspace.labels
|
|
10
10
|
const OWNER_NAME = String(CFG.ownerName || "").slice(0, 40);
|
|
11
|
-
const VERSION = "0.1.
|
|
11
|
+
const VERSION = "0.1.6";
|
|
12
12
|
|
|
13
13
|
/* ---------- page skeleton ---------- */
|
|
14
14
|
document.title = CFG.title || "Dashboard";
|
|
@@ -71,8 +71,12 @@
|
|
|
71
71
|
dayData = calStored && calStored.date === isoDay(new Date()) ? calStored : null;
|
|
72
72
|
statusDoc = null; renderStatus(); watchStatus();
|
|
73
73
|
render();
|
|
74
|
-
|
|
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(); }
|
|
75
78
|
}
|
|
79
|
+
let slowTimer = null;
|
|
76
80
|
function renderSwitcher(){
|
|
77
81
|
const box = $("wsSwitch"); box.replaceChildren(); box.hidden = WORKSPACES.length < 2;
|
|
78
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); });
|
|
@@ -105,7 +109,17 @@
|
|
|
105
109
|
let db = null, mcp = null, items = [], canWrite = true, undoState = null, toastTimer = null, refreshTimer = null;
|
|
106
110
|
const cache = {};
|
|
107
111
|
const CACHE_V = 1;
|
|
108
|
-
|
|
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
|
+
}
|
|
109
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; } }
|
|
110
124
|
const seenMap = store("pd.seen", {}), orderMap = store("pd.order", {});
|
|
111
125
|
function saveSeen(id, t){ seenMap[id] = t; save("pd.seen", seenMap); }
|
|
@@ -186,6 +200,7 @@
|
|
|
186
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: []}));
|
|
187
201
|
});
|
|
188
202
|
items = next; cache[w.id] = next; saveCache(w.id, next); setStatus(""); render();
|
|
203
|
+
ensureNotesPages(w).catch(() => {});
|
|
189
204
|
} catch(e){
|
|
190
205
|
if(w !== WS) return;
|
|
191
206
|
const c = e && e.code;
|
|
@@ -211,7 +226,7 @@
|
|
|
211
226
|
let desc = it.description, labels = null;
|
|
212
227
|
if("section" in patch){
|
|
213
228
|
const s = patch.section;
|
|
214
|
-
if(s === "done"){ await td("complete-tasks", {ids: [id]}); it._completed = true; }
|
|
229
|
+
if(s === "done"){ await td("complete-tasks", {ids: [id]}); it._completed = true; markNotesDone(it); }
|
|
215
230
|
else if(s === "removed"){ await td("delete-object", {type: "task", id}); }
|
|
216
231
|
else {
|
|
217
232
|
if(it._completed){ await td("uncomplete-tasks", {ids: [id]}); it._completed = false; }
|
|
@@ -221,6 +236,7 @@
|
|
|
221
236
|
}
|
|
222
237
|
} else if("waitingOn" in patch) desc = setLine(desc, "Waiting on", patch.waitingOn);
|
|
223
238
|
if("chat" in patch) desc = setLine(desc, "Chat", patch.chat);
|
|
239
|
+
if("notion" in patch) desc = setLine(desc, "Notion", patch.notion);
|
|
224
240
|
const up = {id};
|
|
225
241
|
if(labels){ up.labels = labels; it.labels = labels; }
|
|
226
242
|
if(desc !== it.description){ up.description = desc; it.description = desc; }
|
|
@@ -236,6 +252,52 @@
|
|
|
236
252
|
scheduleRefresh();
|
|
237
253
|
}
|
|
238
254
|
|
|
255
|
+
/* ---------- automatic Notion notes pages for projects ----------
|
|
256
|
+
A workspace with notes:{dataSource} gets one Notion page per project task, created by the page itself (no Claude tokens).
|
|
257
|
+
notes.all = every task is a project (client work); otherwise a task becomes a project at notes.minSteps steps (default 3). */
|
|
258
|
+
const notionCall = (tool, input) => mcp.callTool(CFG.notionServer || "Notion", tool, input, {cache: false});
|
|
259
|
+
const notesTried = store("dash.notesTried", {});
|
|
260
|
+
function isProject(w, it){
|
|
261
|
+
const n = w.notes; if(!n || !n.dataSource) return false;
|
|
262
|
+
if(it.notion || !["today", "ready", "waiting", "handoff", "upcoming", "later"].includes(it.section)) return false;
|
|
263
|
+
return n.all || (it.subtasks || []).length >= (n.minSteps || 3);
|
|
264
|
+
}
|
|
265
|
+
function notesMarkdown(it){
|
|
266
|
+
const out = [];
|
|
267
|
+
const links = [["Todoist", it.todoistUrl], ["Figma", it.figma], ["Source", it.url !== it.todoistUrl ? it.url : null], ["Chat", it.chat]].filter(x => safeUrl(x[1]));
|
|
268
|
+
if(links.length) out.push(links.map(([k, u]) => "[" + k + "](" + u + ")").join(" · "), "");
|
|
269
|
+
const pr = priorityOf(it.note); const note = pr ? pr.rest : it.note;
|
|
270
|
+
if(note) out.push(note, "");
|
|
271
|
+
if((it.log || []).length){ out.push("## Context"); it.log.forEach(x => out.push("- " + x.t)); out.push(""); }
|
|
272
|
+
if((it.subtasks || []).length){ out.push("## Steps when this page was made"); it.subtasks.forEach(x => out.push("- [" + (x.d ? "x" : " ") + "] " + x.t)); out.push(""); }
|
|
273
|
+
out.push("## Notes", "Longer notes, meeting discussions and decisions for this project go here.");
|
|
274
|
+
return out.join("\n");
|
|
275
|
+
}
|
|
276
|
+
let notesBusy = false;
|
|
277
|
+
async function ensureNotesPages(w){
|
|
278
|
+
if(notesBusy || !mcp || !w.notes || !w.notes.dataSource) return;
|
|
279
|
+
const due = items.filter(it => isProject(w, it) && !(Date.now() - (notesTried[it.id] || 0) < 24 * 3600 * 1000)).slice(0, 3);
|
|
280
|
+
if(!due.length) return;
|
|
281
|
+
notesBusy = true;
|
|
282
|
+
try {
|
|
283
|
+
for(const it of due){
|
|
284
|
+
notesTried[it.id] = Date.now(); save("dash.notesTried", notesTried);
|
|
285
|
+
const props = {Name: it.title, Status: "Active", Todoist: it.todoistUrl};
|
|
286
|
+
if(w.notes.figmaProp && it.figma) props[w.notes.figmaProp] = it.figma;
|
|
287
|
+
const r = await notionCall("notion-create-pages", {parent: {data_source_id: w.notes.dataSource}, pages: [{properties: props, content: notesMarkdown(it)}], allow_async: false});
|
|
288
|
+
const txt = JSON.stringify(r && (r.payload || r.content) || "");
|
|
289
|
+
const m = txt.match(/https:\/\/(?:app\.|www\.)?notion\.(?:so|com)\/[^\s"'<>)\\]+/);
|
|
290
|
+
if(!m) continue;
|
|
291
|
+
const url = m[0].replace(/\?pvs=\d+$/, "");
|
|
292
|
+
it.notion = url; await write(it.id, {notion: url});
|
|
293
|
+
}
|
|
294
|
+
} finally { notesBusy = false; }
|
|
295
|
+
}
|
|
296
|
+
async function markNotesDone(it){
|
|
297
|
+
if(!it.notion || !mcp || !(WS.notes && WS.notes.dataSource)) return;
|
|
298
|
+
try { await notionCall("notion-update-page", {page_id: it.notion, command: "update_properties", properties: {Status: "Done"}}); } catch(_){}
|
|
299
|
+
}
|
|
300
|
+
|
|
239
301
|
/* ---------- calendar ---------- */
|
|
240
302
|
let dayData = null;
|
|
241
303
|
async function loadCalendar(){
|
|
@@ -751,11 +813,11 @@
|
|
|
751
813
|
/* ---------- start ---------- */
|
|
752
814
|
WS = pickInitial();
|
|
753
815
|
setView(view); setActiveOnly(activeOnly);
|
|
816
|
+
applyWorkspace(WS); // paint the last known tasks right away, before the connectors are ready
|
|
754
817
|
(async () => {
|
|
755
818
|
const use = n => (window.claude && window.claude.use) ? window.claude.use(n).catch(() => null) : Promise.resolve(null);
|
|
756
819
|
[db, mcp] = await Promise.all([use("db"), use("mcp")]);
|
|
757
|
-
if(!mcp){ canWrite = false;
|
|
758
|
-
if(!cache[WS.id] && !readCache(WS.id)) setStatus("Loading your to-dos…");
|
|
820
|
+
if(!mcp){ canWrite = false; render(); $("refreshed").textContent = "Open this page in Claude to see your dashboard."; return; }
|
|
759
821
|
applyWorkspace(WS);
|
|
760
822
|
setInterval(loadTasks, 120000);
|
|
761
823
|
let calDay = new Date().toDateString();
|
package/package.json
CHANGED