@1agh/maude 2.0.0-rc.1 → 2.0.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/index.ts +35 -2
- package/apps/studio/acp/login-state.ts +3 -2
- package/apps/studio/actions/defs/chat.ts +4 -1
- package/apps/studio/actions.manifest.json +1 -1
- package/apps/studio/agent-runs.ts +3 -0
- package/apps/studio/ai/lease-home.ts +11 -1
- package/apps/studio/ai/run-lifecycle.ts +17 -0
- package/apps/studio/ai/runs.ts +64 -12
- package/apps/studio/api.ts +31 -5
- package/apps/studio/bridge/dgn-protocol.ts +13 -0
- package/apps/studio/canvas-imports.ts +23 -4
- package/apps/studio/canvas-lib.tsx +7 -0
- package/apps/studio/client/app.jsx +4 -0
- package/apps/studio/client/export-lane.js +4 -2
- package/apps/studio/client/fonts/LICENSE-Inter-Tight.txt +93 -0
- package/apps/studio/client/fonts/LICENSE-Inter.txt +93 -0
- package/apps/studio/client/fonts/LICENSE-JetBrains-Mono.txt +93 -0
- package/apps/studio/client/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
- package/apps/studio/client/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/apps/studio/client/fonts/inter-tight-latin-ext-wght-normal.woff2 +0 -0
- package/apps/studio/client/fonts/inter-tight-latin-wght-normal.woff2 +0 -0
- package/apps/studio/client/fonts/jetbrains-mono-latin-ext-wght-normal.woff2 +0 -0
- package/apps/studio/client/fonts/jetbrains-mono-latin-wght-normal.woff2 +0 -0
- package/apps/studio/client/hooks/use-canvas-bridge.jsx +6 -0
- package/apps/studio/client/index.html +0 -3
- package/apps/studio/client/panels/ChatPanel.jsx +10 -2
- package/apps/studio/client/panels/acp-runtime.js +14 -0
- package/apps/studio/client/styles/_index.css +2 -0
- package/apps/studio/client/styles/fonts.css +63 -0
- package/apps/studio/client/system/system-view.jsx +6 -2
- package/apps/studio/client/tree-row-menu.jsx +4 -0
- package/apps/studio/client/v2/ai/Advanced.jsx +23 -7
- package/apps/studio/client/v2/ai/AttachMenu.jsx +4 -0
- package/apps/studio/client/v2/ai/ChatList.jsx +7 -1
- package/apps/studio/client/v2/ai/ConnectSheet.jsx +75 -4
- package/apps/studio/client/v2/ai/NeedsYouSlot.jsx +42 -8
- package/apps/studio/client/v2/ai/NotReady.jsx +24 -3
- package/apps/studio/client/v2/ai/RunList.jsx +4 -0
- package/apps/studio/client/v2/ai/RunSurface.jsx +14 -4
- package/apps/studio/client/v2/ai/ScopeChip.jsx +4 -0
- package/apps/studio/client/v2/ai/Working.jsx +13 -1
- package/apps/studio/client/v2/ai/activity-line.js +390 -0
- package/apps/studio/client/v2/ai/activity-store.js +45 -0
- package/apps/studio/client/v2/ai/advanced-model.js +62 -12
- package/apps/studio/client/v2/ai/ai-list-advanced.css +7 -0
- package/apps/studio/client/v2/ai/ai-run.css +19 -0
- package/apps/studio/client/v2/ai/ai-send.js +6 -2
- package/apps/studio/client/v2/ai/connect-flow.js +29 -8
- package/apps/studio/client/v2/ai/needs-you.css +18 -0
- package/apps/studio/client/v2/ai/needs-you.js +10 -0
- package/apps/studio/client/v2/ai/ring-relay.js +11 -1
- package/apps/studio/client/v2/ai/use-activity-line.js +81 -0
- package/apps/studio/client/v2/annotations/templates-panel.jsx +4 -0
- package/apps/studio/client/v2/assets/kinds-chip.jsx +1 -1
- package/apps/studio/client/v2/assets/place-asset.js +20 -1
- package/apps/studio/client/v2/assets/tile-menu.jsx +1 -1
- package/apps/studio/client/v2/canvases/canvases-panel.jsx +5 -1
- package/apps/studio/client/v2/canvases/row-menu.jsx +4 -2
- package/apps/studio/client/v2/ds/review.css +2 -0
- package/apps/studio/client/v2/empty/ai-drafting.jsx +78 -0
- package/apps/studio/client/v2/empty/empty-host.jsx +17 -0
- package/apps/studio/client/v2/empty/empty.css +98 -0
- package/apps/studio/client/v2/export/advanced/render.jsx +5 -2
- package/apps/studio/client/v2/export/export-copy.js +11 -4
- package/apps/studio/client/v2/export/export-sheet.jsx +6 -2
- package/apps/studio/client/v2/export/exports-model.js +13 -0
- package/apps/studio/client/v2/export/exports-panel.jsx +4 -2
- package/apps/studio/client/v2/export/job-row.jsx +4 -0
- package/apps/studio/client/v2/export/other-formats.jsx +7 -1
- package/apps/studio/client/v2/export/sections/batch-model.js +3 -2
- package/apps/studio/client/v2/export/sections/batch.jsx +20 -4
- package/apps/studio/client/v2/inspector/sections/colour-popover.jsx +4 -0
- package/apps/studio/client/v2/inspector/token-chip.jsx +4 -0
- package/apps/studio/client/v2/kinds/SizePicker.jsx +4 -0
- package/apps/studio/client/v2/presence/faces.jsx +4 -0
- package/apps/studio/client/v2/share/role-menu.jsx +7 -1
- package/apps/studio/client/v2/share/share-model.js +20 -1
- package/apps/studio/client/v2/share/share-sheet.jsx +6 -4
- package/apps/studio/client/v2/shell/account-card.jsx +7 -1
- package/apps/studio/client/v2/shell/canvas-pointer.js +21 -0
- package/apps/studio/client/v2/shell/mode-switch.jsx +4 -0
- package/apps/studio/client/v2/shell/project-pill.jsx +4 -0
- package/apps/studio/client/v2/shell/save-status.js +10 -1
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +2 -0
- package/apps/studio/client/v2/shell/share-cluster.jsx +6 -1
- package/apps/studio/client/v2/shell/use-dismiss-outside.js +14 -6
- package/apps/studio/client/v2/timeline/joins/transition-picker.jsx +7 -1
- package/apps/studio/client/v2/undo/undo-history.jsx +7 -1
- package/apps/studio/cloud/endpoints.ts +31 -1
- package/apps/studio/dist/client.bundle.js +921 -921
- package/apps/studio/dist/comment-mount.js +1 -1
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/editing/canvas-pointer.ts +29 -0
- package/apps/studio/routes/cloud-move.ts +7 -4
- package/apps/studio/sync/ctl-provider.ts +4 -1
- package/apps/studio/sync/file-ledger.ts +12 -0
- package/apps/studio/sync/file-membership.ts +28 -0
- package/apps/studio/sync/file-plane.ts +119 -5
- package/apps/studio/sync/index.ts +55 -1
- package/apps/studio/sync/journal-client.ts +12 -0
- package/apps/studio/sync/poke.ts +30 -0
- package/apps/studio/sync/presentation.ts +6 -1
- package/apps/studio/sync/projection.ts +7 -0
- package/apps/studio/sync/retry-after.ts +27 -0
- package/apps/studio/sync/status.ts +9 -1
- package/apps/studio/video-play-overlay.tsx +67 -12
- package/apps/studio/whats-new.json +78 -6
- package/package.json +8 -8
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// client/v2/ai/activity-store.js — rc3-h (#182): what the chat's activity line knows that the canvas can use.
|
|
2
|
+
//
|
|
3
|
+
// One value per tab: the artboard the AI's in-flight edit names (`{ file, artboard, label, adding? }`, file
|
|
4
|
+
// repo-relative), or null. use-activity-line.js writes it from the live stream; the ring relay
|
|
5
|
+
// (ring-relay.js) marks that artboard the moment the edit starts — before the write lands and the run's
|
|
6
|
+
// lease arrives — and the empty canvas's drafting ghost (empty/ai-drafting.jsx) takes the name of an
|
|
7
|
+
// artboard being added. Names only (an index label or a capped `label`), never a path or the model's words.
|
|
8
|
+
|
|
9
|
+
import { useSyncExternalStore } from 'react';
|
|
10
|
+
|
|
11
|
+
export function createActivityStore() {
|
|
12
|
+
let target = null;
|
|
13
|
+
const subs = new Set();
|
|
14
|
+
const same = (a, b) =>
|
|
15
|
+
a === b ||
|
|
16
|
+
(!!a &&
|
|
17
|
+
!!b &&
|
|
18
|
+
a.file === b.file &&
|
|
19
|
+
a.artboard === b.artboard &&
|
|
20
|
+
a.label === b.label &&
|
|
21
|
+
!!a.adding === !!b.adding);
|
|
22
|
+
return {
|
|
23
|
+
get: () => target,
|
|
24
|
+
set(next) {
|
|
25
|
+
const t = next && typeof next === 'object' ? next : null;
|
|
26
|
+
if (same(t, target)) return;
|
|
27
|
+
target = t;
|
|
28
|
+
for (const fn of [...subs]) fn();
|
|
29
|
+
},
|
|
30
|
+
subscribe(fn) {
|
|
31
|
+
subs.add(fn);
|
|
32
|
+
return () => subs.delete(fn);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let shared = null;
|
|
38
|
+
export function getActivityStore() {
|
|
39
|
+
if (!shared) shared = createActivityStore();
|
|
40
|
+
return shared;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function useActivityTarget(store = getActivityStore()) {
|
|
44
|
+
return useSyncExternalStore(store.subscribe, store.get, store.get);
|
|
45
|
+
}
|
|
@@ -19,7 +19,7 @@ export const ADVANCED_WHERE = 'AI chat panel › Advanced';
|
|
|
19
19
|
* to and focuses. Open in terminal and Copy transcript are registry actions that already existed (S5.7).
|
|
20
20
|
*/
|
|
21
21
|
export const ADVANCED_ROWS = Object.freeze([
|
|
22
|
-
{ row: 'ask-before', action: 'chat.advanced.ask-before', label: '
|
|
22
|
+
{ row: 'ask-before', action: 'chat.advanced.ask-before', label: 'Permissions' },
|
|
23
23
|
{ row: 'model', action: 'chat.advanced.model', label: 'Model' },
|
|
24
24
|
{ row: 'effort', action: 'chat.advanced.effort', label: 'Effort' },
|
|
25
25
|
{ row: 'fast', action: 'chat.advanced.fast-mode', label: 'Fast mode' },
|
|
@@ -36,27 +36,75 @@ export const rowDomId = (row) => `ai-adv-${row}`;
|
|
|
36
36
|
|
|
37
37
|
// ── modes in plain words ─────────────────────────────────────────────────────────────────────────
|
|
38
38
|
|
|
39
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Claude Code's mode ids → what AI may do (03 `ai-adv-edges`; rc3-g, issue #181 C). Order = the order the menu
|
|
41
|
+
* lists them. Each entry: id · label · group · hint · risky.
|
|
42
|
+
* - The LABEL reads alone — it is all the closed row shows ("Permissions: Edit freely, ask before commands"),
|
|
43
|
+
* so it never leans on a heading or on the row's name.
|
|
44
|
+
* - The HINT is one line under the closed row: what AI may do WITHOUT asking, and what it still asks.
|
|
45
|
+
* - RISKY marks the one mode with no checks at all; it says so in its label, its group and its hint.
|
|
46
|
+
*/
|
|
40
47
|
const MODE_WORDS = [
|
|
41
|
-
[
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
[
|
|
49
|
+
'default',
|
|
50
|
+
'Ask before every change',
|
|
51
|
+
'asks',
|
|
52
|
+
'AI asks before it changes a canvas, replaces or deletes a file, or runs a command.',
|
|
53
|
+
false,
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
'auto',
|
|
57
|
+
'Ask only when unsure',
|
|
58
|
+
'asks',
|
|
59
|
+
'AI decides what is safe to do and asks when it is unsure.',
|
|
60
|
+
false,
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
'acceptEdits',
|
|
64
|
+
'Edit freely, ask before commands',
|
|
65
|
+
'asks',
|
|
66
|
+
'AI changes canvases and files in this project without asking. It still asks before running a command.',
|
|
67
|
+
false,
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
'plan',
|
|
71
|
+
'Suggest only',
|
|
72
|
+
'nochange',
|
|
73
|
+
'AI changes nothing. It only suggests what it would do.',
|
|
74
|
+
false,
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
'dontAsk',
|
|
78
|
+
'Skip what needs asking',
|
|
79
|
+
'nochange',
|
|
80
|
+
'AI never asks. Anything that would need a yes is skipped.',
|
|
81
|
+
false,
|
|
82
|
+
],
|
|
83
|
+
[
|
|
84
|
+
'bypassPermissions',
|
|
85
|
+
'Skip every check — risky',
|
|
86
|
+
'free',
|
|
87
|
+
'No checks at all. AI runs commands and changes files, also outside this project, without asking.',
|
|
88
|
+
true,
|
|
89
|
+
],
|
|
47
90
|
];
|
|
48
|
-
const WORDS = new Map(
|
|
91
|
+
const WORDS = new Map(
|
|
92
|
+
MODE_WORDS.map(([id, label, group, hint, risky], i) => [
|
|
93
|
+
id,
|
|
94
|
+
{ label, group, hint, risky, order: i },
|
|
95
|
+
])
|
|
96
|
+
);
|
|
49
97
|
|
|
50
98
|
export const MODE_GROUP_LABEL = Object.freeze({
|
|
51
|
-
asks: 'AI asks
|
|
99
|
+
asks: 'AI asks first',
|
|
52
100
|
nochange: 'AI changes nothing',
|
|
53
|
-
free: '',
|
|
101
|
+
free: 'No safety net',
|
|
54
102
|
});
|
|
55
103
|
|
|
56
104
|
/**
|
|
57
105
|
* The modes the SESSION offers, in plain words. The agent decides which it offers; the rest stay hidden
|
|
58
106
|
* ("Skip every check" shows only where the agent allows it). An id Maude has no words for keeps the agent's
|
|
59
|
-
* own name rather than vanishing.
|
|
107
|
+
* own name (and its own description as the hint) rather than vanishing.
|
|
60
108
|
*/
|
|
61
109
|
export function modeOptions(modes) {
|
|
62
110
|
const list = modes?.availableModes ?? [];
|
|
@@ -70,6 +118,8 @@ export function modeOptions(modes) {
|
|
|
70
118
|
group: w?.group ?? 'asks',
|
|
71
119
|
order: w?.order ?? 100,
|
|
72
120
|
description: m.description ?? '',
|
|
121
|
+
hint: w?.hint ?? m.description ?? '',
|
|
122
|
+
risky: w?.risky ?? false,
|
|
73
123
|
};
|
|
74
124
|
})
|
|
75
125
|
.sort((a, b) => a.order - b.order);
|
|
@@ -496,6 +496,13 @@
|
|
|
496
496
|
line-height: var(--lh-xs);
|
|
497
497
|
color: var(--fg-2);
|
|
498
498
|
}
|
|
499
|
+
/* rc3-g: the mode that skips every check says so in the warning colour, not just in grey. */
|
|
500
|
+
.ai-adv-hint[data-risky] {
|
|
501
|
+
color: var(--status-error-text);
|
|
502
|
+
}
|
|
503
|
+
.ai-adv-select[data-risky] {
|
|
504
|
+
box-shadow: inset 0 0 0 1px var(--status-error-text);
|
|
505
|
+
}
|
|
499
506
|
.ai-adv-val {
|
|
500
507
|
font-size: var(--type-xs);
|
|
501
508
|
color: var(--fg-2);
|
|
@@ -31,6 +31,25 @@
|
|
|
31
31
|
}
|
|
32
32
|
.ai-working-main {
|
|
33
33
|
overflow-wrap: anywhere;
|
|
34
|
+
/* rc3-h (issue 182): one line — a long name ends in an ellipsis instead of growing the row */
|
|
35
|
+
display: block;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
text-overflow: ellipsis;
|
|
38
|
+
white-space: nowrap;
|
|
39
|
+
}
|
|
40
|
+
/* a new phrase (the span re-mounts on change) eases in; reduced motion: just the text change */
|
|
41
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
42
|
+
.ai-working-main {
|
|
43
|
+
animation: ai-working-swap var(--dur-flip) var(--ease-out, ease-out);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
@keyframes ai-working-swap {
|
|
47
|
+
from {
|
|
48
|
+
opacity: 0.35;
|
|
49
|
+
}
|
|
50
|
+
to {
|
|
51
|
+
opacity: 1;
|
|
52
|
+
}
|
|
34
53
|
}
|
|
35
54
|
.ai-step {
|
|
36
55
|
color: var(--fg-1);
|
|
@@ -125,9 +125,13 @@ export async function relayAiSend(island, d, env = {}) {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
let field = composerField(island);
|
|
128
|
-
|
|
128
|
+
// rc3-f (issue #181): while Claude is not connected the header draws no New chat (chat-header.jsx). The open
|
|
129
|
+
// chat then IS the place for the sentence when its field is empty — waiting for a New chat that never comes
|
|
130
|
+
// dropped a Home prompt on a fresh Mac. A draft the person is typing is still never overwritten.
|
|
131
|
+
const newBtn = d.newChat ? island.querySelector('[data-testid="ai-chat-new"]') : null;
|
|
132
|
+
if (d.newChat && newBtn) {
|
|
129
133
|
const before = field;
|
|
130
|
-
|
|
134
|
+
newBtn.click();
|
|
131
135
|
field = await until(() => {
|
|
132
136
|
const f = composerField(island);
|
|
133
137
|
return f && f !== before ? f : null;
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
// connectClaude({ fetchImpl, sleep, signal, onPhase }) → { ok: true } | { ok: false, reason }
|
|
6
6
|
//
|
|
7
7
|
// Phases: 'installing' · 'waiting' (for the browser). Cancel = abort the signal (the sign-in is withdrawn).
|
|
8
|
+
// `onPhase(phase, info)`: for 'installing', `info.startedAt` (ms) is when the install began — the server's own
|
|
9
|
+
// clock when it says so, so a sheet that joins a running install shows the real elapsed time.
|
|
10
|
+
// rc3-f (issue #181): a click while an install already runs JOINS it (the server answers 409 "already in
|
|
11
|
+
// progress"); it is never a dead-end error.
|
|
8
12
|
// Pure of React so test/v2-ai-needs-you.test.ts drives it with a scripted fetch.
|
|
9
13
|
|
|
10
14
|
const SIGNIN_POLL_MS = 2000;
|
|
@@ -38,21 +42,38 @@ export async function connectClaude({
|
|
|
38
42
|
if (first?.status === 'present' && !force) return { ok: true };
|
|
39
43
|
|
|
40
44
|
if (first?.action === 'install' && !force) {
|
|
41
|
-
|
|
45
|
+
const installState = () =>
|
|
46
|
+
fetchImpl('/_api/claude/install-status')
|
|
47
|
+
.then(json)
|
|
48
|
+
.catch(() => null);
|
|
49
|
+
const startedAtOf = (state) =>
|
|
50
|
+
typeof state?.startedAt === 'number' && Number.isFinite(state.startedAt)
|
|
51
|
+
? state.startedAt
|
|
52
|
+
: now();
|
|
42
53
|
const started = await post('/_api/claude/install');
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
let startedAt = now();
|
|
55
|
+
if (!started?.ok) {
|
|
56
|
+
// Already running (an earlier click, another window, a sheet that was closed): join it.
|
|
57
|
+
const state = await installState();
|
|
58
|
+
if (state?.phase !== 'running')
|
|
59
|
+
return { ok: false, reason: started?.reason || 'Could not start the installer.' };
|
|
60
|
+
startedAt = startedAtOf(state);
|
|
61
|
+
}
|
|
62
|
+
onPhase('installing', { startedAt });
|
|
45
63
|
let deadline = now() + INSTALL_MAX_MS;
|
|
46
64
|
for (;;) {
|
|
47
65
|
if (cancelled()) return { ok: false, reason: 'cancelled' };
|
|
48
|
-
if (now() > deadline)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
if (now() > deadline)
|
|
67
|
+
return {
|
|
68
|
+
ok: false,
|
|
69
|
+
reason: 'Could not tell how the Claude Code install is going. Try again.',
|
|
70
|
+
};
|
|
71
|
+
const state = await installState();
|
|
52
72
|
if (state?.phase === 'running')
|
|
53
73
|
deadline = now() + INSTALL_MAX_MS; // progressing: never cut off
|
|
54
74
|
else if (state?.phase === 'done') {
|
|
55
|
-
if (!state.ok)
|
|
75
|
+
if (!state.ok)
|
|
76
|
+
return { ok: false, reason: state.reason || 'Claude Code did not install. Try again.' };
|
|
56
77
|
break;
|
|
57
78
|
}
|
|
58
79
|
await sleep(INSTALL_POLL_MS);
|
|
@@ -520,6 +520,24 @@
|
|
|
520
520
|
font-size: var(--type-xs);
|
|
521
521
|
color: var(--status-error-text);
|
|
522
522
|
}
|
|
523
|
+
/* rc3-f: the setup's live status line (what runs, how long, what is next) */
|
|
524
|
+
.ai-conn-b .ai-conn-prog {
|
|
525
|
+
padding: var(--space-2) var(--space-3);
|
|
526
|
+
border-radius: var(--radius-md);
|
|
527
|
+
background: var(--spark-muted);
|
|
528
|
+
font-size: var(--type-xs);
|
|
529
|
+
line-height: var(--lh-xs);
|
|
530
|
+
color: var(--fg-1);
|
|
531
|
+
}
|
|
532
|
+
.ai-conn-prog strong {
|
|
533
|
+
color: var(--fg-0);
|
|
534
|
+
font-weight: var(--w-semibold);
|
|
535
|
+
font-variant-numeric: tabular-nums;
|
|
536
|
+
}
|
|
537
|
+
.ai-conn-step {
|
|
538
|
+
display: block;
|
|
539
|
+
color: var(--fg-2);
|
|
540
|
+
}
|
|
523
541
|
.ai-conn-a {
|
|
524
542
|
display: flex;
|
|
525
543
|
justify-content: flex-end;
|
|
@@ -298,6 +298,16 @@ export function problemModel(error) {
|
|
|
298
298
|
verb: null,
|
|
299
299
|
};
|
|
300
300
|
}
|
|
301
|
+
if (error.code === 'run-refused') {
|
|
302
|
+
// rc2-e — the lease home refused the run before any turn (acp/index.ts `refusedWords`). Nothing ran, so
|
|
303
|
+
// nothing changed; no verb: the same ask would be refused again — the words say what to change.
|
|
304
|
+
return {
|
|
305
|
+
code: 'run-refused',
|
|
306
|
+
title: message || 'AI could not start on this. Ask again.',
|
|
307
|
+
detail: 'Nothing changed.',
|
|
308
|
+
verb: null,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
301
311
|
// An uncoded error is the v1 connection-problem card (Feed.jsx ErrorCard, `chat-error-card`): it keeps its place.
|
|
302
312
|
return null;
|
|
303
313
|
}
|
|
@@ -30,6 +30,8 @@ import {
|
|
|
30
30
|
ringsFor,
|
|
31
31
|
} from './runs-model.js';
|
|
32
32
|
import { getRunsStore } from './runs-store.js';
|
|
33
|
+
import { targetRings } from './activity-line.js';
|
|
34
|
+
import { getActivityStore } from './activity-store.js';
|
|
33
35
|
|
|
34
36
|
const FRAME = 'iframe[data-testid="canvas-frame"]';
|
|
35
37
|
|
|
@@ -37,6 +39,8 @@ export function createRingsLane({
|
|
|
37
39
|
store,
|
|
38
40
|
// S5.15 — "Made by AI" (made-by-ai.js): settled rings that last until the next person's change
|
|
39
41
|
madeByAi = getMadeByAiStore(),
|
|
42
|
+
// rc3-h (#182) — the artboard the chat's in-flight edit names, ringed before the write lands
|
|
43
|
+
activity = getActivityStore(),
|
|
40
44
|
doc = globalThis.document,
|
|
41
45
|
win = globalThis.window,
|
|
42
46
|
} = {}) {
|
|
@@ -54,7 +58,11 @@ export function createRingsLane({
|
|
|
54
58
|
if (!origin) return;
|
|
55
59
|
const { view, done } = store.getSnapshot();
|
|
56
60
|
const file = frame.getAttribute('data-path') || frame.dataset?.path || '';
|
|
57
|
-
const
|
|
61
|
+
const live = {
|
|
62
|
+
...targetRings(activity?.get?.(), file),
|
|
63
|
+
...ringsFor(view, { activeCanvas: file }),
|
|
64
|
+
};
|
|
65
|
+
const artboards = mergeRings(live, {
|
|
58
66
|
...madeByAiRings(madeByAi?.getSnapshot(), file),
|
|
59
67
|
...doneRings(Object.keys(done)),
|
|
60
68
|
});
|
|
@@ -116,6 +124,7 @@ export function createRingsLane({
|
|
|
116
124
|
}
|
|
117
125
|
const unsub = store.subscribe(onTick);
|
|
118
126
|
const unsubMade = madeByAi?.subscribe(tellAll);
|
|
127
|
+
const unsubActivity = activity?.subscribe?.(tellAll);
|
|
119
128
|
const onMessage = (e) => {
|
|
120
129
|
const dgn = e.data?.dgn;
|
|
121
130
|
if (dgn !== 'loaded' && dgn !== 'canvas-rendered') return;
|
|
@@ -133,6 +142,7 @@ export function createRingsLane({
|
|
|
133
142
|
clearTimeout(expiryTimer);
|
|
134
143
|
unsub();
|
|
135
144
|
unsubMade?.();
|
|
145
|
+
unsubActivity?.();
|
|
136
146
|
win?.removeEventListener?.('message', onMessage);
|
|
137
147
|
};
|
|
138
148
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// client/v2/ai/use-activity-line.js — rc3-h (#182): feeds the chat's live stream into the activity line
|
|
2
|
+
// (activity-line.js) and re-renders only when what it shows changes — a waiting swap, the idle fallback, a
|
|
3
|
+
// new announcement. While `live` is false the line is empty and the canvas target is let go.
|
|
4
|
+
|
|
5
|
+
import { useEffect, useRef, useState } from 'react';
|
|
6
|
+
import { createActivityLine } from './activity-line.js';
|
|
7
|
+
import { getActivityStore } from './activity-store.js';
|
|
8
|
+
|
|
9
|
+
const EMPTY = { text: null, step: null, target: null, announce: null };
|
|
10
|
+
const sameView = (a, b) =>
|
|
11
|
+
a.text === b.text &&
|
|
12
|
+
a.step === b.step &&
|
|
13
|
+
a.target === b.target &&
|
|
14
|
+
(a.announce?.id ?? null) === (b.announce?.id ?? null);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {{ onTurnFrame?: (fn: (frame: any) => void) => () => void } | null} conn
|
|
18
|
+
* @param {boolean} live a turn or run of this chat is working
|
|
19
|
+
* @param {{ designRel?: string, labels?: Map<string, Array<{id: string, label: string}>>, store?: any,
|
|
20
|
+
* now?: () => number }} [o]
|
|
21
|
+
*/
|
|
22
|
+
export function useActivityLine(conn, live, o = {}) {
|
|
23
|
+
const { designRel = '.design', labels = null } = o;
|
|
24
|
+
const store = o.store ?? getActivityStore();
|
|
25
|
+
const now = o.now ?? Date.now;
|
|
26
|
+
const lineRef = useRef(null);
|
|
27
|
+
if (!lineRef.current) lineRef.current = createActivityLine();
|
|
28
|
+
const ctxRef = useRef(null);
|
|
29
|
+
ctxRef.current = { designRel, labelsFor: (f) => labels?.get?.(f) ?? [] };
|
|
30
|
+
const liveRef = useRef(live);
|
|
31
|
+
liveRef.current = live;
|
|
32
|
+
const [view, setView] = useState(EMPTY);
|
|
33
|
+
const [wake, setWake] = useState(0);
|
|
34
|
+
const viewRef = useRef(EMPTY);
|
|
35
|
+
|
|
36
|
+
const publish = () => {
|
|
37
|
+
const v = liveRef.current ? lineRef.current.view(now()) : EMPTY;
|
|
38
|
+
if (!sameView(v, viewRef.current)) {
|
|
39
|
+
viewRef.current = v;
|
|
40
|
+
setView(v);
|
|
41
|
+
}
|
|
42
|
+
store.set(liveRef.current ? v.target : null);
|
|
43
|
+
};
|
|
44
|
+
const publishRef = useRef(publish);
|
|
45
|
+
publishRef.current = publish;
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!conn?.onTurnFrame) return undefined;
|
|
49
|
+
return conn.onTurnFrame((frame) => {
|
|
50
|
+
if (frame?.t === 'update') lineRef.current.feed(frame.update, now(), ctxRef.current);
|
|
51
|
+
publishRef.current();
|
|
52
|
+
setWake((n) => n + 1);
|
|
53
|
+
});
|
|
54
|
+
}, [conn, now]);
|
|
55
|
+
|
|
56
|
+
// a run that ended, failed or was stopped: forget it all
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (!live) lineRef.current.reset();
|
|
59
|
+
publishRef.current();
|
|
60
|
+
}, [live]);
|
|
61
|
+
|
|
62
|
+
// wake when the view changes by itself (a waiting swap, the idle fallback, an announcement)
|
|
63
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: `wake` re-arms the timer after every event
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (!live) return undefined;
|
|
66
|
+
const at = lineRef.current.nextAt(now());
|
|
67
|
+
if (at === null) return undefined;
|
|
68
|
+
const id = setTimeout(
|
|
69
|
+
() => {
|
|
70
|
+
publishRef.current();
|
|
71
|
+
setWake((n) => n + 1);
|
|
72
|
+
},
|
|
73
|
+
Math.max(16, at - now())
|
|
74
|
+
);
|
|
75
|
+
return () => clearTimeout(id);
|
|
76
|
+
}, [live, wake, view, now]);
|
|
77
|
+
|
|
78
|
+
useEffect(() => () => store.set(null), [store]);
|
|
79
|
+
|
|
80
|
+
return view;
|
|
81
|
+
}
|
|
@@ -19,6 +19,7 @@ import { useEffect, useRef, useState } from 'react';
|
|
|
19
19
|
import { TEMPLATES } from '../../../annotations/templates.ts';
|
|
20
20
|
import { v2Scope } from './v2-scope.js';
|
|
21
21
|
import { reasonProps } from '../access/disabled-reason.js';
|
|
22
|
+
import { onCanvasPointer } from '../shell/canvas-pointer.js';
|
|
22
23
|
|
|
23
24
|
/** The columns of the tile grid (canvas 15 `.an-tpl-g`). */
|
|
24
25
|
export const TEMPLATE_COLUMNS = 4;
|
|
@@ -118,9 +119,12 @@ export default function TemplatesPanel({
|
|
|
118
119
|
const onBlur = () => onClose();
|
|
119
120
|
document.addEventListener('pointerdown', onDown, true);
|
|
120
121
|
window.addEventListener('blur', onBlur);
|
|
122
|
+
// rc3 r4-12 — a press in the canvas, told over the dgn bridge (WebKit gives this window no blur for it)
|
|
123
|
+
const offCanvas = onCanvasPointer(onBlur);
|
|
121
124
|
return () => {
|
|
122
125
|
document.removeEventListener('pointerdown', onDown, true);
|
|
123
126
|
window.removeEventListener('blur', onBlur);
|
|
127
|
+
offCanvas();
|
|
124
128
|
};
|
|
125
129
|
}, [anchor, onClose]);
|
|
126
130
|
|
|
@@ -34,7 +34,7 @@ export function KindsChip({ value, onChange }) {
|
|
|
34
34
|
document.addEventListener('keydown', onKey, true);
|
|
35
35
|
return () => document.removeEventListener('keydown', onKey, true);
|
|
36
36
|
}, [open]);
|
|
37
|
-
// a click anywhere else closes it — also a click into the canvas (another origin
|
|
37
|
+
// a click anywhere else closes it — also a click into the canvas (another origin, told over the dgn bridge)
|
|
38
38
|
useDismissOutside(open, root, () => setOpen(false));
|
|
39
39
|
return (
|
|
40
40
|
<span className="lp-kinds" ref={root}>
|
|
@@ -22,6 +22,22 @@ const SAID = {
|
|
|
22
22
|
invalid: 'Not placed. That picture does not fit there; try another.',
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
// rc3 walk (r4-2) — a video dropped onto a photo was refused as a "picture". The refusal names what was dropped: a
|
|
26
|
+
// video (the extensions the shell previews as video, client/shell/util.js PREVIEW_KIND_RULES), or neutrally for a mix.
|
|
27
|
+
const VIDEO_PATH = /\.(mp4|webm|mov|m4v)$/i;
|
|
28
|
+
const INVALID_VIDEO = 'Not placed. That video does not fit there; try another.';
|
|
29
|
+
const INVALID_MIXED = 'Not placed. That does not fit there; try another.';
|
|
30
|
+
|
|
31
|
+
/** The words for a refusal `code`, for the files `list` that were being placed. */
|
|
32
|
+
export function refusalWords(code, list = []) {
|
|
33
|
+
if (code === 'invalid' && list.length) {
|
|
34
|
+
const videos = list.filter((p) => typeof p === 'string' && VIDEO_PATH.test(p)).length;
|
|
35
|
+
if (videos === list.length) return INVALID_VIDEO;
|
|
36
|
+
if (videos > 0) return INVALID_MIXED;
|
|
37
|
+
}
|
|
38
|
+
return SAID[code];
|
|
39
|
+
}
|
|
40
|
+
|
|
25
41
|
/**
|
|
26
42
|
* "Placed 6 photos in Fotky ze zápasu. They're in Assets too." — the line a placement says (12 · ia-placed). The same words
|
|
27
43
|
* the drop says (`editing/finder-drop-model.ts` placedLine; pinned equal in p8-c9-assets.test.tsx), kept here so the shell
|
|
@@ -100,7 +116,10 @@ export async function placeAsset(req, opts = {}) {
|
|
|
100
116
|
created: Array.isArray(body.created) ? body.created : [],
|
|
101
117
|
};
|
|
102
118
|
}
|
|
103
|
-
return {
|
|
119
|
+
return {
|
|
120
|
+
ok: false,
|
|
121
|
+
message: refusalWords(body?.code, list) ?? body?.message ?? 'Not placed; try again.',
|
|
122
|
+
};
|
|
104
123
|
}
|
|
105
124
|
|
|
106
125
|
/**
|
|
@@ -75,7 +75,7 @@ export function AssetTileMenu({ state, items, onSelect, onClose }) {
|
|
|
75
75
|
document.addEventListener('keydown', onKey, true);
|
|
76
76
|
return () => document.removeEventListener('keydown', onKey, true);
|
|
77
77
|
}, [state, onClose]);
|
|
78
|
-
// a click anywhere else closes it — also a click into the canvas (another origin
|
|
78
|
+
// a click anywhere else closes it — also a click into the canvas (another origin, told over the dgn bridge)
|
|
79
79
|
useDismissOutside(!!state, ref, () => onClose());
|
|
80
80
|
|
|
81
81
|
if (!state) return null;
|
|
@@ -23,6 +23,7 @@ import { useFold } from '../fold/use-fold.js';
|
|
|
23
23
|
import { KindChips } from '../kinds/KindChips.jsx';
|
|
24
24
|
import { countByKind, isFilterKind, noCanvasesOfKind } from '../kinds/kind-filter-model.js';
|
|
25
25
|
import { clearKindFilter, useKindFilter } from '../kinds/kind-filter-store.js';
|
|
26
|
+
import { onCanvasPointer } from '../shell/canvas-pointer.js';
|
|
26
27
|
import { nativeDoors } from '../shell/native-doors.js';
|
|
27
28
|
import { PANEL_NONE_FOOT, PanelNoCanvases } from '../create/empty-project.jsx';
|
|
28
29
|
import { AskButton, Empty } from '../empty/index.js';
|
|
@@ -389,15 +390,18 @@ export function CanvasesPanel({
|
|
|
389
390
|
setSortMenu(null);
|
|
390
391
|
if (e.type === 'keydown') sortButton()?.focus();
|
|
391
392
|
};
|
|
392
|
-
// a click into the canvas (another origin) never reaches this document
|
|
393
|
+
// a click into the canvas (another origin) never reaches this document: the canvas tells the shell over the dgn
|
|
394
|
+
// bridge (rc3 r4-12 — the packaged app's WebKit gives no window blur for it); Chromium also blurs the window
|
|
393
395
|
const away = () => setSortMenu(null);
|
|
394
396
|
document.addEventListener('pointerdown', close);
|
|
395
397
|
document.addEventListener('keydown', close);
|
|
396
398
|
window.addEventListener('blur', away);
|
|
399
|
+
const offCanvas = onCanvasPointer(away);
|
|
397
400
|
return () => {
|
|
398
401
|
document.removeEventListener('pointerdown', close);
|
|
399
402
|
document.removeEventListener('keydown', close);
|
|
400
403
|
window.removeEventListener('blur', away);
|
|
404
|
+
offCanvas();
|
|
401
405
|
};
|
|
402
406
|
}, [sortMenu]);
|
|
403
407
|
// opening it takes the focus into the menu (the checked choice), so the keys have somewhere to land
|
|
@@ -82,8 +82,10 @@ export function CanvasRowMenu({ state, items, targets, onSelect, onPick, onClose
|
|
|
82
82
|
document.addEventListener('keydown', onKey, true);
|
|
83
83
|
return () => document.removeEventListener('keydown', onKey, true);
|
|
84
84
|
}, [state, view, onClose]);
|
|
85
|
-
// a click anywhere else closes it — also a click into the canvas (another origin), which
|
|
86
|
-
|
|
85
|
+
// a click anywhere else closes it — also a click into the canvas (another origin), which tells the shell over the
|
|
86
|
+
// dgn bridge (rc3 r4-12: the packaged app's WebKit gives no window blur for it). The focus stays where the click
|
|
87
|
+
// put it — handing it back to ⋯ would take it out of the canvas the person just clicked; esc still gives it back.
|
|
88
|
+
useDismissOutside(!!state, ref, () => onClose(false));
|
|
87
89
|
|
|
88
90
|
if (!state) return null;
|
|
89
91
|
const style = placed
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// client/v2/empty/ai-drafting.jsx — rc3-h (#182): an EMPTY canvas reacts the moment a run of yours starts on it.
|
|
2
|
+
//
|
|
3
|
+
// Before AI writes anything the empty canvas used to keep inviting "Ask AI for a first draft" while the run worked
|
|
4
|
+
// — nothing moved for a minute. Now the invitation steps aside for the board's ghost (01 cf-ai-drafting: a dashed
|
|
5
|
+
// spark outline, "Mobile — next"): where the first artboard will land, "AI is drafting…" above it, and the AI
|
|
6
|
+
// cursor on it (_kit `aiCursor`, the spark arrow). It goes when the run ends, fails or is stopped, and when the real
|
|
7
|
+
// artboard lands (the canvas counts one). Shell-side over the canvas pane, like the empty-canvas card it replaces:
|
|
8
|
+
// no message into the untrusted canvas, no route.
|
|
9
|
+
//
|
|
10
|
+
// Decorative (`aria-hidden`): the AI chat's working line + its polite region say the same words to a screen reader.
|
|
11
|
+
// Reduced motion: the pulse and the cursor's drift stop; the ghost and the cursor stay.
|
|
12
|
+
|
|
13
|
+
import { ownRunWorkingOn, TAG_NEEDS_YOU } from '../ai/runs-model.js';
|
|
14
|
+
import { SparkGlyph } from './ask-button.jsx';
|
|
15
|
+
|
|
16
|
+
export const DRAFTING_LABEL = 'AI is drafting…';
|
|
17
|
+
|
|
18
|
+
const LIVE = new Set(['starting', 'running']);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `null`, or what the ghost says. A run of yours is working on THIS canvas (its scope or a lease, or an edit
|
|
22
|
+
* that names it) and the canvas has reported no artboards (`count` 0 — null while it has not said: no flash).
|
|
23
|
+
*
|
|
24
|
+
* @param {{ view: any, activePath: string|null, designRel?: string, count: number|null|undefined,
|
|
25
|
+
* target?: { file: string, artboard: string, label: string, adding?: boolean } | null }} f
|
|
26
|
+
* @returns {{ label: string, waiting: boolean } | null}
|
|
27
|
+
*/
|
|
28
|
+
export function draftingPresence(f) {
|
|
29
|
+
if (f.count !== 0 || !f.activePath) return null;
|
|
30
|
+
const designRel = f.designRel || '.design';
|
|
31
|
+
const mine = (f.view?.mine || []).filter((r) => LIVE.has(r?.state) || r?.state === 'needs-you');
|
|
32
|
+
if (!mine.length) return null;
|
|
33
|
+
const named = !!f.target && f.target.file === f.activePath;
|
|
34
|
+
if (!ownRunWorkingOn(f.view, f.activePath, designRel) && !named) return null;
|
|
35
|
+
const working = mine.some((r) => LIVE.has(r.state));
|
|
36
|
+
if (!working) return { label: TAG_NEEDS_YOU, waiting: true };
|
|
37
|
+
const adding =
|
|
38
|
+
named && f.target.adding && f.target.label ? `AI is drawing ${f.target.label}` : null;
|
|
39
|
+
return { label: adding || DRAFTING_LABEL, waiting: false };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The ghost, the label above it and the AI cursor, centred on the free canvas (`centre`, px from the left). */
|
|
43
|
+
export function AiDrafting({ label, centre, waiting = false }) {
|
|
44
|
+
return (
|
|
45
|
+
<div className="es-host" style={{ '--es-cx': `${centre}px` }}>
|
|
46
|
+
<div
|
|
47
|
+
className="es-aid"
|
|
48
|
+
data-testid="ai-drafting"
|
|
49
|
+
data-waiting={waiting ? 'true' : undefined}
|
|
50
|
+
aria-hidden="true"
|
|
51
|
+
>
|
|
52
|
+
<span className="es-aid-l" data-testid="ai-drafting-label">
|
|
53
|
+
<SparkGlyph size={10} />
|
|
54
|
+
{label}
|
|
55
|
+
</span>
|
|
56
|
+
<span className="es-aid-ghost" data-testid="ai-drafting-ghost">
|
|
57
|
+
<span className="es-aid-page">
|
|
58
|
+
<i />
|
|
59
|
+
<i />
|
|
60
|
+
<i />
|
|
61
|
+
</span>
|
|
62
|
+
</span>
|
|
63
|
+
<span className="es-aid-cur" data-testid="ai-drafting-cursor">
|
|
64
|
+
<svg width="14" height="16" viewBox="0 0 14 16" aria-hidden="true">
|
|
65
|
+
<path
|
|
66
|
+
d="M1 1l11 6.2-4.7 1.3L5.6 14z"
|
|
67
|
+
fill="currentColor"
|
|
68
|
+
stroke="var(--bg-0)"
|
|
69
|
+
strokeWidth="1"
|
|
70
|
+
strokeLinejoin="round"
|
|
71
|
+
/>
|
|
72
|
+
</svg>
|
|
73
|
+
<span className="es-aid-cur-l">AI</span>
|
|
74
|
+
</span>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
}
|