@bakapiano/ccsm 0.13.0 → 0.15.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.
- package/CLAUDE.md +474 -475
- package/README.md +189 -190
- package/bin/ccsm.js +194 -194
- package/lib/cliActivity.js +118 -0
- package/lib/codexSeed.js +147 -0
- package/lib/config.js +211 -188
- package/lib/folders.js +105 -105
- package/lib/localCliSessions.js +489 -489
- package/lib/persistedSessions.js +144 -142
- package/lib/webTerminal.js +224 -224
- package/lib/workspace.js +230 -230
- package/package.json +57 -57
- package/public/css/base.css +99 -99
- package/public/css/cards.css +183 -183
- package/public/css/feedback.css +303 -303
- package/public/css/forms.css +405 -405
- package/public/css/layout.css +160 -160
- package/public/css/modal.css +190 -190
- package/public/css/responsive.css +10 -10
- package/public/css/sidebar.css +613 -608
- package/public/css/terminals.css +294 -294
- package/public/css/tokens.css +81 -81
- package/public/css/wco.css +98 -98
- package/public/css/widgets.css +1628 -1628
- package/public/index.html +111 -105
- package/public/js/api.js +296 -280
- package/public/js/components/AdoptModal.js +343 -343
- package/public/js/components/App.js +35 -35
- package/public/js/components/DirectoryPicker.js +203 -203
- package/public/js/components/EntityFormModal.js +141 -141
- package/public/js/components/Modal.js +51 -51
- package/public/js/components/OfflineBanner.js +93 -93
- package/public/js/components/PageTitleBar.js +13 -13
- package/public/js/components/Picker.js +179 -179
- package/public/js/components/Popover.js +55 -55
- package/public/js/components/Sidebar.js +299 -299
- package/public/js/components/TerminalView.js +314 -314
- package/public/js/components/useDragSort.js +67 -67
- package/public/js/dialog.js +67 -67
- package/public/js/icons.js +177 -177
- package/public/js/main.js +132 -132
- package/public/js/pages/AboutPage.js +165 -165
- package/public/js/pages/ConfigurePage.js +505 -475
- package/public/js/pages/LaunchPage.js +369 -369
- package/public/js/pages/SessionsPage.js +101 -97
- package/public/js/state.js +231 -231
- package/scripts/dev.js +44 -11
- package/scripts/install.js +158 -137
- package/scripts/restart-helper.js +91 -0
- package/scripts/upgrade-helper.js +155 -0
- package/server.js +1278 -1232
- package/lib/cliSessionWatcher.js +0 -249
- package/public/manifest.webmanifest +0 -15
|
@@ -1,141 +1,141 @@
|
|
|
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
|
-
const isReadOnly = (key) => readOnlyKeys.includes(key);
|
|
30
|
-
|
|
31
|
-
const submit = async (ev) => {
|
|
32
|
-
ev?.preventDefault?.();
|
|
33
|
-
for (const f of fields) {
|
|
34
|
-
if (f.required && !String(draft[f.key] || '').trim()) return;
|
|
35
|
-
}
|
|
36
|
-
setSaving(true);
|
|
37
|
-
try { await onSubmit?.(draft); onClose?.(); }
|
|
38
|
-
catch { /* caller toasts; stay open */ }
|
|
39
|
-
finally { setSaving(false); }
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const runTest = async () => {
|
|
43
|
-
if (!onTest) return;
|
|
44
|
-
setTesting(true);
|
|
45
|
-
setTestResult(null);
|
|
46
|
-
try {
|
|
47
|
-
const r = await onTest(draft);
|
|
48
|
-
setTestResult(r);
|
|
49
|
-
} catch (e) {
|
|
50
|
-
setTestResult({ ok: false, spawnError: String(e?.message || e) });
|
|
51
|
-
} finally {
|
|
52
|
-
setTesting(false);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
return html`
|
|
57
|
-
<${Modal} title=${title} onClose=${onClose} width=${440}>
|
|
58
|
-
<form class="entity-form" onSubmit=${submit}>
|
|
59
|
-
${fields.map((f) => html`
|
|
60
|
-
<label class="entity-field" key=${f.key}>
|
|
61
|
-
<span class="entity-field-label">${f.label}</span>
|
|
62
|
-
${f.type === 'select' ? html`
|
|
63
|
-
<select class="input" value=${draft[f.key] || ''}
|
|
64
|
-
disabled=${isReadOnly(f.key)}
|
|
65
|
-
onChange=${(e) => {
|
|
66
|
-
const next = { ...draft, [f.key]: e.target.value };
|
|
67
|
-
const sideEffects = f.onChange?.(e.target.value, next);
|
|
68
|
-
setDraft(sideEffects ? { ...next, ...sideEffects } : next);
|
|
69
|
-
}}>
|
|
70
|
-
${(f.options || []).map((opt) => html`
|
|
71
|
-
<option value=${opt.value}>${opt.label}</option>`)}
|
|
72
|
-
</select>
|
|
73
|
-
` : f.type === 'iconRadio' ? html`
|
|
74
|
-
<div class=${`icon-radio${isReadOnly(f.key) ? ' is-disabled' : ''}`}>
|
|
75
|
-
${(f.options || []).map((opt) => html`
|
|
76
|
-
<button type="button" key=${opt.value}
|
|
77
|
-
class=${`icon-radio-opt${draft[f.key] === opt.value ? ' is-active' : ''}`}
|
|
78
|
-
disabled=${isReadOnly(f.key)}
|
|
79
|
-
onClick=${() => {
|
|
80
|
-
if (isReadOnly(f.key)) return;
|
|
81
|
-
const next = { ...draft, [f.key]: opt.value };
|
|
82
|
-
const sideEffects = f.onChange?.(opt.value, next);
|
|
83
|
-
setDraft(sideEffects ? { ...next, ...sideEffects } : next);
|
|
84
|
-
}}>
|
|
85
|
-
${opt.icon ? html`<span class="icon-radio-icon">${opt.icon}</span>` : null}
|
|
86
|
-
<span>${opt.label}</span>
|
|
87
|
-
</button>`)}
|
|
88
|
-
</div>
|
|
89
|
-
` : f.type === 'checkbox' ? html`
|
|
90
|
-
<span class="entity-checkbox-row">
|
|
91
|
-
<input type="checkbox" checked=${!!draft[f.key]}
|
|
92
|
-
disabled=${isReadOnly(f.key)}
|
|
93
|
-
onChange=${(e) => setDraft({ ...draft, [f.key]: e.target.checked })} />
|
|
94
|
-
${f.hint ? html`<span class="entity-field-hint">${f.hint}</span>` : null}
|
|
95
|
-
</span>
|
|
96
|
-
` : html`
|
|
97
|
-
<input type=${f.type || 'text'}
|
|
98
|
-
class=${`input${f.mono ? ' mono' : ''}`}
|
|
99
|
-
placeholder=${f.placeholder || ''}
|
|
100
|
-
value=${draft[f.key] || ''}
|
|
101
|
-
readonly=${isReadOnly(f.key)}
|
|
102
|
-
onInput=${(e) => setDraft({ ...draft, [f.key]: e.target.value })}
|
|
103
|
-
autoFocus=${f.autoFocus && !isReadOnly(f.key)} />`}
|
|
104
|
-
${f.hint && f.type !== 'checkbox' ? html`
|
|
105
|
-
<span class="entity-field-hint">${f.hint}</span>` : null}
|
|
106
|
-
</label>`)}
|
|
107
|
-
${testResult ? html`
|
|
108
|
-
<div class=${`entity-test-result ${testResult.ok ? 'is-ok' : 'is-fail'}`}>
|
|
109
|
-
<div class="entity-test-summary">
|
|
110
|
-
${testResult.ok ? '✓' : '✗'} ${testResult.ok ? 'works' : 'failed'}
|
|
111
|
-
${typeof testResult.exitCode === 'number' ? html` · exit ${testResult.exitCode}` : null}
|
|
112
|
-
${typeof testResult.durationMs === 'number' ? html` · ${testResult.durationMs}ms` : null}
|
|
113
|
-
${testResult.timedOut ? html` · timed out` : null}
|
|
114
|
-
${testResult.matchedType === true ? html` · type matches ${testResult.expectedType}` : null}
|
|
115
|
-
${testResult.matchedType === false ? html` · type mismatch (expected ${testResult.expectedType})` : null}
|
|
116
|
-
</div>
|
|
117
|
-
${testResult.spawnError ? html`<pre class="entity-test-out">${testResult.spawnError}</pre>` : null}
|
|
118
|
-
${testResult.stdout ? html`<pre class="entity-test-out">${testResult.stdout}</pre>` : null}
|
|
119
|
-
${testResult.stderr ? html`<pre class="entity-test-out is-stderr">${testResult.stderr}</pre>` : null}
|
|
120
|
-
</div>` : null}
|
|
121
|
-
<div class="entity-form-actions">
|
|
122
|
-
${onTest ? html`
|
|
123
|
-
<button type="button" class="action small subtle entity-test-button"
|
|
124
|
-
disabled=${testing} onClick=${runTest}>
|
|
125
|
-
${testing ? 'Testing…' : testLabel}
|
|
126
|
-
</button>` : null}
|
|
127
|
-
<button type="button" class="action small subtle" onClick=${onClose}>Cancel</button>
|
|
128
|
-
<button type="submit" class=${`action small ${danger ? 'danger' : 'primary'}`}
|
|
129
|
-
disabled=${saving}>
|
|
130
|
-
${saving ? 'Saving…' : submitLabel}
|
|
131
|
-
</button>
|
|
132
|
-
</div>
|
|
133
|
-
</form>
|
|
134
|
-
</${Modal}>`;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function initialFrom(fields) {
|
|
138
|
-
const out = {};
|
|
139
|
-
for (const f of fields) out[f.key] = f.default ?? '';
|
|
140
|
-
return out;
|
|
141
|
-
}
|
|
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
|
+
const isReadOnly = (key) => readOnlyKeys.includes(key);
|
|
30
|
+
|
|
31
|
+
const submit = async (ev) => {
|
|
32
|
+
ev?.preventDefault?.();
|
|
33
|
+
for (const f of fields) {
|
|
34
|
+
if (f.required && !String(draft[f.key] || '').trim()) return;
|
|
35
|
+
}
|
|
36
|
+
setSaving(true);
|
|
37
|
+
try { await onSubmit?.(draft); onClose?.(); }
|
|
38
|
+
catch { /* caller toasts; stay open */ }
|
|
39
|
+
finally { setSaving(false); }
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const runTest = async () => {
|
|
43
|
+
if (!onTest) return;
|
|
44
|
+
setTesting(true);
|
|
45
|
+
setTestResult(null);
|
|
46
|
+
try {
|
|
47
|
+
const r = await onTest(draft);
|
|
48
|
+
setTestResult(r);
|
|
49
|
+
} catch (e) {
|
|
50
|
+
setTestResult({ ok: false, spawnError: String(e?.message || e) });
|
|
51
|
+
} finally {
|
|
52
|
+
setTesting(false);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return html`
|
|
57
|
+
<${Modal} title=${title} onClose=${onClose} width=${440}>
|
|
58
|
+
<form class="entity-form" onSubmit=${submit}>
|
|
59
|
+
${fields.map((f) => html`
|
|
60
|
+
<label class="entity-field" key=${f.key}>
|
|
61
|
+
<span class="entity-field-label">${f.label}</span>
|
|
62
|
+
${f.type === 'select' ? html`
|
|
63
|
+
<select class="input" value=${draft[f.key] || ''}
|
|
64
|
+
disabled=${isReadOnly(f.key)}
|
|
65
|
+
onChange=${(e) => {
|
|
66
|
+
const next = { ...draft, [f.key]: e.target.value };
|
|
67
|
+
const sideEffects = f.onChange?.(e.target.value, next);
|
|
68
|
+
setDraft(sideEffects ? { ...next, ...sideEffects } : next);
|
|
69
|
+
}}>
|
|
70
|
+
${(f.options || []).map((opt) => html`
|
|
71
|
+
<option value=${opt.value}>${opt.label}</option>`)}
|
|
72
|
+
</select>
|
|
73
|
+
` : f.type === 'iconRadio' ? html`
|
|
74
|
+
<div class=${`icon-radio${isReadOnly(f.key) ? ' is-disabled' : ''}`}>
|
|
75
|
+
${(f.options || []).map((opt) => html`
|
|
76
|
+
<button type="button" key=${opt.value}
|
|
77
|
+
class=${`icon-radio-opt${draft[f.key] === opt.value ? ' is-active' : ''}`}
|
|
78
|
+
disabled=${isReadOnly(f.key)}
|
|
79
|
+
onClick=${() => {
|
|
80
|
+
if (isReadOnly(f.key)) return;
|
|
81
|
+
const next = { ...draft, [f.key]: opt.value };
|
|
82
|
+
const sideEffects = f.onChange?.(opt.value, next);
|
|
83
|
+
setDraft(sideEffects ? { ...next, ...sideEffects } : next);
|
|
84
|
+
}}>
|
|
85
|
+
${opt.icon ? html`<span class="icon-radio-icon">${opt.icon}</span>` : null}
|
|
86
|
+
<span>${opt.label}</span>
|
|
87
|
+
</button>`)}
|
|
88
|
+
</div>
|
|
89
|
+
` : f.type === 'checkbox' ? html`
|
|
90
|
+
<span class="entity-checkbox-row">
|
|
91
|
+
<input type="checkbox" checked=${!!draft[f.key]}
|
|
92
|
+
disabled=${isReadOnly(f.key)}
|
|
93
|
+
onChange=${(e) => setDraft({ ...draft, [f.key]: e.target.checked })} />
|
|
94
|
+
${f.hint ? html`<span class="entity-field-hint">${f.hint}</span>` : null}
|
|
95
|
+
</span>
|
|
96
|
+
` : html`
|
|
97
|
+
<input type=${f.type || 'text'}
|
|
98
|
+
class=${`input${f.mono ? ' mono' : ''}`}
|
|
99
|
+
placeholder=${f.placeholder || ''}
|
|
100
|
+
value=${draft[f.key] || ''}
|
|
101
|
+
readonly=${isReadOnly(f.key)}
|
|
102
|
+
onInput=${(e) => setDraft({ ...draft, [f.key]: e.target.value })}
|
|
103
|
+
autoFocus=${f.autoFocus && !isReadOnly(f.key)} />`}
|
|
104
|
+
${f.hint && f.type !== 'checkbox' ? html`
|
|
105
|
+
<span class="entity-field-hint">${f.hint}</span>` : null}
|
|
106
|
+
</label>`)}
|
|
107
|
+
${testResult ? html`
|
|
108
|
+
<div class=${`entity-test-result ${testResult.ok ? 'is-ok' : 'is-fail'}`}>
|
|
109
|
+
<div class="entity-test-summary">
|
|
110
|
+
${testResult.ok ? '✓' : '✗'} ${testResult.ok ? 'works' : 'failed'}
|
|
111
|
+
${typeof testResult.exitCode === 'number' ? html` · exit ${testResult.exitCode}` : null}
|
|
112
|
+
${typeof testResult.durationMs === 'number' ? html` · ${testResult.durationMs}ms` : null}
|
|
113
|
+
${testResult.timedOut ? html` · timed out` : null}
|
|
114
|
+
${testResult.matchedType === true ? html` · type matches ${testResult.expectedType}` : null}
|
|
115
|
+
${testResult.matchedType === false ? html` · type mismatch (expected ${testResult.expectedType})` : null}
|
|
116
|
+
</div>
|
|
117
|
+
${testResult.spawnError ? html`<pre class="entity-test-out">${testResult.spawnError}</pre>` : null}
|
|
118
|
+
${testResult.stdout ? html`<pre class="entity-test-out">${testResult.stdout}</pre>` : null}
|
|
119
|
+
${testResult.stderr ? html`<pre class="entity-test-out is-stderr">${testResult.stderr}</pre>` : null}
|
|
120
|
+
</div>` : null}
|
|
121
|
+
<div class="entity-form-actions">
|
|
122
|
+
${onTest ? html`
|
|
123
|
+
<button type="button" class="action small subtle entity-test-button"
|
|
124
|
+
disabled=${testing} onClick=${runTest}>
|
|
125
|
+
${testing ? 'Testing…' : testLabel}
|
|
126
|
+
</button>` : null}
|
|
127
|
+
<button type="button" class="action small subtle" onClick=${onClose}>Cancel</button>
|
|
128
|
+
<button type="submit" class=${`action small ${danger ? 'danger' : 'primary'}`}
|
|
129
|
+
disabled=${saving}>
|
|
130
|
+
${saving ? 'Saving…' : submitLabel}
|
|
131
|
+
</button>
|
|
132
|
+
</div>
|
|
133
|
+
</form>
|
|
134
|
+
</${Modal}>`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function initialFrom(fields) {
|
|
138
|
+
const out = {};
|
|
139
|
+
for (const f of fields) out[f.key] = f.default ?? '';
|
|
140
|
+
return out;
|
|
141
|
+
}
|
|
@@ -1,51 +1,51 @@
|
|
|
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
|
-
// ...body...
|
|
6
|
-
// </${Modal}>
|
|
7
|
-
|
|
8
|
-
import { html } from '../html.js';
|
|
9
|
-
import { useEffect, useRef } from 'preact/hooks';
|
|
10
|
-
import { createPortal } from 'preact/compat';
|
|
11
|
-
|
|
12
|
-
export function Modal({ title, width = 440, onClose, children }) {
|
|
13
|
-
const panelRef = useRef(null);
|
|
14
|
-
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
const onKey = (ev) => { if (ev.key === 'Escape') onClose?.(); };
|
|
17
|
-
document.addEventListener('keydown', onKey, true);
|
|
18
|
-
const prev = document.body.style.overflow;
|
|
19
|
-
document.body.style.overflow = 'hidden';
|
|
20
|
-
return () => {
|
|
21
|
-
document.removeEventListener('keydown', onKey, true);
|
|
22
|
-
document.body.style.overflow = prev;
|
|
23
|
-
};
|
|
24
|
-
}, [onClose]);
|
|
25
|
-
|
|
26
|
-
const onBackdrop = (ev) => {
|
|
27
|
-
if (ev.target === ev.currentTarget) onClose?.();
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
return createPortal(
|
|
31
|
-
html`<div class="modal-backdrop" onMouseDown=${onBackdrop}>
|
|
32
|
-
<div ref=${panelRef} class="modal modal-picker"
|
|
33
|
-
style=${`width:${width}px;max-width:calc(100vw - 32px);`}
|
|
34
|
-
role="dialog" aria-modal="true">
|
|
35
|
-
${title ? html`
|
|
36
|
-
<div class="modal-head">
|
|
37
|
-
<h2>${title}</h2>
|
|
38
|
-
<button class="modal-close" type="button"
|
|
39
|
-
aria-label="Close" onClick=${onClose}>
|
|
40
|
-
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
41
|
-
<line x1="3" y1="3" x2="13" y2="13"/>
|
|
42
|
-
<line x1="13" y1="3" x2="3" y2="13"/>
|
|
43
|
-
</svg>
|
|
44
|
-
</button>
|
|
45
|
-
</div>` : null}
|
|
46
|
-
<div class="modal-body">${children}</div>
|
|
47
|
-
</div>
|
|
48
|
-
</div>`,
|
|
49
|
-
document.body
|
|
50
|
-
);
|
|
51
|
-
}
|
|
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
|
+
// ...body...
|
|
6
|
+
// </${Modal}>
|
|
7
|
+
|
|
8
|
+
import { html } from '../html.js';
|
|
9
|
+
import { useEffect, useRef } from 'preact/hooks';
|
|
10
|
+
import { createPortal } from 'preact/compat';
|
|
11
|
+
|
|
12
|
+
export function Modal({ title, width = 440, onClose, children }) {
|
|
13
|
+
const panelRef = useRef(null);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const onKey = (ev) => { if (ev.key === 'Escape') onClose?.(); };
|
|
17
|
+
document.addEventListener('keydown', onKey, true);
|
|
18
|
+
const prev = document.body.style.overflow;
|
|
19
|
+
document.body.style.overflow = 'hidden';
|
|
20
|
+
return () => {
|
|
21
|
+
document.removeEventListener('keydown', onKey, true);
|
|
22
|
+
document.body.style.overflow = prev;
|
|
23
|
+
};
|
|
24
|
+
}, [onClose]);
|
|
25
|
+
|
|
26
|
+
const onBackdrop = (ev) => {
|
|
27
|
+
if (ev.target === ev.currentTarget) onClose?.();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return createPortal(
|
|
31
|
+
html`<div class="modal-backdrop" onMouseDown=${onBackdrop}>
|
|
32
|
+
<div ref=${panelRef} class="modal modal-picker"
|
|
33
|
+
style=${`width:${width}px;max-width:calc(100vw - 32px);`}
|
|
34
|
+
role="dialog" aria-modal="true">
|
|
35
|
+
${title ? html`
|
|
36
|
+
<div class="modal-head">
|
|
37
|
+
<h2>${title}</h2>
|
|
38
|
+
<button class="modal-close" type="button"
|
|
39
|
+
aria-label="Close" onClick=${onClose}>
|
|
40
|
+
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round">
|
|
41
|
+
<line x1="3" y1="3" x2="13" y2="13"/>
|
|
42
|
+
<line x1="13" y1="3" x2="3" y2="13"/>
|
|
43
|
+
</svg>
|
|
44
|
+
</button>
|
|
45
|
+
</div>` : null}
|
|
46
|
+
<div class="modal-body">${children}</div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>`,
|
|
49
|
+
document.body
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -1,93 +1,93 @@
|
|
|
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, pollHealth } from '../api.js';
|
|
17
|
-
import { BrandMark } from '../icons.js';
|
|
18
|
-
|
|
19
|
-
// Silent ccsm:// launch via hidden iframe. Same trick as the router.
|
|
20
|
-
// If the protocol is registered AND the user has already OK'd the
|
|
21
|
-
// Windows confirmation prompt, ccsm wakes up within ~2s and the
|
|
22
|
-
// banner auto-dismisses on the next health poll. On a cold first
|
|
23
|
-
// visit (protocol not registered, or "Always allow" not yet ticked),
|
|
24
|
-
// the iframe noops silently and the manual "Start ccsm" button is
|
|
25
|
-
// still there as fallback.
|
|
26
|
-
function silentProtocolLaunch() {
|
|
27
|
-
try {
|
|
28
|
-
const f = document.createElement('iframe');
|
|
29
|
-
f.style.display = 'none';
|
|
30
|
-
f.src = 'ccsm://start';
|
|
31
|
-
document.body.appendChild(f);
|
|
32
|
-
setTimeout(() => { try { f.remove(); } catch {} }, 1500);
|
|
33
|
-
} catch {}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function OfflineBanner() {
|
|
37
|
-
const h = serverHealth.value;
|
|
38
|
-
const offline = h.state === 'offline';
|
|
39
|
-
const [clicked, setClicked] = useState(false);
|
|
40
|
-
const [autoTried, setAutoTried] = useState(false);
|
|
41
|
-
|
|
42
|
-
// First time we see offline state, try a silent ccsm:// launch and
|
|
43
|
-
// tighten the health-poll cadence for a few seconds so the redirect
|
|
44
|
-
// happens within ~2-3s without any visible UI flash.
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (!offline || autoTried) return;
|
|
47
|
-
setAutoTried(true);
|
|
48
|
-
silentProtocolLaunch();
|
|
49
|
-
let n = 0;
|
|
50
|
-
const tick = async () => {
|
|
51
|
-
if (n++ > 12) return; // ~6s of tight polling
|
|
52
|
-
await pollHealth();
|
|
53
|
-
if (serverHealth.value.state === 'online') return;
|
|
54
|
-
setTimeout(tick, 500);
|
|
55
|
-
};
|
|
56
|
-
setTimeout(tick, 500);
|
|
57
|
-
}, [offline]);
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
if (h.state === 'online' && clicked) {
|
|
61
|
-
refreshAll().catch(() => {});
|
|
62
|
-
setClicked(false);
|
|
63
|
-
}
|
|
64
|
-
}, [h.state, clicked]);
|
|
65
|
-
|
|
66
|
-
if (!offline) return null;
|
|
67
|
-
|
|
68
|
-
return html`
|
|
69
|
-
<div class="offline-overlay" role="dialog" aria-modal="true" aria-labelledby="offline-title">
|
|
70
|
-
<div class="offline-card">
|
|
71
|
-
<div class="offline-brand"><${BrandMark} /></div>
|
|
72
|
-
<h1 id="offline-title" class="offline-title">Backend not running</h1>
|
|
73
|
-
<p class="offline-copy">
|
|
74
|
-
ccsm's local backend isn't reachable. Click Start to launch it —
|
|
75
|
-
Windows may ask for permission once. Tick <em>Always allow</em>
|
|
76
|
-
to silence future prompts.
|
|
77
|
-
</p>
|
|
78
|
-
<div class="offline-actions">
|
|
79
|
-
<a class="action primary big" href="ccsm://start"
|
|
80
|
-
onClick=${() => setClicked(true)}>Start ccsm</a>
|
|
81
|
-
</div>
|
|
82
|
-
<details class="offline-fallback">
|
|
83
|
-
<summary>Don't have ccsm installed?</summary>
|
|
84
|
-
<div class="offline-fallback-body">
|
|
85
|
-
<p>Install once via npm, then come back here:</p>
|
|
86
|
-
<pre><code>npm i -g @bakapiano/ccsm</code></pre>
|
|
87
|
-
<p>Or run a one-shot trial without installing:</p>
|
|
88
|
-
<pre><code>npx @bakapiano/ccsm</code></pre>
|
|
89
|
-
</div>
|
|
90
|
-
</details>
|
|
91
|
-
</div>
|
|
92
|
-
</div>`;
|
|
93
|
-
}
|
|
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, pollHealth } from '../api.js';
|
|
17
|
+
import { BrandMark } from '../icons.js';
|
|
18
|
+
|
|
19
|
+
// Silent ccsm:// launch via hidden iframe. Same trick as the router.
|
|
20
|
+
// If the protocol is registered AND the user has already OK'd the
|
|
21
|
+
// Windows confirmation prompt, ccsm wakes up within ~2s and the
|
|
22
|
+
// banner auto-dismisses on the next health poll. On a cold first
|
|
23
|
+
// visit (protocol not registered, or "Always allow" not yet ticked),
|
|
24
|
+
// the iframe noops silently and the manual "Start ccsm" button is
|
|
25
|
+
// still there as fallback.
|
|
26
|
+
function silentProtocolLaunch() {
|
|
27
|
+
try {
|
|
28
|
+
const f = document.createElement('iframe');
|
|
29
|
+
f.style.display = 'none';
|
|
30
|
+
f.src = 'ccsm://start';
|
|
31
|
+
document.body.appendChild(f);
|
|
32
|
+
setTimeout(() => { try { f.remove(); } catch {} }, 1500);
|
|
33
|
+
} catch {}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function OfflineBanner() {
|
|
37
|
+
const h = serverHealth.value;
|
|
38
|
+
const offline = h.state === 'offline';
|
|
39
|
+
const [clicked, setClicked] = useState(false);
|
|
40
|
+
const [autoTried, setAutoTried] = useState(false);
|
|
41
|
+
|
|
42
|
+
// First time we see offline state, try a silent ccsm:// launch and
|
|
43
|
+
// tighten the health-poll cadence for a few seconds so the redirect
|
|
44
|
+
// happens within ~2-3s without any visible UI flash.
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!offline || autoTried) return;
|
|
47
|
+
setAutoTried(true);
|
|
48
|
+
silentProtocolLaunch();
|
|
49
|
+
let n = 0;
|
|
50
|
+
const tick = async () => {
|
|
51
|
+
if (n++ > 12) return; // ~6s of tight polling
|
|
52
|
+
await pollHealth();
|
|
53
|
+
if (serverHealth.value.state === 'online') return;
|
|
54
|
+
setTimeout(tick, 500);
|
|
55
|
+
};
|
|
56
|
+
setTimeout(tick, 500);
|
|
57
|
+
}, [offline]);
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (h.state === 'online' && clicked) {
|
|
61
|
+
refreshAll().catch(() => {});
|
|
62
|
+
setClicked(false);
|
|
63
|
+
}
|
|
64
|
+
}, [h.state, clicked]);
|
|
65
|
+
|
|
66
|
+
if (!offline) return null;
|
|
67
|
+
|
|
68
|
+
return html`
|
|
69
|
+
<div class="offline-overlay" role="dialog" aria-modal="true" aria-labelledby="offline-title">
|
|
70
|
+
<div class="offline-card">
|
|
71
|
+
<div class="offline-brand"><${BrandMark} /></div>
|
|
72
|
+
<h1 id="offline-title" class="offline-title">Backend not running</h1>
|
|
73
|
+
<p class="offline-copy">
|
|
74
|
+
ccsm's local backend isn't reachable. Click Start to launch it —
|
|
75
|
+
Windows may ask for permission once. Tick <em>Always allow</em>
|
|
76
|
+
to silence future prompts.
|
|
77
|
+
</p>
|
|
78
|
+
<div class="offline-actions">
|
|
79
|
+
<a class="action primary big" href="ccsm://start"
|
|
80
|
+
onClick=${() => setClicked(true)}>Start ccsm</a>
|
|
81
|
+
</div>
|
|
82
|
+
<details class="offline-fallback">
|
|
83
|
+
<summary>Don't have ccsm installed?</summary>
|
|
84
|
+
<div class="offline-fallback-body">
|
|
85
|
+
<p>Install once via npm, then come back here:</p>
|
|
86
|
+
<pre><code>npm i -g @bakapiano/ccsm</code></pre>
|
|
87
|
+
<p>Or run a one-shot trial without installing:</p>
|
|
88
|
+
<pre><code>npx @bakapiano/ccsm</code></pre>
|
|
89
|
+
</div>
|
|
90
|
+
</details>
|
|
91
|
+
</div>
|
|
92
|
+
</div>`;
|
|
93
|
+
}
|
|
@@ -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
|
+
}
|