Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
634 lines (585 loc) · 28.9 KB
/
Copy pathindex.html
File metadata and controls
634 lines (585 loc) · 28.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Taskify — AI Agent Orchestration Dashboard</title>
<meta name="description" content="Orchestrate AI agents from a lightweight dashboard. Open source, no build step, powered by LOSOS.">
<!-- Open Graph -->
<meta property="og:title" content="Taskify — AI Agent Orchestration Dashboard">
<meta property="og:description" content="Orchestrate AI agents from a lightweight dashboard. Create issues, assign agents, get AI-powered responses. Open source, no build step.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://taskify.org/">
<meta property="og:image" content="https://taskify.org/og-image.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:site_name" content="Taskify">
<!-- Twitter Card -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Taskify — AI Agent Orchestration Dashboard">
<meta name="twitter:description" content="Orchestrate AI agents from a lightweight dashboard. Open source, no build step.">
<meta name="twitter:image" content="https://taskify.org/og-image.png">
<link rel="icon" href="favicon.svg" type="image/svg+xml">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--bg: #ffffff; --bg2: #fafafa; --bg3: #f4f4f5;
--fg: #09090b; --fg2: #3f3f46; --fg3: #a1a1aa;
--accent: #6366f1; --accent2: #4f46e5; --accent-soft: #eef2ff;
--green: #16a34a; --green-soft: #f0fdf4;
--yellow: #ca8a04; --yellow-soft: #fefce8;
--red: #dc2626; --red-soft: #fef2f2;
--blue: #2563eb; --blue-soft: #eff6ff;
--border: #e4e4e7; --border2: #d4d4d8;
--radius: 10px; --radius-lg: 14px;
--sidebar-w: 240px;
--shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
--shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
--shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
background: var(--bg); color: var(--fg); line-height: 1.5;
-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
/* layout */
#app { display: flex; min-height: 100vh; }
#sidebar { width: var(--sidebar-w); background: var(--bg); border-right: 1px solid var(--border);
padding: 0; flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0;
overflow-y: auto; display: flex; flex-direction: column; }
#main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; background: var(--bg);
min-height: 100vh; }
#topbar { display: flex; align-items: center; border-bottom: 1px solid var(--border);
background: var(--bg); position: sticky; top: 0; z-index: 10; }
#breadcrumbs { padding: 12px 32px; font-size: 13px; color: var(--fg3);
display: flex; align-items: center; gap: 8px; flex: 1; }
#breadcrumbs span { cursor: pointer; color: var(--fg3); transition: color 0.15s; }
#breadcrumbs span:hover { color: var(--accent2); }
#breadcrumbs .bc-current { color: var(--fg); cursor: default; font-weight: 500; }
#breadcrumbs .bc-current:hover { color: var(--fg); }
#breadcrumbs .bc-sep { color: var(--border2); cursor: default; font-size: 11px; }
#content { padding: 32px; max-width: 1000px; }
/* sidebar */
.sb-logo { padding: 20px 24px; font-weight: 700; font-size: 16px; letter-spacing: -0.02em;
border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.sb-logo-icon { width: 28px; height: 28px; background: var(--accent); border-radius: 8px;
display: flex; align-items: center; justify-content: center;
font-size: 14px; box-shadow: var(--shadow-sm); }
.sb-nav { padding: 12px 12px; flex: 1; }
.sb-section { padding: 16px 12px 6px; font-size: 10px; text-transform: uppercase;
letter-spacing: 0.1em; color: var(--fg3); font-weight: 600; }
.sb-section:first-child { padding-top: 4px; }
.sb-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: 13px;
color: var(--fg2); cursor: pointer; border-radius: 8px; transition: all 0.15s;
font-weight: 450; margin-bottom: 2px; }
.sb-item:hover { background: var(--bg3); color: var(--fg); }
.sb-item.active { background: var(--accent-soft); color: var(--accent2); font-weight: 600; }
.sb-item-icon { width: 20px; text-align: center; font-size: 14px; }
.sb-count { margin-left: auto; font-size: 11px; font-weight: 500; color: var(--fg3);
background: var(--bg3); padding: 1px 8px; border-radius: 9999px; }
.sb-item.active .sb-count { background: var(--accent)18; color: var(--accent2); }
.sb-footer { padding: 16px 24px; border-top: 1px solid var(--border); font-size: 11px;
color: var(--fg3); }
/* shared components */
.card { background: var(--bg); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
border-radius: var(--radius); padding: 18px; transition: box-shadow 0.2s, border-color 0.2s; }
.card:hover { box-shadow: var(--shadow); border-color: var(--border2); }
.card.clickable:hover { box-shadow: var(--shadow-md); border-color: var(--accent); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
border-radius: 9999px; font-size: 11px; font-weight: 600; letter-spacing: 0.01em; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-gray { background: var(--bg3); color: var(--fg3); }
.badge-purple { background: var(--accent-soft); color: var(--accent2); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%;
background: currentColor; flex-shrink: 0; }
.badge-no-dot::before { display: none; }
.metric { text-align: center; padding: 24px 16px; }
.metric-value { font-size: 28px; font-weight: 700; color: var(--fg); letter-spacing: -0.02em; }
.metric-label { font-size: 11px; color: var(--fg3); margin-top: 6px; text-transform: uppercase;
letter-spacing: 0.06em; font-weight: 500; }
h1 { font-size: 24px; font-weight: 700; margin-bottom: 20px; letter-spacing: -0.025em;
color: var(--fg); }
h2 { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: var(--fg3);
text-transform: uppercase; letter-spacing: 0.04em; }
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.mb { margin-bottom: 28px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--fg3); }
.text-fg2 { color: var(--fg2); }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
color: var(--fg3); padding: 10px 14px; border-bottom: 1px solid var(--border);
font-weight: 600; background: var(--bg2); }
tr:first-child th:first-child { border-radius: 8px 0 0 0; }
tr:first-child th:last-child { border-radius: 0 8px 0 0; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px;
transition: background 0.1s; }
tr:last-child td { border-bottom: none; }
tr.clickable:hover td { background: var(--accent-soft); }
tr:not(.clickable):hover td { background: var(--bg2); }
.icon-circle { width: 34px; height: 34px; border-radius: 10px; display: flex;
align-items: center; justify-content: center; font-size: 14px;
background: var(--bg3); font-weight: 600; color: var(--fg2); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-idle { background: var(--fg3); }
.status-running { background: var(--green); }
.status-error { background: var(--red); }
.status-paused { background: var(--yellow); }
.status-active { background: var(--green); }
.status-in_progress { background: var(--blue); }
.status-done, .status-completed { background: var(--green); }
.empty { text-align: center; padding: 48px; color: var(--fg3); font-size: 14px; }
.loading { text-align: center; padding: 48px; color: var(--fg3); }
.priority-high { color: var(--red); }
.priority-medium { color: var(--yellow); }
.priority-low { color: var(--fg3); }
.clickable { cursor: pointer; }
/* toast */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 300;
display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none; }
.toast { background: var(--fg); color: var(--bg); padding: 12px 20px; border-radius: 10px;
font-size: 13px; box-shadow: var(--shadow-md); pointer-events: auto;
animation: toast-in 0.3s ease; max-width: 360px; }
.toast-icon { margin-right: 8px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
/* mobile */
#hamburger { display: none; background: none; border: none; font-size: 22px; cursor: pointer;
padding: 8px 16px; color: var(--fg); line-height: 1; }
#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3);
z-index: 99; }
@media (max-width: 768px) {
#sidebar { display: none; z-index: 100; box-shadow: var(--shadow-md); }
#sidebar.open { display: flex; }
#sidebar-overlay.open { display: block; }
#main { margin-left: 0; }
#content { padding: 16px; }
#breadcrumbs { padding: 10px 16px; }
#hamburger { display: block; }
.grid-2, .grid-3 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: repeat(2, 1fr); }
}
/* progress bars */
.progress-track { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.3s ease; }
/* buttons */
.btn { padding: 7px 16px; border-radius: 8px; border: 1px solid var(--border); font-size: 12px;
cursor: pointer; font-weight: 500; transition: all 0.15s; font-family: inherit; }
.btn:hover { border-color: var(--border2); box-shadow: var(--shadow-sm); }
.btn-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-active:hover { background: var(--accent2); border-color: var(--accent2); }
.btn-default { background: var(--bg); color: var(--fg2); }
/* modals */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 200;
display: flex; align-items: center; justify-content: center; }
.modal { background: var(--bg); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
width: 90%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 20px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { margin: 0; text-transform: none; letter-spacing: normal; color: var(--fg);
font-size: 18px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--fg3);
padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--bg3); color: var(--fg); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex;
justify-content: flex-end; gap: 8px; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--fg2);
margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.form-input, .form-select, .form-textarea {
width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
font-size: 13px; font-family: inherit; background: var(--bg); color: var(--fg);
transition: border-color 0.15s; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-textarea { resize: vertical; min-height: 80px; }
.btn-primary { background: var(--accent); color: #fff; border: 1px solid var(--accent);
padding: 8px 20px; border-radius: 8px; font-size: 13px; font-weight: 600;
cursor: pointer; font-family: inherit; transition: background 0.15s; }
.btn-primary:hover { background: var(--accent2); }
.btn-cancel { background: var(--bg); color: var(--fg2); border: 1px solid var(--border);
padding: 8px 20px; border-radius: 8px; font-size: 13px; font-weight: 500;
cursor: pointer; font-family: inherit; }
.btn-cancel:hover { background: var(--bg3); }
</style>
</head>
<body>
<div id="app">
<div id="sidebar-overlay" onclick="closeSidebar()"></div>
<nav id="sidebar">
<div class="sb-logo">
<div class="sb-logo-icon">⚙️</div>
<span>Taskify</span>
</div>
<div id="company-switcher" style="padding:4px 16px 8px;border-bottom:1px solid var(--border)">
<select id="company-select" class="form-select" style="font-size:12px;padding:4px 8px;width:100%"></select>
</div>
<div class="sb-nav">
<div class="sb-section">Overview</div>
<div class="sb-item active" data-nav="dashboard"><span class="sb-item-icon">📊</span> Dashboard</div>
<div class="sb-item" data-nav="activity"><span class="sb-item-icon">📡</span> Activity</div>
<div class="sb-section">Work</div>
<div class="sb-item" data-nav="issues"><span class="sb-item-icon">📋</span> Issues <span class="sb-count" id="sb-issues-count"></span></div>
<div class="sb-item" data-nav="projects"><span class="sb-item-icon">📁</span> Projects <span class="sb-count" id="sb-projects-count"></span></div>
<div class="sb-item" data-nav="goals"><span class="sb-item-icon">🎯</span> Goals</div>
<div class="sb-section">Team</div>
<div class="sb-item" data-nav="agents"><span class="sb-item-icon">🤖</span> Agents <span class="sb-count" id="sb-agents-count"></span></div>
<div class="sb-section">Settings</div>
<div class="sb-item" data-nav="settings"><span class="sb-item-icon">⚙️</span> Company</div>
</div>
<div class="sb-footer">Taskify v0.0.1 · LOSOS</div>
</nav>
<div id="main">
<div id="topbar"><button id="hamburger">☰</button><div id="breadcrumbs"></div><button id="sound-toggle" title="Enable notification sounds" style="background:none;border:none;font-size:16px;cursor:pointer;padding:8px 16px;color:var(--fg3)">🔇</button></div>
<div id="content"></div>
<div id="toasts"></div>
</div>
</div>
<script type="module">
// --- Data layer: try /db/ (MongoDB via JSS), fall back to demo data ---
function resolveDB(input) {
if (!input) return '/db/taskify'
// Fix corrupted values like /db/https://...
if (input.startsWith('/db/http')) return input.replace(/^\/db\//, '')
if (input.startsWith('http://') || input.startsWith('https://')) return input
if (input.startsWith('/db/')) return input
return '/db/' + input
}
function dbDisplayName(db) {
try { var u = new URL(db); return u.hostname + u.pathname } catch(e) {}
return db.replace(/^\/db\//, '')
}
var _urlCompany = new URLSearchParams(window.location.search).get('company')
var DB = resolveDB(_urlCompany || localStorage.getItem('taskify-db') || 'taskify')
localStorage.setItem('taskify-db', DB)
var LIVE = false
async function fetchCollection(name) {
var base = DB.endsWith('/') ? DB : DB + '/'
var listing = await fetch(base + name + '/').then(function(r) { return r.json() })
var items = listing.contains || listing['ldp:contains'] || []
var urls = items.map(function(item) {
return typeof item === 'string' ? item : item['@id']
})
return Promise.all(urls.map(function(url) {
return fetch(url).then(function(r) { return r.json() }).then(function(doc) {
var parts = url.split('/')
doc.id = doc.id || parts[parts.length - 1]
return doc
})
}))
}
async function loadData() {
var results = await Promise.all([
fetchCollection('agents'),
fetchCollection('issues'),
fetchCollection('projects'),
fetchCollection('goals'),
fetchCollection('activity'),
fetchCollection('company')
])
var company = results[5][0] || { id: "c1", name: "Taskify", status: "active", issuePrefix: "TM" }
window.__paperclip = {
company: company,
agents: results[0],
issues: results[1],
projects: results[2],
goals: results[3],
activity: results[4]
}
LIVE = true
}
async function loadDemoData() {
window.__paperclip = await fetch('demo.json').then(function(r) { return r.json() })
}
document.getElementById('content').innerHTML = '<div class="loading">Loading...</div>'
try {
await loadData()
} catch (e) {
await loadDemoData()
}
// Sidebar counts
var d = window.__paperclip
document.getElementById('sb-agents-count').textContent = d.agents.length
document.getElementById('sb-issues-count').textContent = d.issues.filter(function(i) { return i.status !== 'done' && i.status !== 'completed' }).length
document.getElementById('sb-projects-count').textContent = d.projects.length
function closeSidebar() {
document.getElementById('sidebar').classList.remove('open')
document.getElementById('sidebar-overlay').classList.remove('open')
}
document.getElementById('hamburger').addEventListener('click', function() {
document.getElementById('sidebar').classList.toggle('open')
document.getElementById('sidebar-overlay').classList.toggle('open')
})
import { html, render } from './losos/html.js'
// ---- pane imports ----
var panes = {}
panes.dashboard = (await import('./panes/dashboard-pane.js')).default
panes.agents = (await import('./panes/agents-pane.js')).default
panes.agentDetail = (await import('./panes/agent-detail-pane.js')).default
panes.issues = (await import('./panes/issues-pane.js')).default
panes.issueDetail = (await import('./panes/issue-detail-pane.js')).default
panes.projects = (await import('./panes/projects-pane.js')).default
panes.projectDetail = (await import('./panes/project-detail-pane.js')).default
panes.activity = (await import('./panes/activity-pane.js')).default
panes.settings = (await import('./panes/settings-pane.js')).default
panes.goals = (await import('./panes/goals-pane.js')).default
// ---- navigation ----
var content = document.getElementById('content')
var breadcrumbsEl = document.getElementById('breadcrumbs')
var navStack = []
function navigate(paneKey, label, context) {
var entry = { pane: paneKey, label: label, context: context || {} }
try { localStorage.setItem('taskify-pane', JSON.stringify(entry)) } catch(e) {}
// If navigating to a sidebar item, reset the stack
if (['dashboard','agents','issues','projects','activity','goals','settings'].indexOf(paneKey) !== -1) {
navStack = [entry]
} else {
navStack.push(entry)
}
renderContent()
renderBreadcrumbs()
updateSidebar(navStack[0].pane)
}
function navigateBack(toIndex) {
navStack = navStack.slice(0, toIndex + 1)
renderContent()
renderBreadcrumbs()
updateSidebar(navStack[0].pane)
}
function renderContent() {
var current = navStack[navStack.length - 1]
// Use a fresh container to avoid LOSOS cache conflicts on re-render
var fresh = document.createElement('div')
content.innerHTML = ''
content.appendChild(fresh)
var pane = panes[current.pane]
if (pane && pane.render) {
try {
pane.render(null, null, fresh, current.context)
} catch (err) {
console.warn('[render] pane failed:', current.pane, err)
fresh.innerHTML = '<div class="empty">Render error — try refreshing</div>'
}
}
}
function renderBreadcrumbs() {
breadcrumbsEl.innerHTML = ''
navStack.forEach(function(entry, idx) {
if (idx > 0) {
var sep = document.createElement('span')
sep.className = 'bc-sep'
sep.textContent = '/'
breadcrumbsEl.appendChild(sep)
}
var span = document.createElement('span')
span.textContent = entry.label
if (idx === navStack.length - 1) {
span.className = 'bc-current'
} else {
span.addEventListener('click', function() { navigateBack(idx) })
}
breadcrumbsEl.appendChild(span)
})
}
function updateSidebar(activePane) {
document.querySelectorAll('.sb-item').forEach(function(el) {
el.classList.toggle('active', el.dataset.nav === activePane)
})
}
// Expose navigate globally so panes can use it
window.__nav = navigate
window.__loadData = loadData
window.__setDB = function(input) {
DB = resolveDB(input)
localStorage.setItem('taskify-db', DB)
addCompanyToList(DB)
if (LIVE) connectWS()
}
window.__getDB = function() { return DB.replace(/\/+$/, '') }
window.__isLive = function() { return LIVE }
// ---- company list ----
function getCompanyList() {
try { return JSON.parse(localStorage.getItem('taskify-companies')) || [] } catch(e) { return [] }
}
function addCompanyToList(db) {
var resolved = resolveDB(db)
var list = getCompanyList()
if (list.indexOf(resolved) === -1) { list.push(resolved); localStorage.setItem('taskify-companies', JSON.stringify(list)) }
renderCompanySelect()
}
function renderCompanySelect() {
var sel = document.getElementById('company-select')
var list = getCompanyList()
sel.innerHTML = list.map(function(c) {
return '<option value="' + c + '"' + (c === DB ? ' selected' : '') + '>' + dbDisplayName(c) + '</option>'
}).join('') + '<option value="__new">+ New company...</option>'
}
// Add current company to list
addCompanyToList(DB)
document.getElementById('company-select').addEventListener('change', async function() {
var val = this.value
if (val === '__new') {
var input = prompt('Company name or full URL (e.g. mycompany or https://server.com/db/mycompany):')
if (!input) { renderCompanySelect(); return }
val = resolveDB(input.trim())
addCompanyToList(val)
}
window.__setDB(val)
try { await window.__loadData() } catch(e) {
var name = dbDisplayName(val)
window.__paperclip = {
company: { id: 'c1', name: name, status: 'active', issuePrefix: name.slice(0, 3).toUpperCase() },
agents: [], issues: [], projects: [], goals: [], activity: []
}
}
var d = window.__paperclip
document.getElementById('sb-agents-count').textContent = d.agents.length
document.getElementById('sb-issues-count').textContent = d.issues.filter(function(i) { return i.status !== 'done' && i.status !== 'completed' }).length
document.getElementById('sb-projects-count').textContent = d.projects.length
navigate('dashboard', 'Dashboard')
})
// ---- sidebar clicks ----
document.querySelectorAll('.sb-item').forEach(function(el) {
el.addEventListener('click', function() {
var labels = { dashboard: 'Dashboard', agents: 'Agents', issues: 'Issues',
projects: 'Projects', activity: 'Activity', goals: 'Goals', settings: 'Settings' }
navigate(el.dataset.nav, labels[el.dataset.nav] || el.dataset.nav)
closeSidebar()
})
})
// ---- boot ----
var _saved = null
try { _saved = JSON.parse(localStorage.getItem('taskify-pane')) } catch(e) {}
if (_saved && _saved.pane) { navigate(_saved.pane, _saved.label, _saved.context) }
else { navigate('dashboard', 'Dashboard') }
// ---- live sync via WebSocket ----
var _ws = null
function connectWS() {
if (_ws) { _ws.onclose = null; _ws.close() }
var wsHost, subPrefix
try {
var dbUrl = new URL(DB)
wsHost = (dbUrl.protocol === 'https:' ? 'wss:' : 'ws:') + '//' + dbUrl.host
subPrefix = dbUrl.origin + dbUrl.pathname
} catch(e) {
wsHost = (location.protocol === 'https:' ? 'wss:' : 'ws:') + '//' + location.host
subPrefix = location.origin + DB
}
_ws = new WebSocket(wsHost + '/.notifications')
_ws.onopen = function() { _ws.send('sub ' + subPrefix + '/') }
_ws.onmessage = async function(e) {
if (e.data.startsWith('pub ')) {
var pubUrl = e.data.slice(4)
var oldData = JSON.stringify(window.__paperclip)
try {
await loadData()
updateSidebarCounts()
renderContent()
// Detect what changed and toast it
var newData = JSON.stringify(window.__paperclip)
if (oldData !== newData) showChangeToast(pubUrl)
} catch (err) {
console.warn('[ws] reload failed:', err)
}
}
}
_ws.onclose = function() { setTimeout(connectWS, 3000) }
}
function updateSidebarCounts() {
var d = window.__paperclip
document.getElementById('sb-agents-count').textContent = d.agents.length
document.getElementById('sb-issues-count').textContent = d.issues.filter(function(i) { return i.status !== 'done' && i.status !== 'completed' }).length
document.getElementById('sb-projects-count').textContent = d.projects.length
}
var _audioCtx = null
var _soundEnabled = false
document.getElementById('sound-toggle').addEventListener('click', function() {
_soundEnabled = !_soundEnabled
if (_soundEnabled && !_audioCtx) {
_audioCtx = new (window.AudioContext || window.webkitAudioContext)()
}
this.textContent = _soundEnabled ? '🔊' : '🔇'
this.title = _soundEnabled ? 'Mute notifications' : 'Enable notification sounds'
if (_soundEnabled) playNotificationSound()
})
function playNotificationSound() {
if (!_soundEnabled || !_audioCtx) return
try {
var osc = _audioCtx.createOscillator()
var gain = _audioCtx.createGain()
osc.connect(gain)
gain.connect(_audioCtx.destination)
osc.frequency.setValueAtTime(880, _audioCtx.currentTime)
osc.frequency.setValueAtTime(1047, _audioCtx.currentTime + 0.08)
gain.gain.setValueAtTime(0.15, _audioCtx.currentTime)
gain.gain.exponentialRampToValueAtTime(0.001, _audioCtx.currentTime + 0.25)
osc.start(_audioCtx.currentTime)
osc.stop(_audioCtx.currentTime + 0.25)
} catch (e) {}
}
function showToast(icon, message) {
var el = document.createElement('div')
el.className = 'toast'
el.innerHTML = '<span class="toast-icon">' + icon + '</span>' + message
document.getElementById('toasts').appendChild(el)
playNotificationSound()
setTimeout(function() { el.style.opacity = '0'; el.style.transition = 'opacity 0.3s'; setTimeout(function() { el.remove() }, 300) }, 4000)
}
function showChangeToast(url) {
var parts = url.split('/')
var type = parts[parts.length - 2] || ''
var id = parts[parts.length - 1] || ''
var icons = { agents: '🤖', issues: '📋', projects: '📁', goals: '🎯', activity: '📡', company: '⚙️' }
var icon = icons[type] || '🔔'
// Try to find the entity name
var data = window.__paperclip
var name = id
if (type === 'agents') {
var agent = data.agents.find(function(a) { return a.id === id })
if (agent) name = agent.name
} else if (type === 'issues') {
var issue = data.issues.find(function(i) { return i.id === id })
if (issue) name = (issue.identifier || '') + ' ' + (issue.title || '')
} else if (type === 'projects') {
var project = data.projects.find(function(p) { return p.id === id })
if (project) name = project.name
} else if (type === 'activity') {
var act = data.activity.find(function(a) { return a.id === id })
if (act) name = act.action.replace(/\./g, ' → ')
}
if (name.length > 60) name = name.slice(0, 57) + '...'
showToast(icon, '<strong>' + type.slice(0, -1) + '</strong> updated: ' + name)
}
if (LIVE) connectWS()
// ---- xlogin + auth fetch ----
var _nativeFetch = window.fetch.bind(window)
var _inAuthFetch = false
window.fetch = function(url, opts) {
if (!_inAuthFetch && window.xlogin && window.xlogin.authFetch && opts && (opts.method === 'PUT' || opts.method === 'POST' || opts.method === 'DELETE' || opts.method === 'PATCH')) {
_inAuthFetch = true
return window.xlogin.authFetch(url, opts).finally(function() { _inAuthFetch = false })
}
return _nativeFetch(url, opts)
}
document.addEventListener('xlogin', function(e) {
console.log('[taskify] logged in:', e.detail.type, e.detail.id)
window.__user = { type: e.detail.type, id: e.detail.id }
})
document.addEventListener('xlogout', function() {
console.log('[taskify] logged out')
window.__user = null
})
</script>
<script src="https://unpkg.com/xlogin"></script>
</body>
</html>