@bakapiano/ccsm 0.9.0 → 0.10.1
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 +222 -195
- package/README.md +77 -79
- package/lib/cliSessionWatcher.js +249 -0
- package/lib/config.js +101 -24
- package/lib/folders.js +96 -0
- package/lib/localCliSessions.js +177 -0
- package/lib/persistedSessions.js +134 -0
- package/lib/webTerminal.js +31 -18
- package/lib/workspace.js +26 -4
- package/package.json +1 -1
- package/public/assets/claude-color.svg +1 -0
- package/public/assets/codex-color.svg +1 -0
- package/public/assets/copilot-color.svg +1 -0
- package/public/css/base.css +22 -5
- package/public/css/cards.css +37 -3
- package/public/css/feedback.css +127 -43
- package/public/css/forms.css +97 -25
- package/public/css/layout.css +74 -26
- package/public/css/modal.css +40 -26
- package/public/css/responsive.css +2 -2
- package/public/css/sidebar.css +424 -25
- package/public/css/terminals.css +138 -0
- package/public/css/tokens.css +28 -12
- package/public/css/wco.css +38 -39
- package/public/css/widgets.css +1177 -6
- package/public/index.html +35 -2
- package/public/js/api.js +194 -37
- package/public/js/components/AdoptModal.js +171 -0
- package/public/js/components/App.js +1 -11
- package/public/js/components/DirectoryPicker.js +203 -0
- package/public/js/components/EntityFormModal.js +105 -0
- package/public/js/components/Modal.js +51 -0
- package/public/js/components/OfflineBanner.js +29 -23
- package/public/js/components/PageTitleBar.js +13 -0
- package/public/js/components/Picker.js +179 -0
- package/public/js/components/Popover.js +55 -0
- package/public/js/components/Sidebar.js +219 -32
- package/public/js/components/TerminalView.js +27 -3
- package/public/js/components/useDragSort.js +67 -0
- package/public/js/dialog.js +10 -2
- package/public/js/icons.js +66 -3
- package/public/js/main.js +54 -3
- package/public/js/pages/AboutPage.js +80 -0
- package/public/js/pages/ConfigurePage.js +429 -207
- package/public/js/pages/LaunchPage.js +326 -86
- package/public/js/pages/SessionsPage.js +91 -41
- package/public/js/state.js +102 -73
- package/public/manifest.webmanifest +2 -2
- package/scripts/install.js +7 -2
- package/server.js +755 -441
- package/lib/favorites.js +0 -51
- package/lib/focus.js +0 -369
- package/lib/labels.js +0 -29
- package/lib/launcher.js +0 -219
- package/lib/sessions.js +0 -272
- package/lib/snapshot.js +0 -141
- package/public/js/actions.js +0 -107
- package/public/js/components/Fab.js +0 -11
- package/public/js/components/FavoritesTable.js +0 -81
- package/public/js/components/Footer.js +0 -12
- package/public/js/components/NewSessionModal.js +0 -153
- package/public/js/components/PageHead.js +0 -33
- package/public/js/components/Pagination.js +0 -27
- package/public/js/components/RecentTable.js +0 -68
- package/public/js/components/SessionsTable.js +0 -71
- package/public/js/components/SnapshotPanel.js +0 -77
- package/public/js/components/TitleCell.js +0 -40
- package/public/js/components/WorkspacesGrid.js +0 -41
- package/public/js/pages/TerminalsPage.js +0 -74
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// Directory browser used by Launch page. Windows-Explorer-style:
|
|
2
|
+
// ┌───────────────────────────────────────────────┐
|
|
3
|
+
// │ [←] [→] [↑] Home > Users > Admin > foo [✎] │ nav + breadcrumb
|
|
4
|
+
// ├──────────────┬────────────────────────────────┤
|
|
5
|
+
// │ Quick access │ folder rows (large, hoverable)│
|
|
6
|
+
// │ Home │ ⌃ .. │
|
|
7
|
+
// │ Work dir │ 📁 AppData │
|
|
8
|
+
// │ C:\ │ 📁 ccsm-workspaces │
|
|
9
|
+
// │ D:\ │ │
|
|
10
|
+
// └──────────────┴────────────────────────────────┘
|
|
11
|
+
//
|
|
12
|
+
// The picker streams the currently-selected path back to the parent via
|
|
13
|
+
// `onPick(path)` on every selection change. Confirm/cancel UI lives in
|
|
14
|
+
// the parent (the workdir modal's shared footer) so auto + cwd modes
|
|
15
|
+
// share one CTA.
|
|
16
|
+
//
|
|
17
|
+
// Props: { initialPath, onPick }
|
|
18
|
+
|
|
19
|
+
import { html } from '../html.js';
|
|
20
|
+
import { useEffect, useState } from 'preact/hooks';
|
|
21
|
+
import { api } from '../api.js';
|
|
22
|
+
import { setToast } from '../toast.js';
|
|
23
|
+
import { IconFolder, IconHome, IconChevronLeft, IconChevronRight, IconChevronUp, IconPencil } from '../icons.js';
|
|
24
|
+
|
|
25
|
+
export function DirectoryPicker({ initialPath, onPick }) {
|
|
26
|
+
const [data, setData] = useState(null);
|
|
27
|
+
const [path, setPath] = useState(initialPath || '');
|
|
28
|
+
const [history, setHistory] = useState({ stack: [], cursor: -1 }); // back/forward
|
|
29
|
+
const [editing, setEditing] = useState(false);
|
|
30
|
+
const [input, setInput] = useState('');
|
|
31
|
+
const [loading, setLoading] = useState(false);
|
|
32
|
+
|
|
33
|
+
// Push the current selection up on every change so the parent's
|
|
34
|
+
// shared "Use folder" CTA can act on it.
|
|
35
|
+
const select = (p) => { setPath(p); setInput(p); onPick?.(p); };
|
|
36
|
+
|
|
37
|
+
const browse = async (p, { pushHistory = true } = {}) => {
|
|
38
|
+
setLoading(true);
|
|
39
|
+
try {
|
|
40
|
+
const url = '/api/browse' + (p ? `?path=${encodeURIComponent(p)}` : '');
|
|
41
|
+
const r = await api('GET', url);
|
|
42
|
+
setData(r);
|
|
43
|
+
select(r.path);
|
|
44
|
+
if (pushHistory) {
|
|
45
|
+
setHistory((h) => {
|
|
46
|
+
const head = h.stack.slice(0, h.cursor + 1);
|
|
47
|
+
head.push(r.path);
|
|
48
|
+
return { stack: head, cursor: head.length - 1 };
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
} catch (e) { setToast(e.message, 'error'); }
|
|
52
|
+
finally { setLoading(false); }
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
useEffect(() => { browse(initialPath); }, []);
|
|
56
|
+
|
|
57
|
+
const canBack = history.cursor > 0;
|
|
58
|
+
const canForward = history.cursor >= 0 && history.cursor < history.stack.length - 1;
|
|
59
|
+
|
|
60
|
+
const goBack = () => {
|
|
61
|
+
if (!canBack) return;
|
|
62
|
+
const idx = history.cursor - 1;
|
|
63
|
+
setHistory({ ...history, cursor: idx });
|
|
64
|
+
browse(history.stack[idx], { pushHistory: false });
|
|
65
|
+
};
|
|
66
|
+
const goForward = () => {
|
|
67
|
+
if (!canForward) return;
|
|
68
|
+
const idx = history.cursor + 1;
|
|
69
|
+
setHistory({ ...history, cursor: idx });
|
|
70
|
+
browse(history.stack[idx], { pushHistory: false });
|
|
71
|
+
};
|
|
72
|
+
const goUp = () => {
|
|
73
|
+
if (!data?.parent) return;
|
|
74
|
+
browse(data.parent);
|
|
75
|
+
};
|
|
76
|
+
const onAddressSubmit = (ev) => {
|
|
77
|
+
ev?.preventDefault?.();
|
|
78
|
+
const p = (input || '').trim();
|
|
79
|
+
setEditing(false);
|
|
80
|
+
if (p && p !== path) browse(p);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
if (!data) {
|
|
84
|
+
return html`<div class="filex"><div class="filex-loading">Loading…</div></div>`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Build breadcrumb segments. Windows-style: "C:\Users\Admin\foo" →
|
|
88
|
+
// [C:, Users, Admin, foo] with each segment clickable.
|
|
89
|
+
const segments = breadcrumbSegments(data.path);
|
|
90
|
+
|
|
91
|
+
return html`
|
|
92
|
+
<div class="filex">
|
|
93
|
+
<div class="filex-toolbar">
|
|
94
|
+
<div class="filex-navbtns">
|
|
95
|
+
<button class="filex-navbtn" title="Back" disabled=${!canBack} onClick=${goBack}>
|
|
96
|
+
<${IconChevronLeft} />
|
|
97
|
+
</button>
|
|
98
|
+
<button class="filex-navbtn" title="Forward" disabled=${!canForward} onClick=${goForward}>
|
|
99
|
+
<${IconChevronRight} />
|
|
100
|
+
</button>
|
|
101
|
+
<button class="filex-navbtn" title="Up" disabled=${!data.parent} onClick=${goUp}>
|
|
102
|
+
<${IconChevronUp} />
|
|
103
|
+
</button>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
${editing ? html`
|
|
107
|
+
<form class="filex-address-edit" onSubmit=${onAddressSubmit}>
|
|
108
|
+
<input class="filex-address-input mono" value=${input}
|
|
109
|
+
autoFocus
|
|
110
|
+
onInput=${(e) => setInput(e.target.value)}
|
|
111
|
+
onBlur=${onAddressSubmit}
|
|
112
|
+
onKeyDown=${(e) => { if (e.key === 'Escape') { setInput(data.path); setEditing(false); } }}
|
|
113
|
+
spellcheck="false" />
|
|
114
|
+
</form>
|
|
115
|
+
` : html`
|
|
116
|
+
<div class="filex-breadcrumb"
|
|
117
|
+
onClick=${(e) => { if (e.target === e.currentTarget) { setInput(data.path); setEditing(true); } }}>
|
|
118
|
+
${segments.map((seg, i) => html`
|
|
119
|
+
<button key=${seg.path} class="filex-crumb"
|
|
120
|
+
title=${seg.path}
|
|
121
|
+
onClick=${() => browse(seg.path)}>
|
|
122
|
+
${i === 0 && seg.label.match(/^[a-z]:\\?$/i) ? null : null}
|
|
123
|
+
${seg.label}
|
|
124
|
+
</button>
|
|
125
|
+
${i < segments.length - 1
|
|
126
|
+
? html`<span class="filex-crumb-sep" aria-hidden="true">›</span>`
|
|
127
|
+
: null}
|
|
128
|
+
`)}
|
|
129
|
+
<button class="filex-address-edit-btn" title="Edit path"
|
|
130
|
+
onClick=${() => { setInput(data.path); setEditing(true); }}>
|
|
131
|
+
<${IconPencil} />
|
|
132
|
+
</button>
|
|
133
|
+
</div>
|
|
134
|
+
`}
|
|
135
|
+
</div>
|
|
136
|
+
|
|
137
|
+
<div class="filex-body">
|
|
138
|
+
<aside class="filex-side">
|
|
139
|
+
<div class="filex-side-label">Quick access</div>
|
|
140
|
+
${(data.starts || []).map((s) => html`
|
|
141
|
+
<button key=${s.path} class=${`filex-side-item${path === s.path ? ' is-active' : ''}`}
|
|
142
|
+
onClick=${() => browse(s.path)}
|
|
143
|
+
title=${s.path}>
|
|
144
|
+
<span class="filex-side-icon">
|
|
145
|
+
${s.label === 'Home' ? html`<${IconHome} />` : html`<${IconFolder} />`}
|
|
146
|
+
</span>
|
|
147
|
+
<span class="filex-side-name">${s.label}</span>
|
|
148
|
+
</button>`)}
|
|
149
|
+
</aside>
|
|
150
|
+
|
|
151
|
+
<div class="filex-main">
|
|
152
|
+
${!data.exists ? html`
|
|
153
|
+
<div class="filex-empty">Directory not found.</div>
|
|
154
|
+
` : html`
|
|
155
|
+
<div class="filex-list">
|
|
156
|
+
${data.entries.length === 0 ? html`
|
|
157
|
+
<div class="filex-empty">This folder is empty.</div>
|
|
158
|
+
` : data.entries.map((e) => html`
|
|
159
|
+
<button key=${e.path} class="filex-row"
|
|
160
|
+
onDblClick=${() => browse(e.path)}
|
|
161
|
+
onClick=${() => select(e.path)}
|
|
162
|
+
data-active=${path === e.path}>
|
|
163
|
+
<span class="filex-row-icon"><${IconFolder} /></span>
|
|
164
|
+
<span class="filex-row-name">${e.name}</span>
|
|
165
|
+
</button>`)}
|
|
166
|
+
</div>`}
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
<div class="filex-foot">
|
|
171
|
+
<span class="filex-foot-current mono" title=${path}>${path || ' '}</span>
|
|
172
|
+
</div>
|
|
173
|
+
</div>`;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// "C:\Users\Admin\foo" → [{label:'C:', path:'C:\\'}, {label:'Users', path:'C:\\Users'}, …]
|
|
177
|
+
// "/home/me/foo" → [{label:'/', path:'/'}, {label:'home', path:'/home'}, …]
|
|
178
|
+
function breadcrumbSegments(p) {
|
|
179
|
+
if (!p) return [];
|
|
180
|
+
// Windows: split on backslash. Posix: forward slash.
|
|
181
|
+
const isWin = /^[a-zA-Z]:[\\/]/.test(p);
|
|
182
|
+
const sep = isWin ? '\\' : '/';
|
|
183
|
+
const norm = p.replace(/[\\\/]+/g, sep);
|
|
184
|
+
const parts = norm.split(sep).filter(Boolean);
|
|
185
|
+
const segs = [];
|
|
186
|
+
if (isWin) {
|
|
187
|
+
// first part is drive like "C:"
|
|
188
|
+
let acc = parts[0] + sep;
|
|
189
|
+
segs.push({ label: parts[0], path: acc });
|
|
190
|
+
for (let i = 1; i < parts.length; i++) {
|
|
191
|
+
acc = (acc.endsWith(sep) ? acc.slice(0, -1) : acc) + sep + parts[i];
|
|
192
|
+
segs.push({ label: parts[i], path: acc });
|
|
193
|
+
}
|
|
194
|
+
} else {
|
|
195
|
+
let acc = '';
|
|
196
|
+
segs.push({ label: '/', path: '/' });
|
|
197
|
+
for (const part of parts) {
|
|
198
|
+
acc = acc + sep + part;
|
|
199
|
+
segs.push({ label: part, path: acc });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return segs;
|
|
203
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
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, danger,
|
|
22
|
+
}) {
|
|
23
|
+
const [draft, setDraft] = useState(() => ({ ...initialFrom(fields), ...initial }));
|
|
24
|
+
const [saving, setSaving] = useState(false);
|
|
25
|
+
|
|
26
|
+
const isReadOnly = (key) => readOnlyKeys.includes(key);
|
|
27
|
+
|
|
28
|
+
const submit = async (ev) => {
|
|
29
|
+
ev?.preventDefault?.();
|
|
30
|
+
for (const f of fields) {
|
|
31
|
+
if (f.required && !String(draft[f.key] || '').trim()) return;
|
|
32
|
+
}
|
|
33
|
+
setSaving(true);
|
|
34
|
+
try { await onSubmit?.(draft); onClose?.(); }
|
|
35
|
+
catch { /* caller toasts; stay open */ }
|
|
36
|
+
finally { setSaving(false); }
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return html`
|
|
40
|
+
<${Modal} title=${title} onClose=${onClose} width=${440}>
|
|
41
|
+
<form class="entity-form" onSubmit=${submit}>
|
|
42
|
+
${fields.map((f) => html`
|
|
43
|
+
<label class="entity-field" key=${f.key}>
|
|
44
|
+
<span class="entity-field-label">${f.label}</span>
|
|
45
|
+
${f.type === 'select' ? html`
|
|
46
|
+
<select class="input" value=${draft[f.key] || ''}
|
|
47
|
+
disabled=${isReadOnly(f.key)}
|
|
48
|
+
onChange=${(e) => {
|
|
49
|
+
const next = { ...draft, [f.key]: e.target.value };
|
|
50
|
+
const sideEffects = f.onChange?.(e.target.value, next);
|
|
51
|
+
setDraft(sideEffects ? { ...next, ...sideEffects } : next);
|
|
52
|
+
}}>
|
|
53
|
+
${(f.options || []).map((opt) => html`
|
|
54
|
+
<option value=${opt.value}>${opt.label}</option>`)}
|
|
55
|
+
</select>
|
|
56
|
+
` : f.type === 'iconRadio' ? html`
|
|
57
|
+
<div class=${`icon-radio${isReadOnly(f.key) ? ' is-disabled' : ''}`}>
|
|
58
|
+
${(f.options || []).map((opt) => html`
|
|
59
|
+
<button type="button" key=${opt.value}
|
|
60
|
+
class=${`icon-radio-opt${draft[f.key] === opt.value ? ' is-active' : ''}`}
|
|
61
|
+
disabled=${isReadOnly(f.key)}
|
|
62
|
+
onClick=${() => {
|
|
63
|
+
if (isReadOnly(f.key)) return;
|
|
64
|
+
const next = { ...draft, [f.key]: opt.value };
|
|
65
|
+
const sideEffects = f.onChange?.(opt.value, next);
|
|
66
|
+
setDraft(sideEffects ? { ...next, ...sideEffects } : next);
|
|
67
|
+
}}>
|
|
68
|
+
${opt.icon ? html`<span class="icon-radio-icon">${opt.icon}</span>` : null}
|
|
69
|
+
<span>${opt.label}</span>
|
|
70
|
+
</button>`)}
|
|
71
|
+
</div>
|
|
72
|
+
` : f.type === 'checkbox' ? html`
|
|
73
|
+
<span class="entity-checkbox-row">
|
|
74
|
+
<input type="checkbox" checked=${!!draft[f.key]}
|
|
75
|
+
disabled=${isReadOnly(f.key)}
|
|
76
|
+
onChange=${(e) => setDraft({ ...draft, [f.key]: e.target.checked })} />
|
|
77
|
+
${f.hint ? html`<span class="entity-field-hint">${f.hint}</span>` : null}
|
|
78
|
+
</span>
|
|
79
|
+
` : html`
|
|
80
|
+
<input type=${f.type || 'text'}
|
|
81
|
+
class=${`input${f.mono ? ' mono' : ''}`}
|
|
82
|
+
placeholder=${f.placeholder || ''}
|
|
83
|
+
value=${draft[f.key] || ''}
|
|
84
|
+
readonly=${isReadOnly(f.key)}
|
|
85
|
+
onInput=${(e) => setDraft({ ...draft, [f.key]: e.target.value })}
|
|
86
|
+
autoFocus=${f.autoFocus && !isReadOnly(f.key)} />`}
|
|
87
|
+
${f.hint && f.type !== 'checkbox' ? html`
|
|
88
|
+
<span class="entity-field-hint">${f.hint}</span>` : null}
|
|
89
|
+
</label>`)}
|
|
90
|
+
<div class="entity-form-actions">
|
|
91
|
+
<button type="button" class="action small subtle" onClick=${onClose}>Cancel</button>
|
|
92
|
+
<button type="submit" class=${`action small ${danger ? 'danger' : 'primary'}`}
|
|
93
|
+
disabled=${saving}>
|
|
94
|
+
${saving ? 'Saving…' : submitLabel}
|
|
95
|
+
</button>
|
|
96
|
+
</div>
|
|
97
|
+
</form>
|
|
98
|
+
</${Modal}>`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function initialFrom(fields) {
|
|
102
|
+
const out = {};
|
|
103
|
+
for (const f of fields) out[f.key] = f.default ?? '';
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
@@ -0,0 +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,9 +1,11 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// the
|
|
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.
|
|
7
9
|
//
|
|
8
10
|
// First click triggers a Windows confirmation dialog ("Open ccsm.cmd?").
|
|
9
11
|
// User can check "Always allow" to suppress future prompts.
|
|
@@ -12,17 +14,13 @@ import { html } from '../html.js';
|
|
|
12
14
|
import { useEffect, useState } from 'preact/hooks';
|
|
13
15
|
import { serverHealth } from '../state.js';
|
|
14
16
|
import { refreshAll } from '../api.js';
|
|
17
|
+
import { BrandMark } from '../icons.js';
|
|
15
18
|
|
|
16
19
|
export function OfflineBanner() {
|
|
17
20
|
const h = serverHealth.value;
|
|
18
|
-
// "connecting" is the initial transient state — don't flash the banner
|
|
19
|
-
// until we've actually seen offline.
|
|
20
21
|
const offline = h.state === 'offline';
|
|
21
22
|
const [clicked, setClicked] = useState(false);
|
|
22
23
|
|
|
23
|
-
// When backend comes back online after the user tried to launch it,
|
|
24
|
-
// kick refreshAll so the page state catches up faster than the next
|
|
25
|
-
// 5s tick.
|
|
26
24
|
useEffect(() => {
|
|
27
25
|
if (h.state === 'online' && clicked) {
|
|
28
26
|
refreshAll().catch(() => {});
|
|
@@ -33,20 +31,28 @@ export function OfflineBanner() {
|
|
|
33
31
|
if (!offline) return null;
|
|
34
32
|
|
|
35
33
|
return html`
|
|
36
|
-
<div class="offline-
|
|
37
|
-
<div class="offline-
|
|
38
|
-
<
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<a class="action primary" href="ccsm://start"
|
|
34
|
+
<div class="offline-overlay" role="dialog" aria-modal="true" aria-labelledby="offline-title">
|
|
35
|
+
<div class="offline-card">
|
|
36
|
+
<div class="offline-brand"><${BrandMark} /></div>
|
|
37
|
+
<h1 id="offline-title" class="offline-title">Backend not running</h1>
|
|
38
|
+
<p class="offline-copy">
|
|
39
|
+
ccsm's local backend isn't reachable. Click Start to launch it —
|
|
40
|
+
Windows may ask for permission once. Tick <em>Always allow</em>
|
|
41
|
+
to silence future prompts.
|
|
42
|
+
</p>
|
|
43
|
+
<div class="offline-actions">
|
|
44
|
+
<a class="action primary big" href="ccsm://start"
|
|
48
45
|
onClick=${() => setClicked(true)}>Start ccsm</a>
|
|
49
46
|
</div>
|
|
47
|
+
<details class="offline-fallback">
|
|
48
|
+
<summary>Don't have ccsm installed?</summary>
|
|
49
|
+
<div class="offline-fallback-body">
|
|
50
|
+
<p>Install once via npm, then come back here:</p>
|
|
51
|
+
<pre><code>npm i -g @bakapiano/ccsm</code></pre>
|
|
52
|
+
<p>Or run a one-shot trial without installing:</p>
|
|
53
|
+
<pre><code>npx @bakapiano/ccsm</code></pre>
|
|
54
|
+
</div>
|
|
55
|
+
</details>
|
|
50
56
|
</div>
|
|
51
57
|
</div>`;
|
|
52
58
|
}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// Unified picker used inside a Popover. Renders:
|
|
2
|
+
// - optional search box (filters items by `label` + `meta`)
|
|
3
|
+
// - scrollable item list (single or multi select)
|
|
4
|
+
// - footer "+ New <thing>" that expands an inline form
|
|
5
|
+
//
|
|
6
|
+
// items: [{ id, label, meta?, disabled? }]
|
|
7
|
+
// onSelect(id) — single select. Closes popover.
|
|
8
|
+
// onToggle(id, on) — multi select. Doesn't close.
|
|
9
|
+
// selectedIds: Set<string> — for multi select highlight
|
|
10
|
+
// selectedId: string — for single select highlight
|
|
11
|
+
// onCreate(values) — async; returns the newly-created id (selected immediately
|
|
12
|
+
// in single mode; added to selection in multi mode)
|
|
13
|
+
// createFields: [{ key, label, type?, placeholder?, required? }]
|
|
14
|
+
|
|
15
|
+
import { html } from '../html.js';
|
|
16
|
+
import { useState, useRef, useEffect } from 'preact/hooks';
|
|
17
|
+
import { IconSearch, IconPlus, IconClose } from '../icons.js';
|
|
18
|
+
|
|
19
|
+
export function PickerPanel({
|
|
20
|
+
title,
|
|
21
|
+
items,
|
|
22
|
+
selectedId,
|
|
23
|
+
selectedIds,
|
|
24
|
+
multi = false,
|
|
25
|
+
showSearch = true,
|
|
26
|
+
emptyHint = 'Nothing yet.',
|
|
27
|
+
createLabel = '+ New',
|
|
28
|
+
createFields = [],
|
|
29
|
+
onSelect,
|
|
30
|
+
onToggle,
|
|
31
|
+
onCreate,
|
|
32
|
+
onClose,
|
|
33
|
+
dnd,
|
|
34
|
+
}) {
|
|
35
|
+
const [q, setQ] = useState('');
|
|
36
|
+
const [creating, setCreating] = useState(false);
|
|
37
|
+
const [draft, setDraft] = useState(() => initialDraft(createFields));
|
|
38
|
+
const [saving, setSaving] = useState(false);
|
|
39
|
+
const searchRef = useRef(null);
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (showSearch) searchRef.current?.focus();
|
|
43
|
+
}, [showSearch]);
|
|
44
|
+
|
|
45
|
+
const filtered = items.filter((it) => {
|
|
46
|
+
if (!q.trim()) return true;
|
|
47
|
+
const hay = (it.label + ' ' + (it.meta || '')).toLowerCase();
|
|
48
|
+
return hay.includes(q.trim().toLowerCase());
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const submitCreate = async (ev) => {
|
|
52
|
+
ev?.preventDefault?.();
|
|
53
|
+
for (const f of createFields) {
|
|
54
|
+
if (f.required && !String(draft[f.key] || '').trim()) return;
|
|
55
|
+
}
|
|
56
|
+
setSaving(true);
|
|
57
|
+
try {
|
|
58
|
+
const id = await onCreate?.(draft);
|
|
59
|
+
setDraft(initialDraft(createFields));
|
|
60
|
+
setCreating(false);
|
|
61
|
+
if (id != null) {
|
|
62
|
+
if (multi) onToggle?.(id, true);
|
|
63
|
+
else { onSelect?.(id); onClose?.(); }
|
|
64
|
+
}
|
|
65
|
+
} catch (e) {
|
|
66
|
+
// Caller is expected to toast; we just stay open with the form
|
|
67
|
+
console.warn(e);
|
|
68
|
+
} finally {
|
|
69
|
+
setSaving(false);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return html`
|
|
74
|
+
<div class="picker">
|
|
75
|
+
${title ? html`<div class="picker-title">${title}</div>` : null}
|
|
76
|
+
|
|
77
|
+
${showSearch ? html`
|
|
78
|
+
<div class="picker-search">
|
|
79
|
+
<span class="picker-search-icon"><${IconSearch} /></span>
|
|
80
|
+
<input ref=${searchRef} class="picker-search-input"
|
|
81
|
+
placeholder="Search…" value=${q}
|
|
82
|
+
onInput=${(e) => setQ(e.target.value)} />
|
|
83
|
+
${q ? html`<button class="picker-search-clear" onClick=${() => setQ('')}>
|
|
84
|
+
<${IconClose} />
|
|
85
|
+
</button>` : null}
|
|
86
|
+
</div>` : null}
|
|
87
|
+
|
|
88
|
+
<div class="picker-list">
|
|
89
|
+
${filtered.length === 0 ? html`
|
|
90
|
+
<div class="picker-empty">${q ? 'No matches.' : emptyHint}</div>
|
|
91
|
+
` : filtered.map((it) => {
|
|
92
|
+
const isSel = multi ? selectedIds?.has(it.id) : selectedId === it.id;
|
|
93
|
+
const enableDnd = dnd && !it.disabled && !it.undraggable && !q.trim();
|
|
94
|
+
const rowProps = enableDnd ? dnd.rowProps(it.id) : {};
|
|
95
|
+
const handleProps = enableDnd ? dnd.handleProps(it.id) : {};
|
|
96
|
+
return html`
|
|
97
|
+
<div key=${it.id} class=${`picker-item-wrap${enableDnd ? ' is-draggable' : ''}`} ...${rowProps} ...${handleProps}>
|
|
98
|
+
${enableDnd ? html`<span class="picker-item-grip" aria-hidden="true">⋮⋮</span>` : null}
|
|
99
|
+
<button type="button"
|
|
100
|
+
class=${`picker-item${isSel ? ' is-selected' : ''}`}
|
|
101
|
+
disabled=${it.disabled}
|
|
102
|
+
onClick=${() => {
|
|
103
|
+
if (multi) onToggle?.(it.id, !isSel);
|
|
104
|
+
else { onSelect?.(it.id); onClose?.(); }
|
|
105
|
+
}}>
|
|
106
|
+
${it.icon ? html`<span class="picker-item-icon">${it.icon}</span>` : null}
|
|
107
|
+
<span class="picker-item-label">${it.label}</span>
|
|
108
|
+
${it.meta ? html`<span class="picker-item-meta">${it.meta}</span>` : null}
|
|
109
|
+
${isSel ? html`<span class="picker-item-check">✓</span>` : null}
|
|
110
|
+
</button>
|
|
111
|
+
</div>`;
|
|
112
|
+
})}
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
${onCreate ? html`
|
|
116
|
+
<div class="picker-create">
|
|
117
|
+
${!creating ? html`
|
|
118
|
+
<button class="picker-create-toggle" type="button"
|
|
119
|
+
onClick=${() => setCreating(true)}>
|
|
120
|
+
<${IconPlus} />
|
|
121
|
+
<span>${createLabel}</span>
|
|
122
|
+
</button>
|
|
123
|
+
` : html`
|
|
124
|
+
<form class="picker-create-form" onSubmit=${submitCreate}>
|
|
125
|
+
${createFields.map((f) => html`
|
|
126
|
+
<label class="picker-field" key=${f.key}>
|
|
127
|
+
<span class="picker-field-label">${f.label}</span>
|
|
128
|
+
${f.type === 'select' ? html`
|
|
129
|
+
<select class="input" value=${draft[f.key] || ''}
|
|
130
|
+
onChange=${(e) => {
|
|
131
|
+
const next = { ...draft, [f.key]: e.target.value };
|
|
132
|
+
const side = f.onChange?.(e.target.value, next);
|
|
133
|
+
setDraft(side ? { ...next, ...side } : next);
|
|
134
|
+
}}>
|
|
135
|
+
${(f.options || []).map((opt) => html`
|
|
136
|
+
<option value=${opt.value}>${opt.label}</option>`)}
|
|
137
|
+
</select>
|
|
138
|
+
` : f.type === 'iconRadio' ? html`
|
|
139
|
+
<div class="icon-radio">
|
|
140
|
+
${(f.options || []).map((opt) => html`
|
|
141
|
+
<button type="button" key=${opt.value}
|
|
142
|
+
class=${`icon-radio-opt${draft[f.key] === opt.value ? ' is-active' : ''}`}
|
|
143
|
+
onClick=${() => {
|
|
144
|
+
const next = { ...draft, [f.key]: opt.value };
|
|
145
|
+
const side = f.onChange?.(opt.value, next);
|
|
146
|
+
setDraft(side ? { ...next, ...side } : next);
|
|
147
|
+
}}>
|
|
148
|
+
${opt.icon ? html`<span class="icon-radio-icon">${opt.icon}</span>` : null}
|
|
149
|
+
<span>${opt.label}</span>
|
|
150
|
+
</button>`)}
|
|
151
|
+
</div>
|
|
152
|
+
` : html`
|
|
153
|
+
<input type=${f.type || 'text'}
|
|
154
|
+
class=${`input${f.mono ? ' mono' : ''}`}
|
|
155
|
+
placeholder=${f.placeholder || ''}
|
|
156
|
+
value=${draft[f.key] || ''}
|
|
157
|
+
onInput=${(e) => setDraft({ ...draft, [f.key]: e.target.value })}
|
|
158
|
+
autoFocus=${f.autoFocus} />`}
|
|
159
|
+
${f.hint ? html`<span class="picker-field-hint">${f.hint}</span>` : null}
|
|
160
|
+
</label>`)}
|
|
161
|
+
<div class="picker-create-actions">
|
|
162
|
+
<button type="button" class="action small subtle"
|
|
163
|
+
onClick=${() => { setCreating(false); setDraft(initialDraft(createFields)); }}>
|
|
164
|
+
Cancel
|
|
165
|
+
</button>
|
|
166
|
+
<button type="submit" class="action small primary" disabled=${saving}>
|
|
167
|
+
${saving ? 'Creating…' : 'Create'}
|
|
168
|
+
</button>
|
|
169
|
+
</div>
|
|
170
|
+
</form>`}
|
|
171
|
+
</div>` : null}
|
|
172
|
+
</div>`;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function initialDraft(fields) {
|
|
176
|
+
const out = {};
|
|
177
|
+
for (const f of fields) out[f.key] = f.default ?? '';
|
|
178
|
+
return out;
|
|
179
|
+
}
|