@1agh/maude 1.7.1 → 1.9.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/apps/studio/acp/bridge.ts +15 -2
- package/apps/studio/acp/login-state.ts +1 -0
- package/apps/studio/acp/probe.ts +52 -1
- package/apps/studio/api.ts +431 -39
- package/apps/studio/asset-upload.ts +174 -0
- package/apps/studio/assets-s3.ts +37 -2
- package/apps/studio/bin/_curl-local.mjs +7 -0
- package/apps/studio/bin/_pdf-playwright.mjs +22 -1
- package/apps/studio/bin/_png-playwright.mjs +20 -1
- package/apps/studio/bin/_region.mjs +92 -0
- package/apps/studio/bin/annotate.mjs +16 -7
- package/apps/studio/bin/read-annotations.mjs +62 -4
- package/apps/studio/canvas-build.ts +59 -4
- package/apps/studio/canvas-lib.tsx +48 -1
- package/apps/studio/canvas-shell.tsx +28 -4
- package/apps/studio/client/app.jsx +441 -15903
- package/apps/studio/client/canvas-url.js +9 -0
- package/apps/studio/client/dialogs/asset-picker.jsx +331 -0
- package/apps/studio/client/dialogs/command-palette.jsx +112 -0
- package/apps/studio/client/dialogs/export-dialog.jsx +782 -0
- package/apps/studio/client/dialogs/help-modal.jsx +324 -0
- package/apps/studio/client/dialogs/shortcuts-overlay.jsx +144 -0
- package/apps/studio/client/embed-view.jsx +284 -0
- package/apps/studio/client/embed.js +101 -0
- package/apps/studio/client/export-center.jsx +2 -0
- package/apps/studio/client/github.js +36 -3
- package/apps/studio/client/hooks/use-canvas-bridge.jsx +2150 -0
- package/apps/studio/client/hooks/use-git-actions.jsx +236 -0
- package/apps/studio/client/hooks/use-keyboard-shortcuts.jsx +297 -0
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +474 -0
- package/apps/studio/client/hooks/use-photo-and-timeline.jsx +901 -0
- package/apps/studio/client/hooks/use-project-data.jsx +90 -0
- package/apps/studio/client/hooks/use-shell-core.jsx +1212 -0
- package/apps/studio/client/hooks/use-tabs.jsx +723 -0
- package/apps/studio/client/hooks/use-web-socket.jsx +13 -0
- package/apps/studio/client/inspector/artboard-knobs.jsx +456 -0
- package/apps/studio/client/inspector/color-picker.jsx +196 -0
- package/apps/studio/client/inspector/color.js +92 -0
- package/apps/studio/client/inspector/css-knobs.jsx +1720 -0
- package/apps/studio/client/inspector/css-vocab.jsx +131 -0
- package/apps/studio/client/inspector/ds-tokens.js +90 -0
- package/apps/studio/client/inspector/grid-tracks-editor.jsx +97 -0
- package/apps/studio/client/inspector/inspect-computed.jsx +68 -0
- package/apps/studio/client/inspector/inspector-panel.jsx +769 -0
- package/apps/studio/client/inspector/layers.jsx +322 -0
- package/apps/studio/client/inspector/selection.js +65 -0
- package/apps/studio/client/inspector/token-popover.jsx +301 -0
- package/apps/studio/client/menus/menubar.jsx +856 -0
- package/apps/studio/client/report-bug.jsx +8 -2
- package/apps/studio/client/selection-scope.js +40 -0
- package/apps/studio/client/shell/banners.jsx +272 -0
- package/apps/studio/client/shell/collapsed-rail.jsx +23 -0
- package/apps/studio/client/shell/comments-panel.jsx +177 -0
- package/apps/studio/client/shell/constants.js +60 -0
- package/apps/studio/client/shell/dock.jsx +131 -0
- package/apps/studio/client/shell/icons.jsx +370 -0
- package/apps/studio/client/shell/status-bar.jsx +215 -0
- package/apps/studio/client/shell/util.js +332 -0
- package/apps/studio/client/shell/viewport.jsx +254 -0
- package/apps/studio/client/system/system-view.jsx +255 -0
- package/apps/studio/client/tree/tree.jsx +1243 -0
- package/apps/studio/comments-overlay.tsx +6 -4
- package/apps/studio/config.schema.json +5 -0
- package/apps/studio/context.ts +20 -0
- package/apps/studio/dist/client.bundle.js +2728 -2728
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/embed-origins.ts +52 -0
- package/apps/studio/export-dialog.tsx +55 -3
- package/apps/studio/exporters/_browser-bundles.ts +21 -2
- package/apps/studio/exporters/format-scopes.ts +11 -3
- package/apps/studio/exporters/index.ts +17 -2
- package/apps/studio/exporters/jobs.ts +91 -23
- package/apps/studio/exporters/pdf.ts +10 -2
- package/apps/studio/exporters/png.ts +10 -2
- package/apps/studio/exporters/scope.ts +89 -15
- package/apps/studio/format.ts +296 -0
- package/apps/studio/generation/runtime-probe.ts +1 -1
- package/apps/studio/git/service.ts +1 -0
- package/apps/studio/http.ts +399 -36
- package/apps/studio/input-router.tsx +7 -1
- package/apps/studio/path-containment.ts +72 -0
- package/apps/studio/paths.ts +14 -1
- package/apps/studio/read-only-mode.ts +53 -0
- package/apps/studio/server.ts +123 -25
- package/apps/studio/sync/accepted-link.ts +6 -0
- package/apps/studio/sync/agent.ts +9 -1
- package/apps/studio/sync/cold-start-apply.ts +29 -4
- package/apps/studio/sync/cold-start.ts +78 -0
- package/apps/studio/sync/file-plane.ts +61 -1
- package/apps/studio/sync/format-sync.ts +160 -0
- package/apps/studio/sync/index.ts +208 -23
- package/apps/studio/sync/journal-client.ts +25 -5
- package/apps/studio/sync/migrate-seed.ts +8 -1
- package/apps/studio/sync/park.ts +39 -0
- package/apps/studio/sync/presentation.ts +9 -3
- package/apps/studio/sync/status.ts +2 -0
- package/apps/studio/sync/transaction-client.ts +130 -13
- package/apps/studio/sync/writer-registry.ts +5 -0
- package/apps/studio/ui-prefs.ts +95 -10
- package/apps/studio/use-canvas-media-drop.tsx +8 -28
- package/apps/studio/whats-new.json +36 -0
- package/apps/studio/ws.ts +19 -4
- package/cli/bin/claude-design-server.mjs +0 -0
- package/cli/commands/design.mjs +9 -2
- package/cli/commands/hub-workspace.mjs +25 -0
- package/cli/lib/workspace-plan.mjs +51 -0
- package/package.json +11 -9
- package/plugins/design/templates/_shell.html +58 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
// hooks/use-git-actions.jsx — moved verbatim out of client/app.jsx (Maude v2 plan V2-0.2, move-only split).
|
|
2
|
+
|
|
3
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
export function useGitActions({
|
|
6
|
+
gitStatus, setGitStatus, setRemoteSync, diffTarget, setDiffTarget, savingIsManaged,
|
|
7
|
+
savingIsManagedRef
|
|
8
|
+
}) {
|
|
9
|
+
// ----- Phase 27 (E2) — git actions -----
|
|
10
|
+
// All write actions POST same-origin (the dev-server's sameOriginWrite + the
|
|
11
|
+
// dual-allowlist gate them main-origin only). After a mutation we refresh
|
|
12
|
+
// status optimistically; the `git-status` WS broadcast also lands shortly.
|
|
13
|
+
const refreshGitStatus = useCallback(async () => {
|
|
14
|
+
if (savingIsManagedRef.current) return; // cloud-managed — nobody polls a repo they don't commit to
|
|
15
|
+
try {
|
|
16
|
+
const r = await fetch('/_api/git/status');
|
|
17
|
+
if (r.ok) setGitStatus(await r.json());
|
|
18
|
+
} catch {}
|
|
19
|
+
}, []);
|
|
20
|
+
|
|
21
|
+
// Phase 28 (E3) — probe the tracking remote so the Changes panel can surface
|
|
22
|
+
// the "Get latest" nudge (GitPanel reads `status.remoteAhead` / `status.behind`).
|
|
23
|
+
// `?remote=1` is what makes the server do the `git fetch` + ahead/behind count;
|
|
24
|
+
// without it the status is local-only and the nudge never fires. Network call —
|
|
25
|
+
// call sparingly (mount / interval / post-action), never on the WS hot path.
|
|
26
|
+
const refreshRemoteSync = useCallback(async () => {
|
|
27
|
+
// The ahead/behind probe is a real network `git fetch` against the LOCAL
|
|
28
|
+
// repo's remote — the one remote a cloud-managed project has nothing to do
|
|
29
|
+
// with. Gated here as well as at the interval, so a post-action call site
|
|
30
|
+
// cannot reintroduce it.
|
|
31
|
+
if (savingIsManagedRef.current) return;
|
|
32
|
+
try {
|
|
33
|
+
const r = await fetch('/_api/git/status?remote=1');
|
|
34
|
+
if (!r.ok) return;
|
|
35
|
+
const data = await r.json();
|
|
36
|
+
if (data && data.repo !== false)
|
|
37
|
+
setRemoteSync({ remoteAhead: !!data.remoteAhead, behind: data.behind || 0 });
|
|
38
|
+
} catch {}
|
|
39
|
+
}, []);
|
|
40
|
+
|
|
41
|
+
const gitPostJson = useCallback(async (path, body) => {
|
|
42
|
+
try {
|
|
43
|
+
const r = await fetch(path, {
|
|
44
|
+
method: 'POST',
|
|
45
|
+
headers: { 'Content-Type': 'application/json' },
|
|
46
|
+
body: JSON.stringify(body || {}),
|
|
47
|
+
});
|
|
48
|
+
const data = await r.json().catch(() => ({}));
|
|
49
|
+
return { ok: r.ok, ...data };
|
|
50
|
+
} catch (e) {
|
|
51
|
+
return { ok: false, error: 'Network error — is the project still open?' };
|
|
52
|
+
}
|
|
53
|
+
}, []);
|
|
54
|
+
|
|
55
|
+
const gitCommit = useCallback(
|
|
56
|
+
async (message, files) => {
|
|
57
|
+
const res = await gitPostJson('/_api/git/commit', { message, files });
|
|
58
|
+
if (res.ok) await refreshGitStatus();
|
|
59
|
+
return res;
|
|
60
|
+
},
|
|
61
|
+
[gitPostJson, refreshGitStatus]
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const gitDiscard = useCallback(
|
|
65
|
+
async (files) => {
|
|
66
|
+
const res = await gitPostJson('/_api/git/discard', { files });
|
|
67
|
+
if (res.ok) await refreshGitStatus();
|
|
68
|
+
return res;
|
|
69
|
+
},
|
|
70
|
+
[gitPostJson, refreshGitStatus]
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const gitPublish = useCallback(async () => {
|
|
74
|
+
const res = await gitPostJson('/_api/git/push', {});
|
|
75
|
+
// Refresh so the "N versions ready to publish" count clears to 0 after a
|
|
76
|
+
// successful push (the server advanced the local remote-tracking ref), and
|
|
77
|
+
// re-probe the remote so a stale "Get latest" nudge clears.
|
|
78
|
+
if (res.ok) {
|
|
79
|
+
await refreshGitStatus();
|
|
80
|
+
refreshRemoteSync();
|
|
81
|
+
}
|
|
82
|
+
return res;
|
|
83
|
+
}, [gitPostJson, refreshGitStatus, refreshRemoteSync]);
|
|
84
|
+
|
|
85
|
+
const gitGetLatest = useCallback(async () => {
|
|
86
|
+
const res = await gitPostJson('/_api/git/pull', {});
|
|
87
|
+
// On success the remote is merged in — clear the nudge by re-probing.
|
|
88
|
+
if (res.ok) {
|
|
89
|
+
await refreshGitStatus();
|
|
90
|
+
refreshRemoteSync();
|
|
91
|
+
}
|
|
92
|
+
// A true content conflict → open the visual resolver on the first file.
|
|
93
|
+
if (res.conflict && Array.isArray(res.files) && res.files.length) {
|
|
94
|
+
setDiffTarget({ file: res.files[0], conflict: true });
|
|
95
|
+
}
|
|
96
|
+
return res;
|
|
97
|
+
}, [gitPostJson, refreshGitStatus, refreshRemoteSync]);
|
|
98
|
+
|
|
99
|
+
// Phase 28 (E3) — finish a Get-latest conflict from the DiffView resolver.
|
|
100
|
+
// `choice` is 'mine' | 'theirs' | 'both'; the server completes the two-parent
|
|
101
|
+
// merge commit (and, for 'both', writes our version as a "(mine)" copy).
|
|
102
|
+
const gitResolveConflict = useCallback(
|
|
103
|
+
async (choice) => {
|
|
104
|
+
const res = await gitPostJson('/_api/git/resolve', { choice });
|
|
105
|
+
if (res.ok) {
|
|
106
|
+
await refreshGitStatus();
|
|
107
|
+
refreshRemoteSync();
|
|
108
|
+
}
|
|
109
|
+
return res;
|
|
110
|
+
},
|
|
111
|
+
[gitPostJson, refreshGitStatus, refreshRemoteSync]
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
// `path` (optional) scopes History to one canvas — the per-file version list
|
|
115
|
+
// behind the History click-to-preview + DiffView "Saved version" picker
|
|
116
|
+
// (phase-27.1). Omit for the repo-wide log.
|
|
117
|
+
const gitLoadLog = useCallback(async (path) => {
|
|
118
|
+
try {
|
|
119
|
+
const qs = '/_api/git/log?limit=40' + (path ? `&path=${encodeURIComponent(path)}` : '');
|
|
120
|
+
const r = await fetch(qs);
|
|
121
|
+
if (!r.ok) return [];
|
|
122
|
+
const data = await r.json();
|
|
123
|
+
return data.entries || [];
|
|
124
|
+
} catch {
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
}, []);
|
|
128
|
+
|
|
129
|
+
// THE HISTORY THAT IS ACTUALLY BEING WRITTEN (feature-cloud-managed-git-
|
|
130
|
+
// posture). Same signature and same row shape as `gitLoadLog` — the two are
|
|
131
|
+
// interchangeable at the call site precisely because the format, the argv and
|
|
132
|
+
// the parser behind them are ONE module (`git/log-format.ts`), imported by
|
|
133
|
+
// both the local service and the cell.
|
|
134
|
+
//
|
|
135
|
+
// Failure is REPORTED, never mistaken for emptiness: `null` means "we could
|
|
136
|
+
// not reach the cloud" (the panel shows a Retry callout), `[]` means "the
|
|
137
|
+
// cloud has no versions yet" (the panel shows the empty state). Collapsing
|
|
138
|
+
// the two is what produced the original bug in the first place.
|
|
139
|
+
const [cloudHistory, setCloudHistory] = useState(null); // { branch, project, hubHost } | null
|
|
140
|
+
const gitLoadCloudLog = useCallback(async (path) => {
|
|
141
|
+
try {
|
|
142
|
+
const qs =
|
|
143
|
+
'/_api/cloud/history?limit=40' + (path ? `&path=${encodeURIComponent(path)}` : '');
|
|
144
|
+
const r = await fetch(qs);
|
|
145
|
+
if (!r.ok) return null;
|
|
146
|
+
const data = await r.json();
|
|
147
|
+
if (!data?.ok) return null;
|
|
148
|
+
setCloudHistory({
|
|
149
|
+
branch: data.branch ?? null,
|
|
150
|
+
project: data.project ?? null,
|
|
151
|
+
hubHost: data.hubHost ?? null,
|
|
152
|
+
});
|
|
153
|
+
return data.entries || [];
|
|
154
|
+
} catch {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
}, []);
|
|
158
|
+
|
|
159
|
+
// ACCEPTED REVISIONS — the project's own history (DDR-241, T27). When the
|
|
160
|
+
// project saves through accepted revisions the History tab lists logical
|
|
161
|
+
// actions (who did what, when), not Git commits; a row previews as `r<rev>`
|
|
162
|
+
// through the same version preview. `'legacy'` means "use Git history".
|
|
163
|
+
const [projectHistoryOn, setProjectHistoryOn] = useState(false);
|
|
164
|
+
const [projectHistoryRefresh, setProjectHistoryRefresh] = useState(0);
|
|
165
|
+
const loadAcceptedLog = useCallback(async (path) => {
|
|
166
|
+
try {
|
|
167
|
+
const qs =
|
|
168
|
+
'/_api/project/history?limit=40' + (path ? `&path=${encodeURIComponent(path)}` : '');
|
|
169
|
+
const r = await fetch(qs);
|
|
170
|
+
if (!r.ok) return 'legacy';
|
|
171
|
+
const data = await r.json();
|
|
172
|
+
if (!data?.ok) return data?.reason === 'legacy' ? 'legacy' : null;
|
|
173
|
+
return (data.history || []).map((a) => {
|
|
174
|
+
const where = path ? '' : (a.canvases || []).map((c) => c.split('/').pop()).join(', ');
|
|
175
|
+
return {
|
|
176
|
+
sha: `r${a.revision}`,
|
|
177
|
+
message: [a.label || a.kind, where].filter(Boolean).join(' · '),
|
|
178
|
+
author: a.actor,
|
|
179
|
+
date: new Date(a.committedAt).toISOString(),
|
|
180
|
+
accepted: {
|
|
181
|
+
revision: a.revision,
|
|
182
|
+
actionId: a.actionId,
|
|
183
|
+
mine: !!a.mine,
|
|
184
|
+
undo: a.kind === 'undo' || a.kind === 'redo',
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
});
|
|
188
|
+
} catch {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
}, []);
|
|
192
|
+
|
|
193
|
+
// An accepted preview must stay on project history even if loading fails:
|
|
194
|
+
// switching to Git would turn Restore into an unrelated discard operation.
|
|
195
|
+
const acceptedDiff = /^r\d+$/.test(diffTarget?.beforeSha || '');
|
|
196
|
+
const loadDiffLog = useCallback(async (path) => {
|
|
197
|
+
if (!acceptedDiff) return gitLoadLog(path);
|
|
198
|
+
const entries = await loadAcceptedLog(path);
|
|
199
|
+
return Array.isArray(entries) ? entries : [];
|
|
200
|
+
}, [acceptedDiff, gitLoadLog, loadAcceptedLog]);
|
|
201
|
+
const restoreProjectVersion = useCallback(async (path, revision) => {
|
|
202
|
+
if (!path || !Number.isSafeInteger(revision) || revision < 0) {
|
|
203
|
+
return { ok: false, error: 'Choose a saved project version to restore.' };
|
|
204
|
+
}
|
|
205
|
+
const r = await fetch('/_api/project/restore', {
|
|
206
|
+
method: 'POST',
|
|
207
|
+
headers: { 'Content-Type': 'application/json' },
|
|
208
|
+
body: JSON.stringify({ path, revision }),
|
|
209
|
+
}).catch(() => null);
|
|
210
|
+
const result = r ? await r.json().catch(() => null) : null;
|
|
211
|
+
if (r?.ok && result?.ok) {
|
|
212
|
+
setProjectHistoryRefresh((version) => version + 1);
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
return { ok: false, error: result?.error };
|
|
216
|
+
}, []);
|
|
217
|
+
|
|
218
|
+
// Repo-relative path → M/A/D/U badge for the tree (paths match: both the tree
|
|
219
|
+
// and gitStatus use `.design/ui/Foo.tsx`). Keyed off gitStatus so it updates
|
|
220
|
+
// live with the WS broadcast.
|
|
221
|
+
const dirtyByPath = useMemo(() => {
|
|
222
|
+
const KIND = { modified: 'M', added: 'A', deleted: 'D', untracked: 'U' };
|
|
223
|
+
const m = new Map();
|
|
224
|
+
// A tree badge is the SAME claim as the withdrawn count, drawn one row at a
|
|
225
|
+
// time: "this file is unsaved". In cloud-managed posture it is not — the
|
|
226
|
+
// cell committed it seconds ago. Empty, so the tree simply says nothing.
|
|
227
|
+
if (savingIsManaged) return m;
|
|
228
|
+
for (const f of gitStatus?.files || []) m.set(f.path, KIND[f.status]);
|
|
229
|
+
return m;
|
|
230
|
+
}, [gitStatus, savingIsManaged]);
|
|
231
|
+
return {
|
|
232
|
+
acceptedDiff, cloudHistory, dirtyByPath, gitCommit, gitDiscard, gitGetLatest, gitLoadCloudLog,
|
|
233
|
+
gitLoadLog, gitPublish, gitResolveConflict, loadAcceptedLog, loadDiffLog, projectHistoryOn,
|
|
234
|
+
projectHistoryRefresh, refreshRemoteSync, restoreProjectVersion, setProjectHistoryOn
|
|
235
|
+
};
|
|
236
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
// hooks/use-keyboard-shortcuts.jsx — moved verbatim out of client/app.jsx (Maude v2 plan V2-0.2, move-only split).
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect } from 'react';
|
|
4
|
+
import { SYSTEM_TAB } from '../shell/constants.js';
|
|
5
|
+
import { isNativeApp } from '../github.js';
|
|
6
|
+
import { totalCounts } from '../shell/util.js';
|
|
7
|
+
|
|
8
|
+
export function useKeyboardShortcuts({
|
|
9
|
+
activePath, selected, viewerMode, commentsByFile, focusedCommentId, setFocusedCommentId,
|
|
10
|
+
sidebarOpen, setShowHidden, setHelpOpen, setShortcutsOpen, setPaletteOpen, setExportDialog,
|
|
11
|
+
setSettingsOpen, inspectorTab, openPanelExclusive, togglePanel, toggleRightPanel, toggleTimeline,
|
|
12
|
+
presentMode, iframesRef, postToActiveCanvas, performPhotoUndo, tlKeyRef, exitPresent, openSystem,
|
|
13
|
+
closeTab, reloadActive, refreshTree, clearActiveCanvasSelection
|
|
14
|
+
}) {
|
|
15
|
+
// ----- Keyboard shortcuts (no Cmd+W — let browser close the tab) -----
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
function onKey(e) {
|
|
18
|
+
const meta = e.metaKey || e.ctrlKey;
|
|
19
|
+
const inEditable =
|
|
20
|
+
['INPUT', 'TEXTAREA'].includes(document.activeElement?.tagName) ||
|
|
21
|
+
document.activeElement?.isContentEditable;
|
|
22
|
+
// Phase 4.1: shell-side letter shortcuts (H/T/S) must not double-fire
|
|
23
|
+
// inside a focused canvas iframe — the canvas input router owns those
|
|
24
|
+
// letters as tool-mode keys (V/H/C). Cmd-modified shortcuts (⌘R, ⌘⇧M,
|
|
25
|
+
// ⌘F) still fire regardless of focus, mirroring browser convention.
|
|
26
|
+
const inCanvasIframe = document.activeElement?.tagName === 'IFRAME';
|
|
27
|
+
|
|
28
|
+
// Esc exits Presentation Mode first — it's the primary way back to the
|
|
29
|
+
// chrome (the menubar is hidden while presenting). Highest priority so it
|
|
30
|
+
// wins over the focused-pin / deselect Esc handlers below, and fires even
|
|
31
|
+
// when focus is inside the canvas iframe.
|
|
32
|
+
if (presentMode && e.key === 'Escape') {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
exitPresent();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Cmd+K / Ctrl+K — toggle the command palette (works even in inputs).
|
|
39
|
+
if (meta && (e.key === 'k' || e.key === 'K')) {
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
setPaletteOpen((v) => !v);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// Cmd+Z / Cmd+Shift+Z / Cmd+Y — forward to the active canvas's undo stack
|
|
45
|
+
// when focus is in the shell chrome (not a text field, not the canvas
|
|
46
|
+
// iframe). Inside the canvas iframe the canvas owns Cmd+Z; inside an editable
|
|
47
|
+
// field native undo wins (the inspector's CssKnobs forwards on its own). This
|
|
48
|
+
// makes inspector CSS / inline text / attr edits undoable from anywhere.
|
|
49
|
+
if (meta && !e.altKey && (e.key === 'z' || e.key === 'Z' || e.key === 'y' || e.key === 'Y')) {
|
|
50
|
+
if (!inEditable && !inCanvasIframe && activePath && activePath !== SYSTEM_TAB) {
|
|
51
|
+
// DDR-150 dogfood #1 (team finding) — SINGLE OWNER per keypress. With
|
|
52
|
+
// the Timeline open on a video-comp canvas, the timeline undo stack
|
|
53
|
+
// owns Cmd+Z/Shift+Cmd+Z (the timeline keydown effect performs it).
|
|
54
|
+
// Without this skip, BOTH handlers fired on one keypress — undoing a
|
|
55
|
+
// clip op AND popping the canvas's annotation undo simultaneously.
|
|
56
|
+
if (
|
|
57
|
+
(e.key === 'z' || e.key === 'Z') &&
|
|
58
|
+
tlKeyRef.current.open &&
|
|
59
|
+
tlKeyRef.current.comps?.length
|
|
60
|
+
) {
|
|
61
|
+
return; // the timeline shortcuts effect claims it
|
|
62
|
+
}
|
|
63
|
+
const redo = e.key === 'y' || e.key === 'Y' || e.shiftKey;
|
|
64
|
+
// feature-photo-editor — photo edits are sidecar writes (`/_api/photo-edit`),
|
|
65
|
+
// invisible to the canvas's own source-edit undo stack, so they need
|
|
66
|
+
// their own owner here. Claims the keypress only while the Photo tab
|
|
67
|
+
// is the one on screen AND it actually has something to undo/redo —
|
|
68
|
+
// otherwise falls through to the canvas stack as before. (Focus still
|
|
69
|
+
// inside a Photo-tab slider is handled separately by
|
|
70
|
+
// `onPhotoKnobKeyDown`, mirroring `onKnobKeyDown` for CSS knobs.)
|
|
71
|
+
if (inspectorTab === 'photo' && performPhotoUndo(redo)) {
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
postToActiveCanvas({ dgn: redo ? 'redo' : 'undo' });
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Cmd+Shift+R — refresh the FILES tree (re-read /_index-data). The fs-watch
|
|
81
|
+
// → canvas-list-update auto-refresh can miss events in the compiled desktop
|
|
82
|
+
// sidecar (recursive fs.watch is unreliable in a bun --compile binary), and
|
|
83
|
+
// ⌘R is taken by canvas-iframe reload, so this is the manual escape hatch.
|
|
84
|
+
if (meta && e.shiftKey && (e.key === 'r' || e.key === 'R')) {
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
refreshTree();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// Cmd+R — reload active iframe (override browser reload)
|
|
90
|
+
if (meta && (e.key === 'r' || e.key === 'R')) {
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
reloadActive();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// Cmd+Shift+M / Ctrl+Shift+M — toggle right "Comments" panel
|
|
96
|
+
if (meta && e.shiftKey && (e.key === 'm' || e.key === 'M')) {
|
|
97
|
+
e.preventDefault();
|
|
98
|
+
toggleRightPanel('comments');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// Cmd+Shift+G — toggle the Changes (git) panel. Opening it closes the
|
|
102
|
+
// other right-dock panels (one panel at a time).
|
|
103
|
+
if (meta && e.shiftKey && (e.key === 'g' || e.key === 'G')) {
|
|
104
|
+
e.preventDefault();
|
|
105
|
+
toggleRightPanel('changes');
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
// Cmd+Shift+I — toggle Inspector. Was bare "I", which collided with the
|
|
109
|
+
// canvas highlighter tool (same letter, different action by focus).
|
|
110
|
+
//
|
|
111
|
+
// Cloud Phase 27 C1 — a VIEWER GETS THIS TOO, and the line above used to
|
|
112
|
+
// say the opposite ("the panel is edit chrome"). C1 reversed that on
|
|
113
|
+
// purpose: read-only means cannot CHANGE, not cannot SEE, and a reviewer
|
|
114
|
+
// needs structure and measured values as much as anyone. The View menu
|
|
115
|
+
// already offers it (`viewerHiddenPanels` no longer hides it); the
|
|
116
|
+
// shortcut had been left behind, so the menu said yes and the keyboard
|
|
117
|
+
// said no. Found by writing the parity spec that runs in both shells.
|
|
118
|
+
if (meta && e.shiftKey && (e.key === 'i' || e.key === 'I')) {
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
toggleRightPanel('inspector');
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
// Phase 31 (DDR-123) — Cmd+Shift+A opens the native ACP chat sidepanel.
|
|
124
|
+
// Cloud Phase 25 C2 — the agent edits; absent for a viewer.
|
|
125
|
+
if (meta && e.shiftKey && (e.key === 'a' || e.key === 'A') && isNativeApp()) {
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
if (!viewerMode) toggleRightPanel('assistant');
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
// Cmd+Shift+E / Cmd+Shift+H — the File-menu chords, previously
|
|
131
|
+
// advertised but never bound.
|
|
132
|
+
if (meta && e.shiftKey && (e.key === 'e' || e.key === 'E')) {
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
setExportDialog({ mode: 'export' });
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (meta && e.shiftKey && (e.key === 'h' || e.key === 'H')) {
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
setExportDialog({ mode: 'handoff' });
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
// Cmd+, — open Settings (AI generation keys). The platform convention for
|
|
143
|
+
// a settings/preferences surface (feature-ai-media-generation, DDR-16x).
|
|
144
|
+
// Cloud Phase 25 C2 — settings mutate project config; absent for a viewer.
|
|
145
|
+
if (meta && !e.shiftKey && !e.altKey && e.key === ',') {
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
if (!viewerMode) setSettingsOpen(true);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
// Cmd+Shift+T — toggle the Timeline (video-comp scrub) dock.
|
|
151
|
+
if (meta && e.shiftKey && (e.key === 't' || e.key === 'T')) {
|
|
152
|
+
e.preventDefault();
|
|
153
|
+
toggleTimeline();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
// Cmd+C / Ctrl+C — Phase 4.1 removed the shell-side comment-drop chord.
|
|
157
|
+
// Canvas comment-drop is the `C` tool letter (press C in the canvas,
|
|
158
|
+
// then click the element) or right-click "Add comment". Cmd+C now
|
|
159
|
+
// reverts to native browser copy.
|
|
160
|
+
if (meta && !e.shiftKey && !e.altKey && (e.key === 'c' || e.key === 'C')) {
|
|
161
|
+
if (
|
|
162
|
+
selected &&
|
|
163
|
+
selected.selector &&
|
|
164
|
+
activePath &&
|
|
165
|
+
activePath !== SYSTEM_TAB &&
|
|
166
|
+
!inEditable &&
|
|
167
|
+
console &&
|
|
168
|
+
console.warn
|
|
169
|
+
) {
|
|
170
|
+
console.warn(
|
|
171
|
+
'Cmd+C comment-drop deprecated — press C inside the canvas to enter Comment tool, then click the element.'
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
// Fall through to native copy.
|
|
175
|
+
}
|
|
176
|
+
if (inEditable) return;
|
|
177
|
+
// / — focus search (or ⌘F per CV-08 placeholder hint)
|
|
178
|
+
if (e.key === '/') {
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
const inp = document.querySelector('.st-search input');
|
|
181
|
+
if (inp) inp.focus();
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (meta && (e.key === 'f' || e.key === 'F')) {
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
if (!sidebarOpen) openPanelExclusive('tree');
|
|
187
|
+
setTimeout(() => {
|
|
188
|
+
const inp = document.querySelector('.st-search input');
|
|
189
|
+
if (inp) inp.focus();
|
|
190
|
+
}, 0);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
// T / H / S are bare-letter shell shortcuts. When focus is inside a
|
|
194
|
+
// canvas iframe, the canvas input router claims V/H/C — bail out
|
|
195
|
+
// here so the canvas owns the key and the sidebar/system view don't
|
|
196
|
+
// double-fire on focused-canvas keypresses.
|
|
197
|
+
if (inCanvasIframe) {
|
|
198
|
+
// Esc still bubbles below (composer / focused-pin clear).
|
|
199
|
+
if (e.key !== 'Escape') return;
|
|
200
|
+
}
|
|
201
|
+
// T — toggle Project Tree (sidebar)
|
|
202
|
+
if (e.key === 't' || e.key === 'T') {
|
|
203
|
+
if (e.shiftKey || meta) return;
|
|
204
|
+
e.preventDefault();
|
|
205
|
+
togglePanel('tree');
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
// H — toggle show-hidden (sidecars + project/runtime orphans)
|
|
209
|
+
if (e.key === 'h' || e.key === 'H') {
|
|
210
|
+
if (e.shiftKey || meta) return;
|
|
211
|
+
e.preventDefault();
|
|
212
|
+
setShowHidden((v) => !v);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
// S — toggle Design system view
|
|
216
|
+
if ((e.key === 's' || e.key === 'S') && !meta && !e.shiftKey) {
|
|
217
|
+
e.preventDefault();
|
|
218
|
+
if (activePath === SYSTEM_TAB) {
|
|
219
|
+
closeTab(SYSTEM_TAB);
|
|
220
|
+
} else {
|
|
221
|
+
openSystem();
|
|
222
|
+
}
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
// N — open the new-brief-board composer (replaces the advertised ⌘N,
|
|
226
|
+
// which the browser reserves for New Window and never delivers).
|
|
227
|
+
if ((e.key === 'n' || e.key === 'N') && !meta && !e.shiftKey) {
|
|
228
|
+
e.preventDefault();
|
|
229
|
+
openPanelExclusive('tree');
|
|
230
|
+
setTimeout(
|
|
231
|
+
() => document.querySelector('[aria-label="New blank brief board"]')?.click(),
|
|
232
|
+
60
|
|
233
|
+
);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
// ? — keyboard-shortcuts cheat sheet (DS shortcuts overlay)
|
|
237
|
+
if (e.key === '?') {
|
|
238
|
+
e.preventDefault();
|
|
239
|
+
setShortcutsOpen((v) => !v);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
// F1 — the full Help modal (commands & flows)
|
|
243
|
+
if (e.key === 'F1') {
|
|
244
|
+
e.preventDefault();
|
|
245
|
+
setHelpOpen(true);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
// Esc — clear focused pin. The in-place composer (Phase 6) and thread
|
|
249
|
+
// popover handle their own Esc inside the iframe.
|
|
250
|
+
if (e.key === 'Escape') {
|
|
251
|
+
if (focusedCommentId) {
|
|
252
|
+
setFocusedCommentId(null);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
window.addEventListener('keydown', onKey);
|
|
258
|
+
return () => window.removeEventListener('keydown', onKey);
|
|
259
|
+
}, [
|
|
260
|
+
reloadActive,
|
|
261
|
+
refreshTree,
|
|
262
|
+
selected,
|
|
263
|
+
activePath,
|
|
264
|
+
focusedCommentId,
|
|
265
|
+
sidebarOpen,
|
|
266
|
+
openSystem,
|
|
267
|
+
closeTab,
|
|
268
|
+
clearActiveCanvasSelection,
|
|
269
|
+
presentMode,
|
|
270
|
+
exitPresent,
|
|
271
|
+
toggleTimeline,
|
|
272
|
+
inspectorTab,
|
|
273
|
+
performPhotoUndo,
|
|
274
|
+
viewerMode,
|
|
275
|
+
]);
|
|
276
|
+
|
|
277
|
+
const registerIframe = useCallback((path, el) => {
|
|
278
|
+
if (el) iframesRef.current.set(path, el);
|
|
279
|
+
}, []);
|
|
280
|
+
|
|
281
|
+
const totalOpen = totalCounts(commentsByFile).open;
|
|
282
|
+
|
|
283
|
+
// Suppress the native browser context menu across the shell — the canvas
|
|
284
|
+
// input-router already handles right-click inside the canvas host, but
|
|
285
|
+
// sidebar / menubar / statusbar / floating chrome would otherwise leak the
|
|
286
|
+
// native menu on top of our `.dc-context-menu` (or alone, outside canvas).
|
|
287
|
+
// Editable fields (search box, future text inputs) keep the native menu so
|
|
288
|
+
// copy/paste still works.
|
|
289
|
+
const onShellContextMenu = useCallback((e) => {
|
|
290
|
+
const t = e.target;
|
|
291
|
+
if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
e.preventDefault();
|
|
295
|
+
}, []);
|
|
296
|
+
return { onShellContextMenu, registerIframe, totalOpen };
|
|
297
|
+
}
|