@bakapiano/ccsm 0.10.3 → 0.12.0

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.
Files changed (51) hide show
  1. package/CLAUDE.md +475 -475
  2. package/README.md +190 -190
  3. package/bin/ccsm.js +194 -194
  4. package/lib/atomicJson.js +48 -0
  5. package/lib/cliSessionWatcher.js +249 -249
  6. package/lib/config.js +188 -185
  7. package/lib/folders.js +105 -96
  8. package/lib/jsonStore.js +15 -10
  9. package/lib/localCliSessions.js +489 -177
  10. package/lib/persistedSessions.js +142 -134
  11. package/lib/webTerminal.js +208 -208
  12. package/lib/workspace.js +230 -255
  13. package/package.json +57 -57
  14. package/public/css/base.css +99 -99
  15. package/public/css/cards.css +183 -183
  16. package/public/css/feedback.css +303 -303
  17. package/public/css/forms.css +405 -405
  18. package/public/css/layout.css +160 -160
  19. package/public/css/modal.css +190 -183
  20. package/public/css/responsive.css +10 -10
  21. package/public/css/sidebar.css +608 -601
  22. package/public/css/terminals.css +294 -294
  23. package/public/css/tokens.css +81 -79
  24. package/public/css/wco.css +98 -98
  25. package/public/css/widgets.css +1596 -1375
  26. package/public/index.html +105 -103
  27. package/public/js/api.js +272 -260
  28. package/public/js/components/AdoptModal.js +343 -171
  29. package/public/js/components/App.js +35 -35
  30. package/public/js/components/DirectoryPicker.js +203 -203
  31. package/public/js/components/EntityFormModal.js +105 -105
  32. package/public/js/components/Modal.js +51 -51
  33. package/public/js/components/OfflineBanner.js +93 -93
  34. package/public/js/components/PageTitleBar.js +13 -13
  35. package/public/js/components/Picker.js +179 -179
  36. package/public/js/components/Popover.js +55 -55
  37. package/public/js/components/Sidebar.js +341 -270
  38. package/public/js/components/TerminalView.js +298 -298
  39. package/public/js/components/useDragSort.js +67 -67
  40. package/public/js/dialog.js +67 -67
  41. package/public/js/icons.js +177 -177
  42. package/public/js/main.js +132 -140
  43. package/public/js/pages/AboutPage.js +165 -165
  44. package/public/js/pages/ConfigurePage.js +475 -487
  45. package/public/js/pages/LaunchPage.js +369 -369
  46. package/public/js/pages/SessionsPage.js +97 -97
  47. package/public/js/state.js +231 -231
  48. package/public/manifest.webmanifest +15 -15
  49. package/scripts/dev.js +59 -0
  50. package/scripts/install.js +137 -137
  51. package/server.js +1147 -1117
@@ -1,171 +1,343 @@
1
- // "Import existing session" modal. Browses sessions discovered on disk
2
- // for claude / codex / copilot, lets the user pick one, choose which
3
- // configured CLI it should be tied to, and adopts it — a ccsm
4
- // persistedSessions record is created with the upstream session id
5
- // pre-filled so clicking it later runs `<cli> --resume <id>` (via
6
- // cli.resumeIdArgs).
7
- //
8
- // Props:
9
- // onClose() — close request
10
- // onAdopted(sessionId) — fires after a successful adopt with
11
- // the new (or pre-existing) record id
12
- //
13
- // Shows a row of cli-type tabs at the top. Each tab loads on first
14
- // click. Adopted rows are greyed out and labelled.
15
-
16
- import { html } from '../html.js';
17
- import { useState, useEffect } from 'preact/hooks';
18
- import { Modal } from './Modal.js';
19
- import { config } from '../state.js';
20
- import { listLocalCliSessions, adoptSession } from '../api.js';
21
- import { setToast } from '../toast.js';
22
- import { IconForCliType, IconClaudeColor, IconCodexColor, IconCopilotColor } from '../icons.js';
23
-
24
- const TABS = [
25
- { type: 'claude', label: 'Claude', Icon: IconClaudeColor },
26
- { type: 'codex', label: 'Codex', Icon: IconCodexColor },
27
- { type: 'copilot', label: 'Copilot', Icon: IconCopilotColor },
28
- ];
29
-
30
- export function AdoptModal({ onClose, onAdopted }) {
31
- const [tab, setTab] = useState('claude');
32
- // cache per tab so flipping back is instant
33
- const [cache, setCache] = useState({}); // { claude: {loading, error, items} }
34
- const [adopting, setAdopting] = useState(null); // cliSessionId being adopted
35
-
36
- const load = async (type, { force = false } = {}) => {
37
- if (!force && cache[type] && !cache[type].error) return;
38
- setCache((c) => ({ ...c, [type]: { loading: true, items: [], error: null } }));
39
- try {
40
- const items = await listLocalCliSessions(type);
41
- setCache((c) => ({ ...c, [type]: { loading: false, items, error: null } }));
42
- } catch (e) {
43
- setCache((c) => ({ ...c, [type]: { loading: false, items: [], error: e.message } }));
44
- }
45
- };
46
-
47
- useEffect(() => { load(tab); /* eslint-disable-next-line */ }, [tab]);
48
-
49
- const cfg = config.value || {};
50
- const clis = cfg.clis || [];
51
- // Pick first matching configured CLI for the current upstream type; fall
52
- // back to the configured default. Users can change per-row via the select.
53
- const defaultCliFor = (type) => {
54
- const match = clis.find((c) => c.type === type);
55
- if (match) return match.id;
56
- return cfg.defaultCliId || clis[0]?.id || '';
57
- };
58
- const [chosenCli, setChosenCli] = useState({}); // cliSessionId → cli id override
59
-
60
- const adopt = async (item) => {
61
- const cliId = chosenCli[item.cliSessionId] || defaultCliFor(item.cliType);
62
- if (!cliId) { setToast('configure a CLI first', 'error'); return; }
63
- setAdopting(item.cliSessionId);
64
- try {
65
- const r = await adoptSession({
66
- cliId,
67
- cliSessionId: item.cliSessionId,
68
- cwd: item.cwd,
69
- title: item.summary || '',
70
- });
71
- if (r.alreadyAdopted) {
72
- setToast('already in ccsm — opened existing record');
73
- } else {
74
- setToast(`imported · ${item.cliSessionId.slice(0, 8)}…`);
75
- }
76
- // Mark adopted in the cache so the UI updates instantly.
77
- setCache((c) => ({
78
- ...c,
79
- [tab]: c[tab] ? {
80
- ...c[tab],
81
- items: c[tab].items.map((x) => x.cliSessionId === item.cliSessionId
82
- ? { ...x, adopted: true } : x),
83
- } : c[tab],
84
- }));
85
- onAdopted?.(r.session?.id);
86
- } catch (e) {
87
- setToast(e.message, 'error');
88
- } finally {
89
- setAdopting(null);
90
- }
91
- };
92
-
93
- const state = cache[tab] || { loading: true, items: [], error: null };
94
-
95
- return html`
96
- <${Modal} title="Import existing session" onClose=${onClose} width=${640}>
97
- <div class="adopt-tabs">
98
- ${TABS.map((t) => html`
99
- <button type="button"
100
- class=${`adopt-tab${tab === t.type ? ' is-active' : ''}`}
101
- onClick=${() => setTab(t.type)}>
102
- <span class="adopt-tab-icon"><${t.Icon} /></span>
103
- <span>${t.label}</span>
104
- </button>`)}
105
- <button type="button" class="action subtle adopt-refresh"
106
- title="Rescan"
107
- onClick=${() => load(tab, { force: true })}>Refresh</button>
108
- </div>
109
-
110
- <div class="adopt-body">
111
- ${state.loading ? html`
112
- <div class="adopt-empty">Scanning…</div>
113
- ` : state.error ? html`
114
- <div class="adopt-empty adopt-error">${state.error}</div>
115
- ` : state.items.length === 0 ? html`
116
- <div class="adopt-empty">No ${tab} sessions found on this machine.</div>
117
- ` : html`
118
- <ul class="adopt-list">
119
- ${state.items.map((it) => html`
120
- <li class=${`adopt-item${it.adopted ? ' is-adopted' : ''}`}
121
- key=${it.cliSessionId}>
122
- <div class="adopt-main">
123
- <div class="adopt-title">
124
- ${it.summary || html`<span class="ink-faint">(no preview)</span>`}
125
- </div>
126
- <div class="adopt-meta mono">
127
- ${it.cwd}
128
- <span class="adopt-sep">·</span>
129
- ${relTime(it.mtime)}
130
- <span class="adopt-sep">·</span>
131
- ${it.cliSessionId.slice(0, 8)}…
132
- </div>
133
- </div>
134
- <div class="adopt-actions">
135
- ${clis.length > 1 ? html`
136
- <select class="adopt-cli-select"
137
- value=${chosenCli[it.cliSessionId] || defaultCliFor(it.cliType)}
138
- onChange=${(e) => setChosenCli((m) => ({ ...m, [it.cliSessionId]: e.target.value }))}
139
- disabled=${it.adopted}>
140
- ${clis.map((c) => html`<option value=${c.id}>${c.name}</option>`)}
141
- </select>
142
- ` : null}
143
- ${it.adopted ? html`
144
- <span class="adopt-badge">Imported</span>
145
- ` : html`
146
- <button type="button" class="action primary adopt-btn"
147
- disabled=${adopting === it.cliSessionId}
148
- onClick=${() => adopt(it)}>
149
- ${adopting === it.cliSessionId ? 'Importing…' : 'Import'}
150
- </button>
151
- `}
152
- </div>
153
- </li>`)}
154
- </ul>
155
- `}
156
- </div>
157
- </${Modal}>`;
158
- }
159
-
160
- function relTime(ms) {
161
- if (!ms) return '';
162
- const d = Date.now() - ms;
163
- const s = Math.round(d / 1000);
164
- if (s < 60) return `${s}s ago`;
165
- const m = Math.round(s / 60);
166
- if (m < 60) return `${m}m ago`;
167
- const h = Math.round(m / 60);
168
- if (h < 48) return `${h}h ago`;
169
- const days = Math.round(h / 24);
170
- return `${days}d ago`;
171
- }
1
+ // "Import existing session" modal. Browses sessions discovered on disk
2
+ // for claude / codex / copilot, lets the user pick one, choose which
3
+ // configured CLI it should be tied to, and adopts it — a ccsm
4
+ // persistedSessions record is created with the upstream session id
5
+ // pre-filled so clicking it later runs `<cli> --resume <id>` (via
6
+ // cli.resumeIdArgs).
7
+ //
8
+ // Props:
9
+ // onClose() — close request
10
+ // onAdopted(sessionId) — fires after a successful adopt with
11
+ // the new (or pre-existing) record id
12
+ //
13
+ // Tabs across the top switch the upstream type. Below the tabs, an
14
+ // "Adopt as <CLI ▾>" chip filters the configured CLIs by matching
15
+ // `type` and reuses the global PickerPanel popover. A search box
16
+ // filters rows by title + cwd. Each row is a card with the prompt
17
+ // summary, cwd, age, and an Import button.
18
+
19
+ import { html } from '../html.js';
20
+ import { useState, useEffect, useRef, useMemo } from 'preact/hooks';
21
+ import { Modal } from './Modal.js';
22
+ import { Popover } from './Popover.js';
23
+ import { PickerPanel } from './Picker.js';
24
+ import { config } from '../state.js';
25
+ import { listLocalCliSessions, adoptSession } from '../api.js';
26
+ import { setToast } from '../toast.js';
27
+ import {
28
+ IconForCliType, IconClaudeColor, IconCodexColor, IconCopilotColor,
29
+ IconSearch, IconClose, IconChevronDown, IconBranch,
30
+ } from '../icons.js';
31
+
32
+ const TABS = [
33
+ { type: 'claude', label: 'Claude', Icon: IconClaudeColor },
34
+ { type: 'codex', label: 'Codex', Icon: IconCodexColor },
35
+ { type: 'copilot', label: 'Copilot', Icon: IconCopilotColor },
36
+ ];
37
+
38
+ const PAGE_SIZE = 30;
39
+
40
+ export function AdoptModal({ onClose, onAdopted }) {
41
+ const [tab, setTab] = useState('claude');
42
+ // cache shape per tab: { loading, loadingMore, error, items, offset,
43
+ // hasMore, totalActive, totalNonActive }
44
+ const [cache, setCache] = useState({});
45
+ const [adopting, setAdopting] = useState(null);
46
+ const [query, setQuery] = useState('');
47
+ const [pickerOpen, setPickerOpen] = useState(false);
48
+ const [cliOverride, setCliOverride] = useState({});
49
+ const cliAnchorRef = useRef(null);
50
+
51
+ const load = async (type, { force = false } = {}) => {
52
+ const existing = cache[type];
53
+ if (!force && existing && !existing.error && existing.items.length) return;
54
+ setCache((c) => ({
55
+ ...c,
56
+ [type]: { loading: true, loadingMore: false, items: [], error: null,
57
+ offset: 0, hasMore: false, totalActive: 0, totalNonActive: 0 },
58
+ }));
59
+ try {
60
+ const r = await listLocalCliSessions(type, { offset: 0, limit: PAGE_SIZE });
61
+ setCache((c) => ({
62
+ ...c,
63
+ [type]: {
64
+ loading: false, loadingMore: false, error: null,
65
+ items: r.sessions,
66
+ offset: r.offset + r.sessions.filter((s) => !s.active).length, // advance past hydrated non-active
67
+ hasMore: r.hasMore,
68
+ totalActive: r.totalActive,
69
+ totalNonActive: r.totalNonActive,
70
+ },
71
+ }));
72
+ } catch (e) {
73
+ setCache((c) => ({
74
+ ...c,
75
+ [type]: { loading: false, loadingMore: false, items: [], error: e.message,
76
+ offset: 0, hasMore: false, totalActive: 0, totalNonActive: 0 },
77
+ }));
78
+ }
79
+ };
80
+
81
+ const loadMore = async () => {
82
+ const cur = cache[tab];
83
+ if (!cur || cur.loadingMore || !cur.hasMore) return;
84
+ setCache((c) => ({ ...c, [tab]: { ...c[tab], loadingMore: true } }));
85
+ try {
86
+ const r = await listLocalCliSessions(tab, { offset: cur.offset, limit: PAGE_SIZE });
87
+ setCache((c) => {
88
+ const entry = c[tab];
89
+ const existingIds = new Set(entry.items.map((x) => x.cliSessionId));
90
+ const additions = r.sessions.filter((s) => !existingIds.has(s.cliSessionId));
91
+ return {
92
+ ...c,
93
+ [tab]: {
94
+ ...entry,
95
+ loadingMore: false,
96
+ items: [...entry.items, ...additions],
97
+ offset: cur.offset + additions.filter((s) => !s.active).length,
98
+ hasMore: r.hasMore,
99
+ },
100
+ };
101
+ });
102
+ } catch (e) {
103
+ setCache((c) => ({ ...c, [tab]: { ...c[tab], loadingMore: false, error: e.message } }));
104
+ }
105
+ };
106
+
107
+ useEffect(() => { load(tab); /* eslint-disable-next-line */ }, [tab]);
108
+ // Clear search when switching tabs
109
+ useEffect(() => { setQuery(''); }, [tab]);
110
+
111
+ const cfg = config.value || {};
112
+ const clis = cfg.clis || [];
113
+ // CLIs of the same upstream `type` as the active tab — these are the
114
+ // ones the row's `--resume <id>` template will actually work with.
115
+ const matchingClis = useMemo(
116
+ () => clis.filter((c) => c.type === tab),
117
+ [clis, tab],
118
+ );
119
+
120
+ // Effective CLI for the current tab: user override → first matching
121
+ // → configured default → first cli.
122
+ const effectiveCliId =
123
+ cliOverride[tab]
124
+ || matchingClis[0]?.id
125
+ || cfg.defaultCliId
126
+ || clis[0]?.id
127
+ || '';
128
+ const effectiveCli = clis.find((c) => c.id === effectiveCliId) || null;
129
+
130
+ // Items the picker shows — prefer same-type CLIs at top, then dim others.
131
+ const pickerItems = useMemo(() => {
132
+ const Icon = IconForCliType(tab);
133
+ const top = matchingClis.map((c) => ({
134
+ id: c.id,
135
+ icon: html`<${Icon} />`,
136
+ label: c.name,
137
+ meta: c.command,
138
+ }));
139
+ const others = clis
140
+ .filter((c) => c.type !== tab)
141
+ .map((c) => {
142
+ const I = IconForCliType(c.type);
143
+ return {
144
+ id: c.id,
145
+ icon: html`<${I} />`,
146
+ label: c.name,
147
+ meta: `(non-${tab})`,
148
+ };
149
+ });
150
+ return [...top, ...others];
151
+ }, [clis, matchingClis, tab]);
152
+
153
+ const state = cache[tab] || {
154
+ loading: true, loadingMore: false, items: [], error: null,
155
+ offset: 0, hasMore: false, totalActive: 0, totalNonActive: 0,
156
+ };
157
+ const items = useMemo(() => {
158
+ const q = query.trim().toLowerCase();
159
+ if (!q) return state.items;
160
+ return state.items.filter((it) => {
161
+ const hay = `${it.summary || ''} ${it.cwd || ''} ${it.cliSessionId}`.toLowerCase();
162
+ return hay.includes(q);
163
+ });
164
+ }, [state.items, query]);
165
+
166
+ const totalKnown = state.totalActive + state.totalNonActive;
167
+ const unimportedCount = state.items.filter((it) => !it.adopted).length;
168
+
169
+ const adopt = async (item) => {
170
+ const cliId = effectiveCliId;
171
+ if (!cliId) { setToast('configure a CLI first', 'error'); return; }
172
+ setAdopting(item.cliSessionId);
173
+ try {
174
+ const r = await adoptSession({
175
+ cliId,
176
+ cliSessionId: item.cliSessionId,
177
+ cwd: item.cwd,
178
+ title: item.summary || '',
179
+ });
180
+ if (r.alreadyAdopted) setToast('already in ccsm — opened existing record');
181
+ else setToast(`imported · ${item.cliSessionId.slice(0, 8)}…`);
182
+ setCache((c) => ({
183
+ ...c,
184
+ [tab]: c[tab] ? {
185
+ ...c[tab],
186
+ items: c[tab].items.map((x) => x.cliSessionId === item.cliSessionId
187
+ ? { ...x, adopted: true } : x),
188
+ } : c[tab],
189
+ }));
190
+ onAdopted?.(r.session?.id);
191
+ } catch (e) {
192
+ setToast(e.message, 'error');
193
+ } finally {
194
+ setAdopting(null);
195
+ }
196
+ };
197
+
198
+ return html`
199
+ <${Modal} title="Import existing session" onClose=${onClose} width=${680}>
200
+ <div class="adopt">
201
+ <!-- Tabs row -->
202
+ <div class="adopt-tabs">
203
+ ${TABS.map((t) => {
204
+ const cnt = cache[t.type]?.items?.filter((x) => !x.adopted).length;
205
+ return html`
206
+ <button type="button" key=${t.type}
207
+ class=${`adopt-tab${tab === t.type ? ' is-active' : ''}`}
208
+ onClick=${() => setTab(t.type)}>
209
+ <span class="adopt-tab-icon"><${t.Icon} /></span>
210
+ <span>${t.label}</span>
211
+ ${typeof cnt === 'number' && cnt > 0 ? html`
212
+ <span class="adopt-tab-count">${cnt}</span>
213
+ ` : null}
214
+ </button>`;
215
+ })}
216
+ <button type="button" class="adopt-icon-btn" title="Rescan"
217
+ onClick=${() => load(tab, { force: true })}>
218
+ <svg viewBox="0 0 16 16" width="13" height="13" aria-hidden="true">
219
+ <path d="M2 8a6 6 0 0 1 10.3-4.2L14 2v4h-4l1.5-1.5A4.5 4.5 0 1 0 12.5 8H14a6 6 0 1 1-12 0z"
220
+ fill="none" stroke="currentColor" stroke-width="1.4" stroke-linejoin="round"/>
221
+ </svg>
222
+ </button>
223
+ </div>
224
+
225
+ <!-- Tools row: CLI picker + search -->
226
+ <div class="adopt-tools">
227
+ <button type="button" ref=${cliAnchorRef}
228
+ class=${`adopt-cli-pill${pickerOpen ? ' is-open' : ''}`}
229
+ onClick=${() => setPickerOpen((v) => !v)}>
230
+ <span class="adopt-cli-pill-prefix">Adopt as</span>
231
+ <span class="adopt-cli-pill-icon">
232
+ ${effectiveCli ? html`${(() => {
233
+ const I = IconForCliType(effectiveCli.type);
234
+ return html`<${I} />`;
235
+ })()}` : null}
236
+ </span>
237
+ <span class="adopt-cli-pill-name">${effectiveCli?.name || 'choose CLI'}</span>
238
+ <${IconChevronDown} />
239
+ </button>
240
+ ${pickerOpen ? html`
241
+ <${Popover} anchor=${cliAnchorRef} onClose=${() => setPickerOpen(false)} width=${300}>
242
+ <${PickerPanel}
243
+ title=${`CLI for ${tab} sessions`}
244
+ items=${pickerItems}
245
+ selectedId=${effectiveCliId}
246
+ showSearch=${pickerItems.length > 6}
247
+ emptyHint=${`No configured CLIs match ${tab}.`}
248
+ onSelect=${(id) => { setCliOverride((m) => ({ ...m, [tab]: id })); }}
249
+ onClose=${() => setPickerOpen(false)} />
250
+ </${Popover}>` : null}
251
+
252
+ <div class="adopt-search">
253
+ <span class="adopt-search-icon"><${IconSearch} /></span>
254
+ <input class="adopt-search-input"
255
+ placeholder=${state.loading ? 'Loading…' : `Search ${unimportedCount} sessions…`}
256
+ value=${query} disabled=${state.loading}
257
+ onInput=${(e) => setQuery(e.target.value)} />
258
+ ${query ? html`
259
+ <button class="adopt-search-clear" type="button"
260
+ onClick=${() => setQuery('')} title="Clear">
261
+ <${IconClose} />
262
+ </button>` : null}
263
+ </div>
264
+ </div>
265
+
266
+ <!-- List body -->
267
+ <div class="adopt-body">
268
+ ${state.loading ? html`
269
+ <div class="adopt-empty"><span class="adopt-empty-spinner"></span> Scanning…</div>
270
+ ` : state.error ? html`
271
+ <div class="adopt-empty adopt-error">${state.error}</div>
272
+ ` : state.items.length === 0 ? html`
273
+ <div class="adopt-empty">
274
+ <div class="adopt-empty-mark">∅</div>
275
+ No ${tab} sessions found on this machine.
276
+ </div>
277
+ ` : items.length === 0 ? html`
278
+ <div class="adopt-empty">No matches for "${query}".</div>
279
+ ` : html`
280
+ <ul class="adopt-list" data-shown=${items.length} data-total=${totalKnown}>
281
+ ${items.map((it) => html`
282
+ <li class=${`adopt-row${it.adopted ? ' is-adopted' : ''}${it.active ? ' is-active' : ''}`}
283
+ key=${it.cliSessionId}>
284
+ <div class="adopt-row-main">
285
+ <div class="adopt-row-title">
286
+ ${it.active ? html`<span class="adopt-row-live" title="A CLI process has this session open right now">● live</span>` : null}
287
+ ${it.summary || html`<span class="adopt-row-untitled">untitled session</span>`}
288
+ </div>
289
+ <div class="adopt-row-meta">
290
+ <span class="adopt-row-path mono" title=${it.cwd || ''}>${it.cwd || '—'}</span>
291
+ <span class="adopt-row-dot">·</span>
292
+ <span>${relTime(it.mtime)}</span>
293
+ <span class="adopt-row-dot">·</span>
294
+ <span class="adopt-row-id mono">${it.cliSessionId.slice(0, 8)}</span>
295
+ </div>
296
+ </div>
297
+ <div class="adopt-row-actions">
298
+ ${it.adopted ? html`
299
+ <span class="adopt-row-badge">Imported</span>
300
+ ` : html`
301
+ <button type="button" class="action primary adopt-row-btn"
302
+ disabled=${adopting === it.cliSessionId || !effectiveCliId}
303
+ onClick=${() => adopt(it)}>
304
+ ${adopting === it.cliSessionId ? 'Importing…' : 'Import'}
305
+ </button>
306
+ `}
307
+ </div>
308
+ </li>`)}
309
+ </ul>
310
+ ${state.hasMore && !query ? html`
311
+ <div class="adopt-loadmore">
312
+ <button type="button" class="action subtle"
313
+ disabled=${state.loadingMore}
314
+ onClick=${loadMore}>
315
+ ${state.loadingMore ? 'Loading…'
316
+ : `Load ${Math.min(PAGE_SIZE, state.totalNonActive - state.offset)} more · ${state.items.length} / ${totalKnown}`}
317
+ </button>
318
+ </div>` : !query && state.items.length > 0 ? html`
319
+ <div class="adopt-loadmore adopt-loadmore-done">
320
+ All ${totalKnown} sessions loaded
321
+ </div>` : null}
322
+ ${query && state.hasMore ? html`
323
+ <div class="adopt-loadmore adopt-loadmore-hint">
324
+ Searching ${state.items.length} loaded · clear search and Load more to see older sessions
325
+ </div>` : null}
326
+ `}
327
+ </div>
328
+ </div>
329
+ </${Modal}>`;
330
+ }
331
+
332
+ function relTime(ms) {
333
+ if (!ms) return '';
334
+ const d = Date.now() - ms;
335
+ const s = Math.round(d / 1000);
336
+ if (s < 60) return `${s}s ago`;
337
+ const m = Math.round(s / 60);
338
+ if (m < 60) return `${m}m ago`;
339
+ const h = Math.round(m / 60);
340
+ if (h < 48) return `${h}h ago`;
341
+ const days = Math.round(h / 24);
342
+ return `${days}d ago`;
343
+ }
@@ -1,35 +1,35 @@
1
- import { html } from '../html.js';
2
- import { activeTab } from '../state.js';
3
- import { Sidebar } from './Sidebar.js';
4
- import { Toast } from './Toast.js';
5
- import { DialogHost } from './DialogHost.js';
6
- import { OfflineBanner } from './OfflineBanner.js';
7
- import { SessionsPage } from '../pages/SessionsPage.js';
8
- import { LaunchPage } from '../pages/LaunchPage.js';
9
- import { ConfigurePage } from '../pages/ConfigurePage.js';
10
- import { AboutPage } from '../pages/AboutPage.js';
11
-
12
- function Panel({ name, children }) {
13
- const active = activeTab.value === name;
14
- return html`<section class="tab-panel" data-panel=${name} data-active=${active || null}>${children}</section>`;
15
- }
16
-
17
- export function App() {
18
- const tab = activeTab.value;
19
-
20
- return html`
21
- <div class="app">
22
- <${Sidebar} />
23
- <main class="main">
24
- <div class="content">
25
- ${tab === 'sessions' ? html`<${Panel} name="sessions"><${SessionsPage} /></${Panel}>` : null}
26
- ${tab === 'launch' ? html`<${Panel} name="launch"><${LaunchPage} /></${Panel}>` : null}
27
- ${tab === 'configure' ? html`<${Panel} name="configure"><${ConfigurePage} /></${Panel}>` : null}
28
- ${tab === 'about' ? html`<${Panel} name="about"><${AboutPage} /></${Panel}>` : null}
29
- </div>
30
- </main>
31
- <${OfflineBanner} />
32
- <${Toast} />
33
- <${DialogHost} />
34
- </div>`;
35
- }
1
+ import { html } from '../html.js';
2
+ import { activeTab } from '../state.js';
3
+ import { Sidebar } from './Sidebar.js';
4
+ import { Toast } from './Toast.js';
5
+ import { DialogHost } from './DialogHost.js';
6
+ import { OfflineBanner } from './OfflineBanner.js';
7
+ import { SessionsPage } from '../pages/SessionsPage.js';
8
+ import { LaunchPage } from '../pages/LaunchPage.js';
9
+ import { ConfigurePage } from '../pages/ConfigurePage.js';
10
+ import { AboutPage } from '../pages/AboutPage.js';
11
+
12
+ function Panel({ name, children }) {
13
+ const active = activeTab.value === name;
14
+ return html`<section class="tab-panel" data-panel=${name} data-active=${active || null}>${children}</section>`;
15
+ }
16
+
17
+ export function App() {
18
+ const tab = activeTab.value;
19
+
20
+ return html`
21
+ <div class="app">
22
+ <${Sidebar} />
23
+ <main class="main">
24
+ <div class="content">
25
+ ${tab === 'sessions' ? html`<${Panel} name="sessions"><${SessionsPage} /></${Panel}>` : null}
26
+ ${tab === 'launch' ? html`<${Panel} name="launch"><${LaunchPage} /></${Panel}>` : null}
27
+ ${tab === 'configure' ? html`<${Panel} name="configure"><${ConfigurePage} /></${Panel}>` : null}
28
+ ${tab === 'about' ? html`<${Panel} name="about"><${AboutPage} /></${Panel}>` : null}
29
+ </div>
30
+ </main>
31
+ <${OfflineBanner} />
32
+ <${Toast} />
33
+ <${DialogHost} />
34
+ </div>`;
35
+ }