@bakapiano/ccsm 0.22.3 → 0.22.4

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 (60) 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 +592 -592
  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 +148 -22
  42. package/public/js/components/TerminalResizeDebouncer.js +126 -0
  43. package/public/js/components/XtermTerminal.js +62 -15
  44. package/public/js/components/useDragSort.js +67 -67
  45. package/public/js/dialog.js +67 -67
  46. package/public/js/icons.js +212 -212
  47. package/public/js/main.js +296 -296
  48. package/public/js/pages/AboutPage.js +90 -90
  49. package/public/js/pages/ConfigurePage.js +713 -713
  50. package/public/js/pages/LaunchPage.js +421 -421
  51. package/public/js/pages/RemotePage.js +743 -743
  52. package/public/js/pages/SessionsPage.js +100 -100
  53. package/public/js/state.js +335 -335
  54. package/public/manifest.webmanifest +25 -0
  55. package/public/setup/index.html +567 -0
  56. package/scripts/dev.js +149 -149
  57. package/scripts/install.js +153 -153
  58. package/scripts/restart-helper.js +96 -96
  59. package/scripts/upgrade-helper.js +687 -687
  60. package/server.js +1807 -1807
@@ -1,203 +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
- }
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
+ }