-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.html
More file actions
395 lines (362 loc) · 16.3 KB
/
Copy pathshell.html
File metadata and controls
395 lines (362 loc) · 16.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>AyTree — modular shell</title>
<style>
:root {
--bg: #0f0e0a;
--text: #f4edcf;
--muted: #a99f78;
--accent: #c2a334;
--accent-strong: #e0be3e;
--line: rgba(224, 190, 62, 0.22);
--card: #17150d;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; width: 100vw; height: 100vh; overflow: hidden; background: var(--bg); color: var(--text); font-family: system-ui, Inter, ui-sans-serif, sans-serif; text-rendering: optimizeLegibility; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; background: var(--bg); }
.inspector, #status {
position: absolute; z-index: 15; font-size: 0.7rem; color: var(--muted);
background: rgba(15,14,10,0.85); border: 1px solid var(--line); border-radius: 5px; padding: 4px 7px;
}
.inspector { bottom: 12px; left: 12px; max-width: 380px; font-size: 0.9rem; line-height: 1.3; display: none; }
.inspector.open { display: block; }
#status { bottom: 8px; right: 8px; font-size: 0.65rem; pointer-events: none; }
#picker-prompt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(15,14,10,0.7); z-index: 30; font-size: 1rem; text-align: center; }
button { pointer-events: auto; padding: 8px 14px; font-size: 0.9rem; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
button:hover { border-color: var(--accent); }
#lens-legend {
position: absolute; top: 8px; left: 8px; z-index: 15; display: flex; gap: 6px;
background: rgba(15,14,10,0.85); border: 1px solid var(--line); border-radius: 5px; padding: 5px;
}
.lens-chip {
display: flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 4px;
border: 1px solid var(--line); font-size: 0.72rem; color: var(--muted);
}
.lens-chip .key {
display: inline-block; min-width: 1.1em; text-align: center; padding: 0 3px;
border: 1px solid var(--muted); border-radius: 3px; font-weight: 700; color: var(--text);
}
.lens-chip.active { border-color: var(--accent-strong); color: var(--text); }
.lens-chip.active .key { border-color: var(--accent-strong); background: var(--accent-strong); color: #0f0e0a; }
.lens-chip.stub { opacity: 0.55; font-style: italic; }
.lens-chip.overlay-on { border-color: var(--accent); color: var(--accent-strong); }
#filter-panel {
position: absolute; top: 8px; right: 8px; z-index: 15; width: 168px;
background: rgba(15,14,10,0.9); border: 1px solid var(--line); border-radius: 5px;
padding: 8px; font-size: 0.72rem; color: var(--muted);
}
#filter-panel h3 {
margin: 0 0 5px; font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase;
color: var(--text); opacity: 0.75;
}
#filter-panel .group { margin-bottom: 8px; }
#filter-panel label {
display: flex; align-items: center; gap: 6px; padding: 2px 0; cursor: pointer;
user-select: none;
}
#filter-panel input[type="checkbox"] { accent-color: var(--accent-strong); cursor: pointer; }
#filter-panel .swatch {
display: inline-block; width: 8px; height: 8px; border-radius: 2px; flex: none;
}
#insp-status-row { display: flex; }
.status-chip {
font-size: 0.68rem; padding: 2px 7px; border-radius: 3px; border: 1px solid var(--line);
color: var(--muted); background: transparent; cursor: pointer;
}
.status-chip.active { border-color: var(--accent-strong); color: var(--text); font-weight: 700; }
</style>
</head>
<body>
<canvas id="map"></canvas>
<div id="lens-legend"></div>
<div id="filter-panel">
<div class="group">
<h3>categories</h3>
<div id="filter-categories"></div>
</div>
<div class="group">
<h3>kind</h3>
<label><input type="checkbox" id="filter-files" checked> files</label>
<label><input type="checkbox" id="filter-dirs" checked> directories</label>
</div>
<div class="group">
<h3>commits</h3>
<label><input type="checkbox" id="filter-regular" checked> regular</label>
<label><input type="checkbox" id="filter-merge" checked> merge</label>
</div>
</div>
<div id="inspector" class="inspector">
<div id="insp-name" style="font-weight:700; font-size:0.95rem;"></div>
<div id="insp-path" style="font-family:monospace; font-size:0.82rem; word-break:break-all;"></div>
<div id="insp-meta" style="color:var(--muted); font-size:0.75rem;"></div>
<div id="insp-status-row" style="display:none; margin-top:6px; gap:4px;"></div>
<textarea id="insp-note" style="display:none; width:100%; margin-top:6px; min-height:44px; resize:vertical; background:rgba(0,0,0,0.25); color:var(--text); border:1px solid var(--line); border-radius:4px; padding:4px 6px; font:inherit; font-size:0.8rem;" placeholder="add a note…"></textarea>
<div id="insp-note-saved" style="display:none; font-size:0.62rem; opacity:0.6; margin-top:2px;">saved</div>
<div style="margin-top:6px;"><button id="close-insp">close</button></div>
</div>
<div id="status"></div>
<div id="picker-prompt">
<div style="max-width:520px;">
<div style="font-size:1.15rem; margin-bottom:8px;">AyTree — modular shell</div>
<div style="margin-bottom:12px;">Select a local git repo dir. Keys 1/2/3 switch lenses, w toggles the weave overlay.</div>
<button id="pick-btn">Select local repo dir</button>
</div>
</div>
<script type="module">
import { Compositor } from './src/compositor/compositor.js';
import { RafScheduler } from './src/compositor/raf.js';
import { BASE_LENSES, WEAVE_OVERLAY } from './src/compositor/lens-registry.js';
import { loadSnapshot } from './src/ingest/picker.js';
import { CAT_COLOR } from './src/compositor/encode.js';
import { fetchNotes, saveNote } from './src/ingest/notes-client.js';
const STATUSES = ['todo', 'in-progress', 'blocked', 'done'];
const canvas = document.getElementById('map');
const statusEl = document.getElementById('status');
const legendEl = document.getElementById('lens-legend');
const insp = document.getElementById('inspector');
const inspName = document.getElementById('insp-name');
const inspPath = document.getElementById('insp-path');
const inspMeta = document.getElementById('insp-meta');
const inspStatusRow = document.getElementById('insp-status-row');
const inspNote = document.getElementById('insp-note');
const inspNoteSaved = document.getElementById('insp-note-saved');
const pickerPrompt = document.getElementById('picker-prompt');
const compositor = new Compositor(canvas);
const raf = new RafScheduler(() => compositor.present());
let currentSnapshot = null;
let currentLensId = BASE_LENSES[0].id;
let weaveOn = false;
function setStatus(msg) { statusEl.textContent = msg; }
function currentLens() {
return compositor.baseLens;
}
function renderLegend() {
legendEl.innerHTML = '';
for (const l of BASE_LENSES) {
const chip = document.createElement('span');
chip.className = 'lens-chip' + (l.id === currentLensId ? ' active' : '') + (l.ready ? '' : ' stub');
chip.innerHTML = `<span class="key">${l.key}</span>${l.label}${l.ready ? '' : ' (soon)'}`;
legendEl.appendChild(chip);
}
const wChip = document.createElement('span');
wChip.className = 'lens-chip' + (weaveOn ? ' overlay-on' : '') + (WEAVE_OVERLAY.ready ? '' : ' stub');
wChip.innerHTML = `<span class="key">${WEAVE_OVERLAY.key}</span>${WEAVE_OVERLAY.label}${WEAVE_OVERLAY.ready ? '' : ' (soon)'}`;
legendEl.appendChild(wChip);
}
function switchLens(entry) {
if (entry.id === currentLensId && compositor.baseLens) return;
const lens = new entry.ctor();
try {
if (currentSnapshot) lens.setData(currentSnapshot);
compositor.mount(lens);
currentLensId = entry.id;
renderLegend();
if (currentSnapshot) {
compositor.fitView(lens.nodes);
setStatus(`lens: ${entry.label} • ${currentSnapshot.repoPath}`);
} else {
setStatus(`lens: ${entry.label} selected • pick a repo to load data`);
}
raf.schedule();
} catch (e) {
setStatus(`${entry.label}: ${e.message}`);
}
}
function toggleWeave() {
if (!WEAVE_OVERLAY.ready) {
setStatus(`${WEAVE_OVERLAY.label}: not implemented yet — see docs/ARCHITECTURE.md §4`);
return;
}
weaveOn = !weaveOn;
if (weaveOn) {
const overlay = new WEAVE_OVERLAY.ctor();
if (currentSnapshot) overlay.setData(currentSnapshot);
compositor.setWeaveOverlay(overlay);
} else {
compositor.setWeaveOverlay(null);
}
renderLegend();
raf.schedule();
}
// === On-screen filter panel (docs/ARCHITECTURE.md's filter state lives on the
// compositor so it's shared across lenses; this just renders + edits it) ===
const catsEl = document.getElementById('filter-categories');
for (const cat of Object.keys(CAT_COLOR)) {
const label = document.createElement('label');
label.innerHTML = `<input type="checkbox" checked data-cat="${cat}"><span class="swatch" style="background:${CAT_COLOR[cat]}"></span>${cat}`;
catsEl.appendChild(label);
}
catsEl.addEventListener('change', (e) => {
const cat = e.target.dataset.cat;
if (!cat) return;
if (e.target.checked) compositor.filterState.categories.add(cat);
else compositor.filterState.categories.delete(cat);
raf.schedule();
});
document.getElementById('filter-files').addEventListener('change', (e) => {
compositor.filterState.showFiles = e.target.checked;
raf.schedule();
});
document.getElementById('filter-dirs').addEventListener('change', (e) => {
compositor.filterState.showDirs = e.target.checked;
raf.schedule();
});
document.getElementById('filter-regular').addEventListener('change', (e) => {
compositor.filterState.showRegularCommits = e.target.checked;
raf.schedule();
});
document.getElementById('filter-merge').addEventListener('change', (e) => {
compositor.filterState.showMergeCommits = e.target.checked;
raf.schedule();
});
// Default lens on boot
switchLens(BASE_LENSES[0]);
function resizeAndDraw() {
compositor.resize();
raf.schedule();
}
let noteSaveTimer = null;
let inspectedNode = null;
function renderStatusChips(node) {
inspStatusRow.innerHTML = '';
const current = node.note && node.note.status;
for (const s of STATUSES) {
const chip = document.createElement('button');
chip.type = 'button';
chip.className = 'status-chip' + (s === current ? ' active' : '');
chip.textContent = s;
chip.addEventListener('click', () => {
node.note = node.note || {};
node.note.status = s === current ? '' : s; // click again to clear
node.hasNote = !!(node.note.notes || node.note.status);
renderStatusChips(node);
persistNote(node);
raf.schedule();
});
inspStatusRow.appendChild(chip);
}
}
// Server keys notes relative to SCAN_ROOT (the picked repo's parent dir), e.g.
// "AyTree/src/foo.js" — not "src/foo.js" like snapshot.files[].path (repo-relative).
function workspaceKey(path) {
return currentSnapshot ? `${currentSnapshot.repoPath}/${path}` : path;
}
function persistNote(node) {
clearTimeout(noteSaveTimer);
inspNoteSaved.style.display = 'none';
noteSaveTimer = setTimeout(async () => {
try {
await saveNote(workspaceKey(node.path), node.note || {});
if (inspectedNode === node) {
inspNoteSaved.style.display = 'block';
setTimeout(() => { inspNoteSaved.style.display = 'none'; }, 1200);
}
} catch {
setStatus('note not saved — is the server running? (server/aytree_server.py)');
}
}, 500); // debounce: autosave, no explicit save action to click
}
function updateInspector(n) {
inspectedNode = n;
if (!n) {
insp.classList.remove('open');
return;
}
inspName.textContent = n.name + (n.isDir ? ' /' : '');
inspPath.textContent = n.path;
inspMeta.textContent = `${n.cat} • ${n.isDir ? 'directory' : 'file'} • click map or press Esc to close`;
// notes only make sense for file-tree nodes (spatial-map / radial-onion), not commits
const notable = typeof n.hasNote !== 'undefined';
inspStatusRow.style.display = notable ? 'flex' : 'none';
inspNote.style.display = notable ? 'block' : 'none';
if (notable) {
renderStatusChips(n);
inspNote.value = (n.note && n.note.notes) || '';
}
insp.classList.add('open');
}
inspNote.addEventListener('input', () => {
if (!inspectedNode) return;
inspectedNode.note = inspectedNode.note || {};
inspectedNode.note.notes = inspNote.value;
inspectedNode.hasNote = !!(inspectedNode.note.notes || inspectedNode.note.status);
persistNote(inspectedNode);
raf.schedule();
});
canvas.addEventListener('pointerdown', (e) => {
canvas.setPointerCapture(e.pointerId);
canvas.dataset.dragging = '1';
canvas.dataset.lastX = e.clientX;
canvas.dataset.lastY = e.clientY;
});
window.addEventListener('pointermove', (e) => {
if (canvas.dataset.dragging !== '1') return;
const dx = e.clientX - Number(canvas.dataset.lastX);
const dy = e.clientY - Number(canvas.dataset.lastY);
compositor.pan(dx, dy);
canvas.dataset.lastX = e.clientX;
canvas.dataset.lastY = e.clientY;
raf.schedule();
});
window.addEventListener('pointerup', () => { canvas.dataset.dragging = '0'; });
canvas.addEventListener('wheel', (e) => {
e.preventDefault();
const factor = e.deltaY < 0 ? 1.18 : 1 / 1.18;
compositor.zoomAt(e.clientX, e.clientY, factor);
raf.schedule();
}, { passive: false });
canvas.addEventListener('click', (e) => {
const rect = canvas.getBoundingClientRect();
let hit = compositor.hitTest(e.clientX - rect.left, e.clientY - rect.top);
// lens-specific click hook (e.g. radial-onion re-roots on directory click)
const lens = currentLens();
if (hit && lens && typeof lens.onClick === 'function') {
hit = lens.onClick(hit);
raf.schedule();
}
updateInspector(hit);
});
window.addEventListener('keydown', (e) => {
if (e.key === 'Escape') { updateInspector(null); return; }
if (e.key.toLowerCase() === 'r') {
compositor.fitView(currentLens() ? currentLens().nodes : []);
raf.schedule();
return;
}
if (e.key.toLowerCase() === WEAVE_OVERLAY.key) { toggleWeave(); return; }
const entry = BASE_LENSES.find((l) => l.key === e.key);
if (entry) switchLens(entry);
});
new ResizeObserver(resizeAndDraw).observe(canvas);
document.getElementById('close-insp').addEventListener('click', () => updateInspector(null));
document.getElementById('pick-btn').addEventListener('click', async () => {
try {
setStatus('loading local repo…');
const snapshot = await loadSnapshot('local-git');
// re-key the workspace-relative notes DB to this repo's own relative paths
const rawNotes = await fetchNotes();
const prefix = `${snapshot.repoPath}/`;
snapshot.notes = {};
for (const [k, v] of Object.entries(rawNotes)) {
if (k.startsWith(prefix)) snapshot.notes[k.slice(prefix.length)] = v;
}
currentSnapshot = snapshot;
const lens = currentLens();
lens.setData(snapshot);
if (compositor.weaveOverlay) compositor.weaveOverlay.setData(snapshot);
pickerPrompt.style.display = 'none';
compositor.resize();
compositor.fitView(lens.nodes);
raf.schedule();
setStatus(`${lens.nodes.length} items • ${snapshot.commits.length} commits • ${snapshot.repoPath}`);
} catch (e) {
setStatus('picker cancelled or failed: ' + (e && e.message ? e.message : e));
}
});
resizeAndDraw();
</script>
</body>
</html>