@bakapiano/ccsm 0.22.3 → 0.22.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.
Files changed (61) hide show
  1. package/CLAUDE.md +538 -538
  2. package/README.md +189 -189
  3. package/bin/ccsm.js +235 -235
  4. package/lib/cliActivity.js +139 -139
  5. package/lib/codexSeed.js +183 -183
  6. package/lib/config.js +274 -274
  7. package/lib/devices.js +229 -229
  8. package/lib/folders.js +124 -124
  9. package/lib/localCliSessions.js +519 -519
  10. package/lib/persistedSessions.js +129 -129
  11. package/lib/tunnel.js +621 -621
  12. package/lib/webTerminal.js +225 -225
  13. package/lib/workspace.js +233 -233
  14. package/package.json +57 -57
  15. package/public/css/base.css +99 -99
  16. package/public/css/cards.css +183 -183
  17. package/public/css/feedback.css +504 -504
  18. package/public/css/forms.css +453 -453
  19. package/public/css/layout.css +176 -176
  20. package/public/css/modal.css +190 -190
  21. package/public/css/responsive.css +176 -176
  22. package/public/css/sidebar.css +707 -707
  23. package/public/css/terminals.css +645 -543
  24. package/public/css/tokens.css +81 -81
  25. package/public/css/wco.css +196 -196
  26. package/public/css/widgets.css +2725 -2725
  27. package/public/index.html +152 -152
  28. package/public/js/api.js +371 -371
  29. package/public/js/backend.js +149 -149
  30. package/public/js/components/App.js +73 -73
  31. package/public/js/components/DirectoryPicker.js +203 -203
  32. package/public/js/components/EntityFormModal.js +153 -153
  33. package/public/js/components/Modal.js +57 -57
  34. package/public/js/components/OfflineBanner.js +67 -67
  35. package/public/js/components/PageTitleBar.js +13 -13
  36. package/public/js/components/PendingApprovalOverlay.js +128 -128
  37. package/public/js/components/Picker.js +179 -179
  38. package/public/js/components/Popover.js +55 -55
  39. package/public/js/components/RestartOverlay.js +36 -36
  40. package/public/js/components/Sidebar.js +380 -380
  41. package/public/js/components/TerminalInstance.js +159 -22
  42. package/public/js/components/TerminalResizeDebouncer.js +126 -0
  43. package/public/js/components/TerminalView.js +15 -2
  44. package/public/js/components/XtermTerminal.js +74 -15
  45. package/public/js/components/useDragSort.js +67 -67
  46. package/public/js/dialog.js +67 -67
  47. package/public/js/icons.js +212 -212
  48. package/public/js/main.js +296 -296
  49. package/public/js/pages/AboutPage.js +90 -90
  50. package/public/js/pages/ConfigurePage.js +713 -713
  51. package/public/js/pages/LaunchPage.js +421 -421
  52. package/public/js/pages/RemotePage.js +743 -743
  53. package/public/js/pages/SessionsPage.js +199 -80
  54. package/public/js/state.js +335 -335
  55. package/public/manifest.webmanifest +25 -0
  56. package/public/setup/index.html +567 -0
  57. package/scripts/dev.js +149 -149
  58. package/scripts/install.js +153 -153
  59. package/scripts/restart-helper.js +96 -96
  60. package/scripts/upgrade-helper.js +687 -687
  61. package/server.js +1807 -1807
@@ -1,153 +1,153 @@
1
- // Generic create/edit form rendered inside a Modal. Field shape mirrors
2
- // the createFields prop used by Picker.js so the same field-definition
3
- // objects power both the inline-create-in-popover flow and the standalone
4
- // edit flow used from Configure.
5
- //
6
- // Usage:
7
- // <${EntityFormModal}
8
- // title="Edit CLI"
9
- // fields=${cliFields}
10
- // initial=${currentValues}
11
- // onSubmit=${async (values) => { ... }}
12
- // onClose=${close} />
13
-
14
- import { html } from '../html.js';
15
- import { useState } from 'preact/hooks';
16
- import { Modal } from './Modal.js';
17
-
18
- export function EntityFormModal({
19
- title, fields, initial = {}, submitLabel = 'Save',
20
- readOnlyKeys = [],
21
- onSubmit, onClose, onTest, testLabel = 'Test',
22
- danger,
23
- }) {
24
- const [draft, setDraft] = useState(() => ({ ...initialFrom(fields), ...initial }));
25
- const [saving, setSaving] = useState(false);
26
- const [testing, setTesting] = useState(false);
27
- const [testResult, setTestResult] = useState(null);
28
-
29
- // A field is read-only if its key is in the static `readOnlyKeys`
30
- // prop OR its own `readOnly` predicate (called with the current
31
- // draft) returns true. The predicate lets a field react to other
32
- // fields' values — e.g. lock newSessionIdArgs once a known `type`
33
- // is picked, since those args are an integration contract with the
34
- // upstream CLI, not a user knob.
35
- const isReadOnly = (field) => {
36
- if (readOnlyKeys.includes(field.key)) return true;
37
- if (typeof field.readOnly === 'function') {
38
- try { return !!field.readOnly(draft); } catch { return false; }
39
- }
40
- return !!field.readOnly;
41
- };
42
-
43
- const submit = async (ev) => {
44
- ev?.preventDefault?.();
45
- for (const f of fields) {
46
- if (f.required && !String(draft[f.key] || '').trim()) return;
47
- }
48
- setSaving(true);
49
- try { await onSubmit?.(draft); onClose?.(); }
50
- catch { /* caller toasts; stay open */ }
51
- finally { setSaving(false); }
52
- };
53
-
54
- const runTest = async () => {
55
- if (!onTest) return;
56
- setTesting(true);
57
- setTestResult(null);
58
- try {
59
- const r = await onTest(draft);
60
- setTestResult(r);
61
- } catch (e) {
62
- setTestResult({ ok: false, spawnError: String(e?.message || e) });
63
- } finally {
64
- setTesting(false);
65
- }
66
- };
67
-
68
- const footer = html`
69
- ${onTest ? html`
70
- <button type="button" class="action small subtle entity-test-button"
71
- disabled=${testing} onClick=${runTest}>
72
- ${testing ? 'Testing…' : testLabel}
73
- </button>` : null}
74
- <button type="button" class="action small subtle" onClick=${onClose}>Cancel</button>
75
- <button type="submit" form="entity-form-modal" class=${`action small ${danger ? 'danger' : 'primary'}`}
76
- disabled=${saving}>
77
- ${saving ? 'Saving…' : submitLabel}
78
- </button>`;
79
-
80
- return html`
81
- <${Modal} title=${title} onClose=${onClose} width=${440} footer=${footer}>
82
- <form id="entity-form-modal" class="entity-form" onSubmit=${submit}>
83
- ${fields.map((f) => html`
84
- <label class="entity-field" key=${f.key}>
85
- <span class="entity-field-label">${f.label}</span>
86
- ${f.type === 'select' ? html`
87
- <select class="input" value=${draft[f.key] || ''}
88
- disabled=${isReadOnly(f)}
89
- onChange=${(e) => {
90
- const next = { ...draft, [f.key]: e.target.value };
91
- const sideEffects = f.onChange?.(e.target.value, next);
92
- setDraft(sideEffects ? { ...next, ...sideEffects } : next);
93
- }}>
94
- ${(f.options || []).map((opt) => html`
95
- <option value=${opt.value}>${opt.label}</option>`)}
96
- </select>
97
- ` : f.type === 'iconRadio' ? html`
98
- <div class=${`icon-radio${isReadOnly(f) ? ' is-disabled' : ''}`}>
99
- ${(f.options || []).map((opt) => html`
100
- <button type="button" key=${opt.value}
101
- class=${`icon-radio-opt${draft[f.key] === opt.value ? ' is-active' : ''}`}
102
- disabled=${isReadOnly(f)}
103
- onClick=${() => {
104
- if (isReadOnly(f)) return;
105
- const next = { ...draft, [f.key]: opt.value };
106
- const sideEffects = f.onChange?.(opt.value, next);
107
- setDraft(sideEffects ? { ...next, ...sideEffects } : next);
108
- }}>
109
- ${opt.icon ? html`<span class="icon-radio-icon">${opt.icon}</span>` : null}
110
- <span>${opt.label}</span>
111
- </button>`)}
112
- </div>
113
- ` : f.type === 'checkbox' ? html`
114
- <span class="entity-checkbox-row">
115
- <input type="checkbox" checked=${!!draft[f.key]}
116
- disabled=${isReadOnly(f)}
117
- onChange=${(e) => setDraft({ ...draft, [f.key]: e.target.checked })} />
118
- ${f.hint ? html`<span class="entity-field-hint">${typeof f.hint === 'function' ? f.hint(draft) : f.hint}</span>` : null}
119
- </span>
120
- ` : html`
121
- <input type=${f.type || 'text'}
122
- class=${`input${f.mono ? ' mono' : ''}`}
123
- placeholder=${f.placeholder || ''}
124
- value=${draft[f.key] || ''}
125
- readonly=${isReadOnly(f)}
126
- onInput=${(e) => setDraft({ ...draft, [f.key]: e.target.value })}
127
- autoFocus=${f.autoFocus && !isReadOnly(f)} />`}
128
- ${f.hint && f.type !== 'checkbox' ? html`
129
- <span class="entity-field-hint">${typeof f.hint === 'function' ? f.hint(draft) : f.hint}</span>` : null}
130
- </label>`)}
131
- ${testResult ? html`
132
- <div class=${`entity-test-result ${testResult.ok ? 'is-ok' : 'is-fail'}`}>
133
- <div class="entity-test-summary">
134
- ${testResult.ok ? '✓' : '✗'} ${testResult.ok ? 'works' : 'failed'}
135
- ${typeof testResult.exitCode === 'number' ? html` · exit ${testResult.exitCode}` : null}
136
- ${typeof testResult.durationMs === 'number' ? html` · ${testResult.durationMs}ms` : null}
137
- ${testResult.timedOut ? html` · timed out` : null}
138
- ${testResult.matchedType === true ? html` · type matches ${testResult.expectedType}` : null}
139
- ${testResult.matchedType === false ? html` · type mismatch (expected ${testResult.expectedType})` : null}
140
- </div>
141
- ${testResult.spawnError ? html`<pre class="entity-test-out">${testResult.spawnError}</pre>` : null}
142
- ${testResult.stdout ? html`<pre class="entity-test-out">${testResult.stdout}</pre>` : null}
143
- ${testResult.stderr ? html`<pre class="entity-test-out is-stderr">${testResult.stderr}</pre>` : null}
144
- </div>` : null}
145
- </form>
146
- </${Modal}>`;
147
- }
148
-
149
- function initialFrom(fields) {
150
- const out = {};
151
- for (const f of fields) out[f.key] = f.default ?? '';
152
- return out;
153
- }
1
+ // Generic create/edit form rendered inside a Modal. Field shape mirrors
2
+ // the createFields prop used by Picker.js so the same field-definition
3
+ // objects power both the inline-create-in-popover flow and the standalone
4
+ // edit flow used from Configure.
5
+ //
6
+ // Usage:
7
+ // <${EntityFormModal}
8
+ // title="Edit CLI"
9
+ // fields=${cliFields}
10
+ // initial=${currentValues}
11
+ // onSubmit=${async (values) => { ... }}
12
+ // onClose=${close} />
13
+
14
+ import { html } from '../html.js';
15
+ import { useState } from 'preact/hooks';
16
+ import { Modal } from './Modal.js';
17
+
18
+ export function EntityFormModal({
19
+ title, fields, initial = {}, submitLabel = 'Save',
20
+ readOnlyKeys = [],
21
+ onSubmit, onClose, onTest, testLabel = 'Test',
22
+ danger,
23
+ }) {
24
+ const [draft, setDraft] = useState(() => ({ ...initialFrom(fields), ...initial }));
25
+ const [saving, setSaving] = useState(false);
26
+ const [testing, setTesting] = useState(false);
27
+ const [testResult, setTestResult] = useState(null);
28
+
29
+ // A field is read-only if its key is in the static `readOnlyKeys`
30
+ // prop OR its own `readOnly` predicate (called with the current
31
+ // draft) returns true. The predicate lets a field react to other
32
+ // fields' values — e.g. lock newSessionIdArgs once a known `type`
33
+ // is picked, since those args are an integration contract with the
34
+ // upstream CLI, not a user knob.
35
+ const isReadOnly = (field) => {
36
+ if (readOnlyKeys.includes(field.key)) return true;
37
+ if (typeof field.readOnly === 'function') {
38
+ try { return !!field.readOnly(draft); } catch { return false; }
39
+ }
40
+ return !!field.readOnly;
41
+ };
42
+
43
+ const submit = async (ev) => {
44
+ ev?.preventDefault?.();
45
+ for (const f of fields) {
46
+ if (f.required && !String(draft[f.key] || '').trim()) return;
47
+ }
48
+ setSaving(true);
49
+ try { await onSubmit?.(draft); onClose?.(); }
50
+ catch { /* caller toasts; stay open */ }
51
+ finally { setSaving(false); }
52
+ };
53
+
54
+ const runTest = async () => {
55
+ if (!onTest) return;
56
+ setTesting(true);
57
+ setTestResult(null);
58
+ try {
59
+ const r = await onTest(draft);
60
+ setTestResult(r);
61
+ } catch (e) {
62
+ setTestResult({ ok: false, spawnError: String(e?.message || e) });
63
+ } finally {
64
+ setTesting(false);
65
+ }
66
+ };
67
+
68
+ const footer = html`
69
+ ${onTest ? html`
70
+ <button type="button" class="action small subtle entity-test-button"
71
+ disabled=${testing} onClick=${runTest}>
72
+ ${testing ? 'Testing…' : testLabel}
73
+ </button>` : null}
74
+ <button type="button" class="action small subtle" onClick=${onClose}>Cancel</button>
75
+ <button type="submit" form="entity-form-modal" class=${`action small ${danger ? 'danger' : 'primary'}`}
76
+ disabled=${saving}>
77
+ ${saving ? 'Saving…' : submitLabel}
78
+ </button>`;
79
+
80
+ return html`
81
+ <${Modal} title=${title} onClose=${onClose} width=${440} footer=${footer}>
82
+ <form id="entity-form-modal" class="entity-form" onSubmit=${submit}>
83
+ ${fields.map((f) => html`
84
+ <label class="entity-field" key=${f.key}>
85
+ <span class="entity-field-label">${f.label}</span>
86
+ ${f.type === 'select' ? html`
87
+ <select class="input" value=${draft[f.key] || ''}
88
+ disabled=${isReadOnly(f)}
89
+ onChange=${(e) => {
90
+ const next = { ...draft, [f.key]: e.target.value };
91
+ const sideEffects = f.onChange?.(e.target.value, next);
92
+ setDraft(sideEffects ? { ...next, ...sideEffects } : next);
93
+ }}>
94
+ ${(f.options || []).map((opt) => html`
95
+ <option value=${opt.value}>${opt.label}</option>`)}
96
+ </select>
97
+ ` : f.type === 'iconRadio' ? html`
98
+ <div class=${`icon-radio${isReadOnly(f) ? ' is-disabled' : ''}`}>
99
+ ${(f.options || []).map((opt) => html`
100
+ <button type="button" key=${opt.value}
101
+ class=${`icon-radio-opt${draft[f.key] === opt.value ? ' is-active' : ''}`}
102
+ disabled=${isReadOnly(f)}
103
+ onClick=${() => {
104
+ if (isReadOnly(f)) return;
105
+ const next = { ...draft, [f.key]: opt.value };
106
+ const sideEffects = f.onChange?.(opt.value, next);
107
+ setDraft(sideEffects ? { ...next, ...sideEffects } : next);
108
+ }}>
109
+ ${opt.icon ? html`<span class="icon-radio-icon">${opt.icon}</span>` : null}
110
+ <span>${opt.label}</span>
111
+ </button>`)}
112
+ </div>
113
+ ` : f.type === 'checkbox' ? html`
114
+ <span class="entity-checkbox-row">
115
+ <input type="checkbox" checked=${!!draft[f.key]}
116
+ disabled=${isReadOnly(f)}
117
+ onChange=${(e) => setDraft({ ...draft, [f.key]: e.target.checked })} />
118
+ ${f.hint ? html`<span class="entity-field-hint">${typeof f.hint === 'function' ? f.hint(draft) : f.hint}</span>` : null}
119
+ </span>
120
+ ` : html`
121
+ <input type=${f.type || 'text'}
122
+ class=${`input${f.mono ? ' mono' : ''}`}
123
+ placeholder=${f.placeholder || ''}
124
+ value=${draft[f.key] || ''}
125
+ readonly=${isReadOnly(f)}
126
+ onInput=${(e) => setDraft({ ...draft, [f.key]: e.target.value })}
127
+ autoFocus=${f.autoFocus && !isReadOnly(f)} />`}
128
+ ${f.hint && f.type !== 'checkbox' ? html`
129
+ <span class="entity-field-hint">${typeof f.hint === 'function' ? f.hint(draft) : f.hint}</span>` : null}
130
+ </label>`)}
131
+ ${testResult ? html`
132
+ <div class=${`entity-test-result ${testResult.ok ? 'is-ok' : 'is-fail'}`}>
133
+ <div class="entity-test-summary">
134
+ ${testResult.ok ? '✓' : '✗'} ${testResult.ok ? 'works' : 'failed'}
135
+ ${typeof testResult.exitCode === 'number' ? html` · exit ${testResult.exitCode}` : null}
136
+ ${typeof testResult.durationMs === 'number' ? html` · ${testResult.durationMs}ms` : null}
137
+ ${testResult.timedOut ? html` · timed out` : null}
138
+ ${testResult.matchedType === true ? html` · type matches ${testResult.expectedType}` : null}
139
+ ${testResult.matchedType === false ? html` · type mismatch (expected ${testResult.expectedType})` : null}
140
+ </div>
141
+ ${testResult.spawnError ? html`<pre class="entity-test-out">${testResult.spawnError}</pre>` : null}
142
+ ${testResult.stdout ? html`<pre class="entity-test-out">${testResult.stdout}</pre>` : null}
143
+ ${testResult.stderr ? html`<pre class="entity-test-out is-stderr">${testResult.stderr}</pre>` : null}
144
+ </div>` : null}
145
+ </form>
146
+ </${Modal}>`;
147
+ }
148
+
149
+ function initialFrom(fields) {
150
+ const out = {};
151
+ for (const f of fields) out[f.key] = f.default ?? '';
152
+ return out;
153
+ }
@@ -1,57 +1,57 @@
1
- // Centered modal dialog with backdrop. Closes via Esc, the corner X,
2
- // or a click on the backdrop.
3
- //
4
- // <${Modal} onClose=${close} title="Choose CLI" width=${440}
5
- // footer=${html`<button ...>Cancel</button> ...`}>
6
- // ...body (scrolls)...
7
- // </${Modal}>
8
- //
9
- // When `footer` is given it renders in a fixed .modal-foot below the
10
- // scrollable body — the body grows/scrolls between a pinned head and a
11
- // pinned footer (the .modal is a flex column capped at 90vh).
12
-
13
- import { html } from '../html.js';
14
- import { useEffect, useRef } from 'preact/hooks';
15
- import { createPortal } from 'preact/compat';
16
-
17
- export function Modal({ title, width = 440, onClose, children, footer }) {
18
- const panelRef = useRef(null);
19
-
20
- useEffect(() => {
21
- const onKey = (ev) => { if (ev.key === 'Escape') onClose?.(); };
22
- document.addEventListener('keydown', onKey, true);
23
- const prev = document.body.style.overflow;
24
- document.body.style.overflow = 'hidden';
25
- return () => {
26
- document.removeEventListener('keydown', onKey, true);
27
- document.body.style.overflow = prev;
28
- };
29
- }, [onClose]);
30
-
31
- const onBackdrop = (ev) => {
32
- if (ev.target === ev.currentTarget) onClose?.();
33
- };
34
-
35
- return createPortal(
36
- html`<div class="modal-backdrop" onMouseDown=${onBackdrop}>
37
- <div ref=${panelRef} class="modal modal-picker"
38
- style=${`width:${width}px;max-width:calc(100vw - 32px);`}
39
- role="dialog" aria-modal="true">
40
- ${title ? html`
41
- <div class="modal-head">
42
- <h2>${title}</h2>
43
- <button class="modal-close" type="button"
44
- aria-label="Close" onClick=${onClose}>
45
- <svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
46
- <line x1="3" y1="3" x2="13" y2="13"/>
47
- <line x1="13" y1="3" x2="3" y2="13"/>
48
- </svg>
49
- </button>
50
- </div>` : null}
51
- <div class="modal-body">${children}</div>
52
- ${footer ? html`<div class="modal-foot">${footer}</div>` : null}
53
- </div>
54
- </div>`,
55
- document.body
56
- );
57
- }
1
+ // Centered modal dialog with backdrop. Closes via Esc, the corner X,
2
+ // or a click on the backdrop.
3
+ //
4
+ // <${Modal} onClose=${close} title="Choose CLI" width=${440}
5
+ // footer=${html`<button ...>Cancel</button> ...`}>
6
+ // ...body (scrolls)...
7
+ // </${Modal}>
8
+ //
9
+ // When `footer` is given it renders in a fixed .modal-foot below the
10
+ // scrollable body — the body grows/scrolls between a pinned head and a
11
+ // pinned footer (the .modal is a flex column capped at 90vh).
12
+
13
+ import { html } from '../html.js';
14
+ import { useEffect, useRef } from 'preact/hooks';
15
+ import { createPortal } from 'preact/compat';
16
+
17
+ export function Modal({ title, width = 440, onClose, children, footer }) {
18
+ const panelRef = useRef(null);
19
+
20
+ useEffect(() => {
21
+ const onKey = (ev) => { if (ev.key === 'Escape') onClose?.(); };
22
+ document.addEventListener('keydown', onKey, true);
23
+ const prev = document.body.style.overflow;
24
+ document.body.style.overflow = 'hidden';
25
+ return () => {
26
+ document.removeEventListener('keydown', onKey, true);
27
+ document.body.style.overflow = prev;
28
+ };
29
+ }, [onClose]);
30
+
31
+ const onBackdrop = (ev) => {
32
+ if (ev.target === ev.currentTarget) onClose?.();
33
+ };
34
+
35
+ return createPortal(
36
+ html`<div class="modal-backdrop" onMouseDown=${onBackdrop}>
37
+ <div ref=${panelRef} class="modal modal-picker"
38
+ style=${`width:${width}px;max-width:calc(100vw - 32px);`}
39
+ role="dialog" aria-modal="true">
40
+ ${title ? html`
41
+ <div class="modal-head">
42
+ <h2>${title}</h2>
43
+ <button class="modal-close" type="button"
44
+ aria-label="Close" onClick=${onClose}>
45
+ <svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
46
+ <line x1="3" y1="3" x2="13" y2="13"/>
47
+ <line x1="13" y1="3" x2="3" y2="13"/>
48
+ </svg>
49
+ </button>
50
+ </div>` : null}
51
+ <div class="modal-body">${children}</div>
52
+ ${footer ? html`<div class="modal-foot">${footer}</div>` : null}
53
+ </div>
54
+ </div>`,
55
+ document.body
56
+ );
57
+ }
@@ -1,67 +1,67 @@
1
- // Fullscreen overlay shown when the backend is offline. Blocks
2
- // interaction with the rest of the UI until backend comes back.
3
- //
4
- // The hosted frontend (https://bakapiano.github.io/ccsm/v1/) can't
5
- // spawn processes directly, so we surface a ccsm://start link instead.
6
- // Windows hands that off to the registered protocol handler
7
- // (ccsm.cmd), which spawns the backend silently. Our health probe
8
- // picks it up on the next tick and the overlay auto-hides.
9
- //
10
- // First click triggers a Windows confirmation dialog ("Open ccsm.cmd?").
11
- // User can check "Always allow" to suppress future prompts.
12
-
13
- import { html } from '../html.js';
14
- import { useEffect, useState } from 'preact/hooks';
15
- import { serverHealth } from '../state.js';
16
- import { refreshAll } from '../api.js';
17
- import { BrandMark } from '../icons.js';
18
-
19
- export function OfflineBanner() {
20
- const h = serverHealth.value;
21
- const offline = h.state === 'offline';
22
- const [clicked, setClicked] = useState(false);
23
-
24
- // We used to silently fire ccsm://start via a hidden iframe the
25
- // moment the backend went offline. Even when the user had OK'd
26
- // "Always allow" once, some browsers still flashed a momentary
27
- // confirmation prompt — and first-time visitors got a "Open
28
- // ccsm.cmd?" dialog with no apparent trigger, which is a bad UX.
29
- // The Start button below is the only path that fires the protocol
30
- // now; the health poll picks the backend up automatically once
31
- // the user clicks it (or starts ccsm from a terminal / shortcut).
32
-
33
- useEffect(() => {
34
- if (h.state === 'online' && clicked) {
35
- refreshAll().catch(() => {});
36
- setClicked(false);
37
- }
38
- }, [h.state, clicked]);
39
-
40
- if (!offline) return null;
41
-
42
- return html`
43
- <div class="offline-overlay" role="dialog" aria-modal="true" aria-labelledby="offline-title">
44
- <div class="offline-card">
45
- <div class="offline-brand"><${BrandMark} /></div>
46
- <h1 id="offline-title" class="offline-title">Backend not running</h1>
47
- <p class="offline-copy">
48
- ccsm's local backend isn't reachable. Click Start to launch it —
49
- Windows may ask for permission once. Tick <em>Always allow</em>
50
- to silence future prompts.
51
- </p>
52
- <div class="offline-actions">
53
- <a class="action primary big" href="ccsm://start"
54
- onClick=${() => setClicked(true)}>Start ccsm</a>
55
- </div>
56
- <details class="offline-fallback">
57
- <summary>Don't have ccsm installed?</summary>
58
- <div class="offline-fallback-body">
59
- <p>Install once via npm, then come back here:</p>
60
- <pre><code>npm i -g @bakapiano/ccsm</code></pre>
61
- <p>Or run a one-shot trial without installing:</p>
62
- <pre><code>npx @bakapiano/ccsm</code></pre>
63
- </div>
64
- </details>
65
- </div>
66
- </div>`;
67
- }
1
+ // Fullscreen overlay shown when the backend is offline. Blocks
2
+ // interaction with the rest of the UI until backend comes back.
3
+ //
4
+ // The hosted frontend (https://bakapiano.github.io/ccsm/v1/) can't
5
+ // spawn processes directly, so we surface a ccsm://start link instead.
6
+ // Windows hands that off to the registered protocol handler
7
+ // (ccsm.cmd), which spawns the backend silently. Our health probe
8
+ // picks it up on the next tick and the overlay auto-hides.
9
+ //
10
+ // First click triggers a Windows confirmation dialog ("Open ccsm.cmd?").
11
+ // User can check "Always allow" to suppress future prompts.
12
+
13
+ import { html } from '../html.js';
14
+ import { useEffect, useState } from 'preact/hooks';
15
+ import { serverHealth } from '../state.js';
16
+ import { refreshAll } from '../api.js';
17
+ import { BrandMark } from '../icons.js';
18
+
19
+ export function OfflineBanner() {
20
+ const h = serverHealth.value;
21
+ const offline = h.state === 'offline';
22
+ const [clicked, setClicked] = useState(false);
23
+
24
+ // We used to silently fire ccsm://start via a hidden iframe the
25
+ // moment the backend went offline. Even when the user had OK'd
26
+ // "Always allow" once, some browsers still flashed a momentary
27
+ // confirmation prompt — and first-time visitors got a "Open
28
+ // ccsm.cmd?" dialog with no apparent trigger, which is a bad UX.
29
+ // The Start button below is the only path that fires the protocol
30
+ // now; the health poll picks the backend up automatically once
31
+ // the user clicks it (or starts ccsm from a terminal / shortcut).
32
+
33
+ useEffect(() => {
34
+ if (h.state === 'online' && clicked) {
35
+ refreshAll().catch(() => {});
36
+ setClicked(false);
37
+ }
38
+ }, [h.state, clicked]);
39
+
40
+ if (!offline) return null;
41
+
42
+ return html`
43
+ <div class="offline-overlay" role="dialog" aria-modal="true" aria-labelledby="offline-title">
44
+ <div class="offline-card">
45
+ <div class="offline-brand"><${BrandMark} /></div>
46
+ <h1 id="offline-title" class="offline-title">Backend not running</h1>
47
+ <p class="offline-copy">
48
+ ccsm's local backend isn't reachable. Click Start to launch it —
49
+ Windows may ask for permission once. Tick <em>Always allow</em>
50
+ to silence future prompts.
51
+ </p>
52
+ <div class="offline-actions">
53
+ <a class="action primary big" href="ccsm://start"
54
+ onClick=${() => setClicked(true)}>Start ccsm</a>
55
+ </div>
56
+ <details class="offline-fallback">
57
+ <summary>Don't have ccsm installed?</summary>
58
+ <div class="offline-fallback-body">
59
+ <p>Install once via npm, then come back here:</p>
60
+ <pre><code>npm i -g @bakapiano/ccsm</code></pre>
61
+ <p>Or run a one-shot trial without installing:</p>
62
+ <pre><code>npx @bakapiano/ccsm</code></pre>
63
+ </div>
64
+ </details>
65
+ </div>
66
+ </div>`;
67
+ }
@@ -1,13 +1,13 @@
1
- // Thin page-title strip rendered at the top of every page's main panel.
2
- // Matches the sidebar collapse-toggle height so the eye sees a single
3
- // 28px-tall row spanning the top of the whole window.
4
-
5
- import { html } from '../html.js';
6
-
7
- export function PageTitleBar({ title, children }) {
8
- return html`
9
- <header class="page-title-bar">
10
- <div class="page-title-bar-title">${title}</div>
11
- ${children ? html`<div class="page-title-bar-actions">${children}</div>` : null}
12
- </header>`;
13
- }
1
+ // Thin page-title strip rendered at the top of every page's main panel.
2
+ // Matches the sidebar collapse-toggle height so the eye sees a single
3
+ // 28px-tall row spanning the top of the whole window.
4
+
5
+ import { html } from '../html.js';
6
+
7
+ export function PageTitleBar({ title, children }) {
8
+ return html`
9
+ <header class="page-title-bar">
10
+ <div class="page-title-bar-title">${title}</div>
11
+ ${children ? html`<div class="page-title-bar-actions">${children}</div>` : null}
12
+ </header>`;
13
+ }