@1agh/maude 2.0.2 → 2.0.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 (154) hide show
  1. package/README.md +6 -5
  2. package/apps/studio/access/request.ts +0 -1
  3. package/apps/studio/acp/adapter-stderr.ts +43 -13
  4. package/apps/studio/acp/background-tasks.ts +155 -0
  5. package/apps/studio/acp/bridge.ts +44 -5
  6. package/apps/studio/acp/connected-fact.ts +15 -4
  7. package/apps/studio/acp/index.ts +14 -5
  8. package/apps/studio/actions/agents.ts +5 -0
  9. package/apps/studio/actions/defs/view.ts +12 -0
  10. package/apps/studio/actions.manifest.json +13 -1
  11. package/apps/studio/actions.parity.json +7 -1
  12. package/apps/studio/api.ts +31 -24
  13. package/apps/studio/asset-placeholder.tsx +157 -62
  14. package/apps/studio/bin/_png-playwright.mjs +10 -1
  15. package/apps/studio/bin/_pw-launch.mjs +14 -0
  16. package/apps/studio/bin/_thumbs-playwright.mjs +4 -1
  17. package/apps/studio/boot-progress.ts +31 -0
  18. package/apps/studio/bridge/dgn-protocol.ts +34 -4
  19. package/apps/studio/canvas-build-sandbox.ts +275 -42
  20. package/apps/studio/canvas-build-worker.ts +10 -0
  21. package/apps/studio/canvas-create.ts +24 -0
  22. package/apps/studio/canvas-module-cache.ts +93 -0
  23. package/apps/studio/canvas-source/errors.ts +39 -0
  24. package/apps/studio/canvas-source/waiting.ts +290 -0
  25. package/apps/studio/client/actions/shell-key-handlers.js +5 -0
  26. package/apps/studio/client/app.jsx +22 -9
  27. package/apps/studio/client/github.js +23 -3
  28. package/apps/studio/client/home/home-api.js +30 -19
  29. package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
  30. package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
  31. package/apps/studio/client/hooks/use-tabs.jsx +64 -35
  32. package/apps/studio/client/index-loader.ts +23 -3
  33. package/apps/studio/client/panels/ChatPanel.jsx +22 -37
  34. package/apps/studio/client/panels/DiffView.jsx +314 -248
  35. package/apps/studio/client/panels/TeamProjects.jsx +119 -69
  36. package/apps/studio/client/panels/acp-runtime.js +25 -0
  37. package/apps/studio/client/panels/chat-finish.js +66 -0
  38. package/apps/studio/client/shell/frame-cap.js +53 -0
  39. package/apps/studio/client/shell/viewport.jsx +9 -0
  40. package/apps/studio/client/styles/_index.css +2 -0
  41. package/apps/studio/client/tree/tree.jsx +48 -21
  42. package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
  43. package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
  44. package/apps/studio/client/v2/ai/ai-run.css +87 -3
  45. package/apps/studio/client/v2/ai/background-model.js +113 -0
  46. package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
  47. package/apps/studio/client/v2/ai/run-api.js +7 -3
  48. package/apps/studio/client/v2/ai/runs-store.js +2 -1
  49. package/apps/studio/client/v2/annotations/vote-store.js +11 -5
  50. package/apps/studio/client/v2/assets/asset-state-lane.js +176 -8
  51. package/apps/studio/client/v2/assets/assets-bus.js +10 -8
  52. package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
  53. package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
  54. package/apps/studio/client/v2/assets/missing-frame.jsx +8 -4
  55. package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
  56. package/apps/studio/client/v2/assets/spotlight.css +153 -0
  57. package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
  58. package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
  59. package/apps/studio/client/v2/assets/tile.jsx +3 -0
  60. package/apps/studio/client/v2/assets/use-assets.js +2 -1
  61. package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
  62. package/apps/studio/client/v2/canvases/covers.js +11 -5
  63. package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
  64. package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
  65. package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
  66. package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
  67. package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
  68. package/apps/studio/client/v2/canvases/use-pins.js +2 -1
  69. package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
  70. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
  71. package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
  72. package/apps/studio/client/v2/code/code.css +67 -0
  73. package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
  74. package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
  75. package/apps/studio/client/v2/create/name-dialog.css +10 -0
  76. package/apps/studio/client/v2/ds/advanced-host.jsx +5 -2
  77. package/apps/studio/client/v2/ds/make-host.jsx +5 -2
  78. package/apps/studio/client/v2/ds/off-system-host.jsx +5 -2
  79. package/apps/studio/client/v2/ds/truth-host.jsx +5 -2
  80. package/apps/studio/client/v2/empty/arriving.jsx +29 -12
  81. package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
  82. package/apps/studio/client/v2/empty/not-local.jsx +31 -1
  83. package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
  84. package/apps/studio/client/v2/export/last-finished.js +2 -1
  85. package/apps/studio/client/v2/export/native-save.js +44 -0
  86. package/apps/studio/client/v2/history/git-model.js +18 -4
  87. package/apps/studio/client/v2/history/git-parts.jsx +60 -42
  88. package/apps/studio/client/v2/history/history.css +6 -0
  89. package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
  90. package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
  91. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
  92. package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
  93. package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
  94. package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
  95. package/apps/studio/client/v2/search/search-recent.js +3 -1
  96. package/apps/studio/client/v2/search/search-remote.js +6 -4
  97. package/apps/studio/client/v2/settings/connections-model.js +1 -1
  98. package/apps/studio/client/v2/shell/menu-runner.js +1 -0
  99. package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
  100. package/apps/studio/client/v2/shell/recovery-store.js +2 -1
  101. package/apps/studio/client/v2/shell/served-routes.js +120 -0
  102. package/apps/studio/client/v2/shell/share-cluster-host.jsx +2 -1
  103. package/apps/studio/client/v2/shell/shell-activity.js +19 -0
  104. package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
  105. package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
  106. package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
  107. package/apps/studio/cloud/endpoints.ts +23 -1
  108. package/apps/studio/dist/client.bundle.js +798 -801
  109. package/apps/studio/dist/comment-mount.js +2 -2
  110. package/apps/studio/dist/styles.css +1 -1
  111. package/apps/studio/ds-assets.ts +138 -48
  112. package/apps/studio/editing/minimap-context.tsx +3 -3
  113. package/apps/studio/editing/page-activity.ts +251 -0
  114. package/apps/studio/editing/rotate-handle.tsx +9 -5
  115. package/apps/studio/editing/sticky-name.tsx +4 -4
  116. package/apps/studio/history/restore-artboard-action.ts +40 -0
  117. package/apps/studio/home/hub.ts +77 -175
  118. package/apps/studio/home/routes.ts +47 -8
  119. package/apps/studio/http.ts +117 -66
  120. package/apps/studio/index-flight.ts +40 -0
  121. package/apps/studio/managed-projects.ts +52 -24
  122. package/apps/studio/migrate/hub.ts +7 -1
  123. package/apps/studio/routes/asset-state.ts +12 -0
  124. package/apps/studio/routes/canvas-source.ts +44 -2
  125. package/apps/studio/routes/ds-assets.ts +8 -0
  126. package/apps/studio/routes/history.ts +28 -5
  127. package/apps/studio/routes/hub-signin.ts +115 -0
  128. package/apps/studio/routes/index.ts +4 -0
  129. package/apps/studio/routes/table.ts +7 -0
  130. package/apps/studio/routes/trash.ts +3 -0
  131. package/apps/studio/server.ts +11 -0
  132. package/apps/studio/sync/accepted-cold-start.ts +26 -3
  133. package/apps/studio/sync/accepted-link.ts +9 -4
  134. package/apps/studio/sync/asset-push.ts +8 -1
  135. package/apps/studio/sync/asset-state.ts +27 -2
  136. package/apps/studio/sync/code-module-consent.ts +74 -0
  137. package/apps/studio/sync/file-ledger.ts +35 -0
  138. package/apps/studio/sync/file-plane.ts +479 -84
  139. package/apps/studio/sync/hub-browser-signin.ts +377 -0
  140. package/apps/studio/sync/hub-text-undo.ts +30 -10
  141. package/apps/studio/sync/index.ts +73 -11
  142. package/apps/studio/sync/lfs-pointer.ts +137 -0
  143. package/apps/studio/sync/projection.ts +44 -2
  144. package/apps/studio/sync/pull-pacer.ts +160 -0
  145. package/apps/studio/sync/pull-priority.ts +119 -0
  146. package/apps/studio/sync/seed-progress.ts +47 -3
  147. package/apps/studio/sync/transaction-client.ts +71 -6
  148. package/apps/studio/sync/workspace-signin.ts +6 -256
  149. package/apps/studio/sync/writer-registry.ts +5 -1
  150. package/apps/studio/video-links-overlay.tsx +3 -2
  151. package/apps/studio/whats-new.json +63 -0
  152. package/cli/lib/design-help.gen.mjs +1 -1
  153. package/cli/lib/workspace-plan.mjs +14 -0
  154. package/package.json +8 -8
@@ -0,0 +1,199 @@
1
+ // client/v2/assets/spotlight.jsx — an Assets tile, large (2.0.4, issue #191; decision v2-204-asset-spotlight).
2
+ //
3
+ // A double-click on a tile (or Space on the picked one — the registry action `assets.spotlight`) opens its picture, clip or
4
+ // sound over the app. A picture fits the window, a clip plays with its controls, a sound plays too; anything else says its
5
+ // name and size. Under it: the file's name, path and size, and the rows the tile already offers. ← → walk the tiles the tab
6
+ // shows, esc or a click outside closes, and focus goes back to the tile. The window is modal: Tab stays inside it.
7
+ //
8
+ // `AssetSpotlight` is the pure render over the panel's state (spotlight-model.js holds the words and the order).
9
+
10
+ import { useId, useState } from 'react';
11
+ import { Kbd, StIcon } from '../../shell/icons.jsx';
12
+ import { portalToBody } from '../portal-scope.jsx';
13
+ import { useModalFocus } from '../shell/modal-focus.js';
14
+ import {
15
+ pathWords,
16
+ previewKind,
17
+ SPOTLIGHT_WORDS as W,
18
+ sizeLine,
19
+ stepIndex,
20
+ } from './spotlight-model.js';
21
+
22
+ /** The media for one asset. Keyed by path by the caller, so a step remounts it (a clip starts from its first frame). */
23
+ function Stage({ asset, url }) {
24
+ const kind = previewKind(asset);
25
+ const [broken, setBroken] = useState(false);
26
+ if (kind === 'image' && !broken)
27
+ return (
28
+ <img
29
+ className="v2-spot-img"
30
+ data-testid="spotlight-image"
31
+ src={url}
32
+ alt={asset.name}
33
+ draggable={false}
34
+ onError={() => setBroken(true)}
35
+ />
36
+ );
37
+ if (kind === 'video' && !broken)
38
+ return (
39
+ // biome-ignore lint/a11y/useMediaCaption: the person's own footage; captions are a sidecar of the clip, not of the library
40
+ <video
41
+ className="v2-spot-video"
42
+ data-testid="spotlight-video"
43
+ src={url}
44
+ controls
45
+ playsInline
46
+ preload="metadata"
47
+ onError={() => setBroken(true)}
48
+ />
49
+ );
50
+ if (kind === 'audio' && !broken)
51
+ return (
52
+ <div className="v2-spot-sound" data-testid="spotlight-sound">
53
+ <StIcon name="resolve" size={28} />
54
+ {/* biome-ignore lint/a11y/useMediaCaption: a sound has no captions to show */}
55
+ <audio src={url} controls preload="metadata" onError={() => setBroken(true)} />
56
+ </div>
57
+ );
58
+ // a font, or any file the window cannot draw: what it is, so the person knows it is the right one
59
+ return (
60
+ <div className="v2-spot-file" data-testid="spotlight-file">
61
+ <StIcon name="image" size={28} />
62
+ <p className="v2-spot-file-n">{asset.name}</p>
63
+ {sizeLine(asset) ? <p className="v2-spot-file-s">{sizeLine(asset)}</p> : null}
64
+ <p className="v2-spot-file-s">{broken ? W.failed : W.noPreview}</p>
65
+ </div>
66
+ );
67
+ }
68
+
69
+ /**
70
+ * @param {object} p
71
+ * @param {Array<{ path: string, name: string, kind: string, size?: number }>} p.items the tiles ← → walks, in the tab's order
72
+ * @param {number} p.index which one is showing
73
+ * @param {(path: string) => string} p.urlOf the SAME address the tile draws (main origin, read-only)
74
+ * @param {Array<{ id: string, label: string, keys?: string }>} [p.rows] the tile's own actions
75
+ * @param {(index: number) => void} p.onIndex
76
+ * @param {() => void} p.onClose esc, the close button and a click outside
77
+ * @param {(id: string) => void} [p.onRow]
78
+ */
79
+ export function AssetSpotlight({ items, index, urlOf, rows = [], onIndex, onClose, onRow }) {
80
+ const titleId = useId();
81
+ const ref = useModalFocus({ onClose });
82
+ const asset = items[index];
83
+ if (!asset) return null;
84
+ const n = items.length;
85
+ const step = (delta) => {
86
+ const to = stepIndex(index, delta, n);
87
+ if (to !== index) onIndex(to);
88
+ };
89
+ const onKeyDown = (e) => {
90
+ if (e.defaultPrevented || e.metaKey || e.ctrlKey || e.altKey) return;
91
+ // a focused clip or sound keeps its own arrows (seek); everything else steps
92
+ if (e.target?.closest?.('video, audio, input, select, textarea')) return;
93
+ if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
94
+ e.preventDefault();
95
+ e.stopPropagation();
96
+ step(e.key === 'ArrowRight' ? 1 : -1);
97
+ }
98
+ };
99
+ const path = pathWords(asset);
100
+ const size = sizeLine(asset);
101
+ return portalToBody(
102
+ <div className="v2-spot" data-testid="asset-spotlight" data-asset={asset.path}>
103
+ <div
104
+ className="v2-spot-scrim"
105
+ data-testid="spotlight-scrim"
106
+ aria-hidden="true"
107
+ onClick={onClose}
108
+ />
109
+ <div
110
+ ref={ref}
111
+ className="v2-spot-dialog"
112
+ role="dialog"
113
+ aria-modal="true"
114
+ aria-labelledby={titleId}
115
+ tabIndex={-1}
116
+ onKeyDown={onKeyDown}
117
+ >
118
+ <header className="v2-spot-head">
119
+ <h2 id={titleId} className="v2-spot-title" data-testid="spotlight-title">
120
+ {asset.name || W.fallbackName}
121
+ </h2>
122
+ <span className="v2-spot-pos" role="status" data-testid="spotlight-position">
123
+ {n > 1 ? W.position(index, n) : ''}
124
+ </span>
125
+ <button
126
+ type="button"
127
+ className="sh-iconbtn"
128
+ data-testid="spotlight-close"
129
+ aria-label={W.close}
130
+ onClick={onClose}
131
+ >
132
+ <StIcon name="x" size={14} />
133
+ </button>
134
+ </header>
135
+ {/* biome-ignore lint/a11y/noStaticElementInteractions lint/a11y/useKeyWithClickEvents: a click on the empty space is a pointer door; esc and the close button are the keyboard's */}
136
+ <div
137
+ className="v2-spot-stage"
138
+ data-testid="spotlight-stage"
139
+ onClick={(e) => {
140
+ // the empty space around the picture is "outside" too
141
+ if (e.target === e.currentTarget) onClose();
142
+ }}
143
+ >
144
+ <button
145
+ type="button"
146
+ className="sh-iconbtn v2-spot-nav v2-spot-nav--prev"
147
+ data-testid="spotlight-prev"
148
+ aria-label={W.previous}
149
+ disabled={index <= 0}
150
+ title={index <= 0 ? W.atFirst : undefined}
151
+ onClick={() => step(-1)}
152
+ >
153
+ <StIcon name="chevron-right" size={16} />
154
+ </button>
155
+ <Stage key={asset.path} asset={asset} url={urlOf(asset.path)} />
156
+ <button
157
+ type="button"
158
+ className="sh-iconbtn v2-spot-nav"
159
+ data-testid="spotlight-next"
160
+ aria-label={W.next}
161
+ disabled={index >= n - 1}
162
+ title={index >= n - 1 ? W.atLast : undefined}
163
+ onClick={() => step(1)}
164
+ >
165
+ <StIcon name="chevron-right" size={16} />
166
+ </button>
167
+ </div>
168
+ <footer className="v2-spot-foot">
169
+ <p className="v2-spot-meta" data-testid="spotlight-meta">
170
+ <span className="v2-spot-path" data-testid="spotlight-path">
171
+ {path}
172
+ </span>
173
+ {size ? (
174
+ <span className="v2-spot-size" data-testid="spotlight-size">
175
+ {size}
176
+ </span>
177
+ ) : null}
178
+ </p>
179
+ {rows.length ? (
180
+ <span className="v2-spot-rows">
181
+ {rows.map((r) => (
182
+ <button
183
+ key={r.id}
184
+ type="button"
185
+ className="btn btn--sm"
186
+ data-testid={`spotlight-row-${r.id}`}
187
+ onClick={() => onRow?.(r.id)}
188
+ >
189
+ {r.label}
190
+ {r.keys ? <Kbd>{r.keys}</Kbd> : null}
191
+ </button>
192
+ ))}
193
+ </span>
194
+ ) : null}
195
+ </footer>
196
+ </div>
197
+ </div>
198
+ );
199
+ }
@@ -1,6 +1,6 @@
1
1
  // client/v2/assets/tile-menu.jsx — the menu a right-click on a tile opens (S8.12; 12 · ia-assets-keys).
2
2
  //
3
- // "Place in MVP zápasu ↵", "Show details ⌘I", "Copy ⌘C" and Move to trash — the same actions the keys run (`assets.place`, `assets.details`,
3
+ // "Place in MVP zápasu ↵", "View larger Space", "Show details ⌘I", "Copy ⌘C" and Move to trash — the same actions the keys run (`assets.place`, `assets.details`,
4
4
  // through assets-bus.js), so the menu, ↵ and ⌘I are one code path. A viewer is offered Show details only; sound and video
5
5
  // are not placed from here (a clip goes on a video artboard's timeline). Reached by the right-click, the keyboard
6
6
  // (↑ ↓ walk, esc closes). Move to trash (S8.13) is an editor's: the studio takes the picture and its sidecars together.
@@ -23,6 +23,8 @@ export function tileMenuItems(asset, { readOnly = false, placeLabel = null, coun
23
23
  label: placeLabel ? `Place in ${placeLabel}` : 'Place',
24
24
  keys: '↵',
25
25
  });
26
+ // 2.0.4 (#191) — View larger (`assets.spotlight`): the same window a double-click opens; a read, so every role has it
27
+ items.push({ id: 'spotlight', label: 'View larger', keys: 'Space' });
26
28
  items.push({ id: 'details', label: 'Show details', keys: '⌘I' });
27
29
  // P8 round 7 (12 · ia-assets-keys) — Rename… (`assets.rename`): an editor's, one picture at a time
28
30
  if (!readOnly && count <= 1) items.push({ id: 'rename', label: 'Rename…' });
@@ -40,6 +40,8 @@ export function AssetTile({
40
40
  canDrag,
41
41
  onPick,
42
42
  onMenu,
43
+ // 2.0.4 (#191) — a double-click opens the tile large (spotlight.jsx); a tile with no `onOpen` ignores it
44
+ onOpen = undefined,
43
45
  caption = false,
44
46
  uploading = null,
45
47
  // 12 · ia-assets-find — the name (or tag) a search matched, on a gradient foot
@@ -62,6 +64,7 @@ export function AssetTile({
62
64
  uploading ? `${tileLabel(asset)}. ${uploadWords(asset.name, uploading)}` : tileLabel(asset)
63
65
  }
64
66
  onClick={(e) => onPick(asset.path, e)}
67
+ onDoubleClick={onOpen ? (e) => onOpen(asset.path, e) : undefined}
65
68
  onContextMenu={(e) => {
66
69
  onPick(asset.path, e, true);
67
70
  onMenu(e, asset);
@@ -7,6 +7,7 @@
7
7
 
8
8
  import { useCallback, useEffect, useRef, useState } from 'react';
9
9
  import { INDEX_CHANGED_EVENT } from '../canvases/use-canvas-index.js';
10
+ import { fetchIfServed } from '../shell/served-routes.js';
10
11
 
11
12
  const KINDS = new Set(['image', 'video', 'audio']);
12
13
 
@@ -70,7 +71,7 @@ export function usageWords(row) {
70
71
 
71
72
  async function readRows(get) {
72
73
  try {
73
- const r = await get('/_api/index?part=assets', { cache: 'no-store' });
74
+ const r = await fetchIfServed('/_api/index?part=assets', { cache: 'no-store' }, get);
74
75
  if (r.ok) {
75
76
  const j = await r.json();
76
77
  if (Array.isArray(j?.assets))
@@ -58,6 +58,7 @@ import { askForCovers } from './covers.js';
58
58
  import { siblingNames } from './rename-model.js';
59
59
  import { useRowSlots } from './row-slots.js';
60
60
  import { supportIcon, supportIndex } from './support-model.js';
61
+ import { useTrashGone, withoutGone } from './trash-queue.js';
61
62
  import { canvasMenuItems, CanvasRowMenu } from './row-menu.jsx';
62
63
  import { leftOutOf } from '../ds/update-model.js';
63
64
  import { SORT_BYS, SORT_LABELS, KIND_NOTE, sortControl } from './sort.js';
@@ -148,9 +149,19 @@ export function CanvasesPanel({
148
149
  }, []);
149
150
  // S11.9 — Canvases › Advanced › Show file names: each canvas row grows a second mono line
150
151
  const [showFileNames] = useViewPref(VIEW_PREF_KEYS.fileNames);
152
+ // #194 — a canvas the server has moved to the trash leaves the list at once, before the index re-reads
153
+ const trashGone = useTrashGone();
154
+ const listedGroups = useMemo(() => withoutGone(groups, trashGone), [groups, trashGone]);
151
155
  const tree = useMemo(
152
- () => buildTree({ groups, meta, designRel, opened: pins.opened, ghosts: slots.ghosts }),
153
- [groups, meta, designRel, pins.opened, slots.ghosts]
156
+ () =>
157
+ buildTree({
158
+ groups: listedGroups,
159
+ meta,
160
+ designRel,
161
+ opened: pins.opened,
162
+ ghosts: slots.ghosts,
163
+ }),
164
+ [listedGroups, meta, designRel, pins.opened, slots.ghosts]
154
165
  );
155
166
  const isOpen = expansion?.isOpen;
156
167
  // S7.24 — the kind filter chips (one filter for Canvases and Layers, kind-filter-store.js). Counts are over
@@ -4,6 +4,8 @@
4
4
  // the service queues every canvas's cover at background priority (never in front of a visible request) and
5
5
  // each finished one reaches the rows through the index (`index-changed`), so the pictures arrive one by one.
6
6
 
7
+ import { fetchIfServed } from '../shell/served-routes.js';
8
+
7
9
  let asked = false;
8
10
 
9
11
  /** POST /_api/thumbs/want { keys: [], background: true } — at most once per page load; a refusal is silent. */
@@ -14,11 +16,15 @@ export function askForCovers(fetchImpl) {
14
16
  if (typeof f !== 'function') return false;
15
17
  try {
16
18
  Promise.resolve(
17
- f('/_api/thumbs/want', {
18
- method: 'POST',
19
- headers: { 'content-type': 'application/json' },
20
- body: JSON.stringify({ keys: [], background: true }),
21
- })
19
+ fetchIfServed(
20
+ '/_api/thumbs/want',
21
+ {
22
+ method: 'POST',
23
+ headers: { 'content-type': 'application/json' },
24
+ body: JSON.stringify({ keys: [], background: true }),
25
+ },
26
+ f
27
+ )
22
28
  ).catch(() => {});
23
29
  } catch {
24
30
  /* no network, no pictures — the rows keep their small page */
@@ -0,0 +1,139 @@
1
+ // client/v2/canvases/folder-ask.js — #195 (2.0.4): what the tree's folder and file rows ask, and the words a
2
+ // refusal says.
3
+ //
4
+ // The report: "I can't add or rename folder" (desktop). The folder row's menu asked with `window.prompt`, and
5
+ // Tauri's WKWebView does not implement it — it returns null at once, so "New folder here" and "Rename folder"
6
+ // did nothing at all (and "Delete folder"'s `window.confirm` answered "no" the same way). Every one of them now
7
+ // asks in the shell's own centered dialog (`NameDialog`, the one "New canvas" uses), and a refusal is said
8
+ // under the field in plain words instead of failing silently.
9
+ //
10
+ // Pure: the dialog's words per ask, the client-side name check (the same rule as the server's — rename-model),
11
+ // and the line a failed request shows.
12
+
13
+ import { checkRename } from './rename-model.js';
14
+
15
+ /** CONTRACT §4: a dialog's title asks with the verb its primary button uses; the other button is Cancel. */
16
+ export const FOLDER_ASK_WORDS = Object.freeze({
17
+ /** a Can view / Can comment session, or a request the server refused for its role (403) */
18
+ role: 'Folders need Can edit. Ask a project owner for edit access.',
19
+ filesRole: 'Changing files needs Can edit. Ask a project owner for edit access.',
20
+ failed: {
21
+ 'new-folder': 'Could not make the folder. Nothing was changed. Try again.',
22
+ 'rename-folder': 'Could not rename the folder. Nothing was changed. Try again.',
23
+ 'trash-folder': 'Could not move the folder to the trash. Nothing was changed. Try again.',
24
+ 'rename-canvas': 'Could not rename. Nothing was changed. Try again.',
25
+ 'rename-file': 'Could not rename. Nothing was changed. Try again.',
26
+ 'trash-file': 'Could not move it to the trash. Nothing was changed. Try again.',
27
+ },
28
+ noGroup: 'There is no canvas folder to put a new folder in yet. Make a canvas first.',
29
+ });
30
+
31
+ const folderName = (p) =>
32
+ String(p || '')
33
+ .replace(/\/+$/, '')
34
+ .split('/')
35
+ .pop() || '';
36
+
37
+ /**
38
+ * The words of one ask. `ask` = { kind, path, name? }:
39
+ * new-folder path = the parent folder → Create folder in “<parent>”
40
+ * rename-folder path = the folder → Rename folder “<name>”
41
+ * rename-canvas path = the canvas, name = its name → Rename canvas
42
+ * rename-file path = the file, name = file name → Rename “<file>” (the extension stays)
43
+ * trash-folder path = the folder → Move “<name>” to the trash?
44
+ * trash-file path = the file, name = file name → Move “<file>” to the trash?
45
+ */
46
+ export function folderAskWords(ask) {
47
+ const name = ask?.name ?? folderName(ask?.path);
48
+ switch (ask?.kind) {
49
+ case 'new-folder':
50
+ return {
51
+ title: `Create folder in “${folderName(ask.path)}”`,
52
+ label: 'Folder name',
53
+ initial: 'Untitled folder',
54
+ confirm: 'Create',
55
+ busy: 'Creating…',
56
+ };
57
+ case 'rename-folder':
58
+ return {
59
+ title: `Rename folder “${name}”`,
60
+ label: 'Folder name',
61
+ initial: name,
62
+ confirm: 'Rename',
63
+ busy: 'Renaming…',
64
+ };
65
+ case 'rename-canvas':
66
+ return {
67
+ title: `Rename canvas “${name}”`,
68
+ label: 'Canvas name',
69
+ initial: name,
70
+ confirm: 'Rename',
71
+ busy: 'Renaming…',
72
+ };
73
+ case 'rename-file': {
74
+ const ext = name.includes('.') ? name.slice(name.lastIndexOf('.')) : '';
75
+ return {
76
+ title: `Rename “${name}”`,
77
+ label: ext ? `Name (stays ${ext})` : 'Name',
78
+ initial: ext ? name.slice(0, -ext.length) : name,
79
+ confirm: 'Rename',
80
+ busy: 'Renaming…',
81
+ };
82
+ }
83
+ case 'trash-folder':
84
+ return {
85
+ title: `Move “${name}” to the trash?`,
86
+ body: 'Every canvas inside moves to the trash, where you can bring it back. Empty folders inside are removed.',
87
+ confirm: 'Move to trash',
88
+ busy: 'Moving…',
89
+ };
90
+ case 'trash-file':
91
+ return {
92
+ title: `Move “${name}” to the trash?`,
93
+ body: 'You can bring it back from the Trash.',
94
+ confirm: 'Move to trash',
95
+ busy: 'Moving…',
96
+ };
97
+ default:
98
+ return null;
99
+ }
100
+ }
101
+
102
+ /** True for the asks that take a name (a NameDialog), false for the yes/no ones. */
103
+ export const asksForName = (ask) =>
104
+ ask?.kind === 'new-folder' ||
105
+ ask?.kind === 'rename-folder' ||
106
+ ask?.kind === 'rename-canvas' ||
107
+ ask?.kind === 'rename-file';
108
+
109
+ /**
110
+ * The typed name before anything is sent: the same rule the server holds (letters, numbers, spaces, - and _;
111
+ * not starting with _; 60 characters), so a refused name is said at once, with the suggestion.
112
+ * @returns {{ kind: 'keep' } | { kind: 'error', error: string } | { kind: 'send', name: string }}
113
+ */
114
+ export function checkAskName(ask, draft) {
115
+ const words = folderAskWords(ask);
116
+ const current = ask?.kind === 'new-folder' ? '' : (words?.initial ?? '');
117
+ const v = checkRename({ draft, current });
118
+ if (v.kind === 'rename') return { kind: 'send', name: v.name };
119
+ return v.kind === 'error' ? { kind: 'error', error: v.error } : { kind: 'keep' };
120
+ }
121
+
122
+ /**
123
+ * The line a failed folder/file request shows under the field (or in the yes/no dialog).
124
+ * `res` = { ok: false, status?, error?, network? } from the shell's request functions (use-tabs.jsx).
125
+ * The server's own words come back as they are (they are plain since #195 — canvas-create.ts FOLDER_WORDS,
126
+ * NAME_RULE); a role refusal, a lost connection or a bare status gets one plain sentence instead.
127
+ */
128
+ export function askFailure(kind, res) {
129
+ const fallback = FOLDER_ASK_WORDS.failed[kind] ?? FOLDER_ASK_WORDS.failed['new-folder'];
130
+ if (res?.status === 403)
131
+ return kind.endsWith('-file') || kind === 'rename-canvas'
132
+ ? FOLDER_ASK_WORDS.filesRole
133
+ : FOLDER_ASK_WORDS.role;
134
+ if (res?.network) return fallback;
135
+ const error = typeof res?.error === 'string' ? res.error.trim() : '';
136
+ // a bare status ("error 500"), or a lower-case developer string from an older server, is not for people
137
+ if (!error || /^error \d+$/.test(error) || /^[a-z"]/.test(error)) return fallback;
138
+ return error;
139
+ }
@@ -0,0 +1,150 @@
1
+ // client/v2/canvases/folder-dialogs.jsx — #195 (2.0.4): the tree's folder and file asks, in the shell's own
2
+ // centered dialog instead of `window.prompt` / `window.confirm` (both are no-ops in Tauri's WKWebView, which is
3
+ // why "New folder here" and "Rename folder" did nothing on the desktop).
4
+ //
5
+ // `TreeAsk` owns one ask at a time: the name check before anything is sent, the busy state while the request
6
+ // runs, and the refusal under the field (folder-ask.js `askFailure`). `run(ask, name?)` is the request; it
7
+ // answers `{ ok, status?, error?, network? }`.
8
+
9
+ import { useCallback, useId, useRef, useState } from 'react';
10
+
11
+ import NameDialog from '../create/NameDialog.jsx';
12
+ import { useModalFocus } from '../shell/modal-focus.js';
13
+ import { askFailure, asksForName, checkAskName, folderAskWords } from './folder-ask.js';
14
+
15
+ /**
16
+ * A yes/no ask on the same material as NameDialog: title, one line, Cancel and the verb. `over` lifts it above a
17
+ * modal sheet that is already open (the version diff) — it is the shell's replacement for `window.confirm`.
18
+ */
19
+ export function ConfirmAskDialog({
20
+ title,
21
+ body,
22
+ confirm,
23
+ busyLabel,
24
+ busy,
25
+ error,
26
+ over = false,
27
+ onConfirm,
28
+ onCancel,
29
+ }) {
30
+ const okRef = useRef(null);
31
+ const ref = useModalFocus({ onClose: onCancel, initialRef: okRef });
32
+ const titleId = useId();
33
+ return (
34
+ <div className={over ? 'nd-scrim nd-scrim--over' : 'nd-scrim'} data-testid="tree-ask-scrim">
35
+ <form
36
+ ref={ref}
37
+ className="island nd-dialog"
38
+ role="alertdialog"
39
+ aria-modal="true"
40
+ aria-labelledby={titleId}
41
+ tabIndex={-1}
42
+ data-testid="tree-ask-confirm"
43
+ onSubmit={(e) => {
44
+ e.preventDefault();
45
+ if (!busy) onConfirm();
46
+ }}
47
+ >
48
+ <h2 id={titleId} className="nd-title" data-testid="tree-ask-title">
49
+ {title}
50
+ </h2>
51
+ {body ? <p className="nd-body">{body}</p> : null}
52
+ {error ? (
53
+ <p className="nd-err" role="alert" data-testid="tree-ask-error">
54
+ {error}
55
+ </p>
56
+ ) : null}
57
+ <div className="nd-acts">
58
+ <button
59
+ type="button"
60
+ className="btn"
61
+ disabled={busy}
62
+ data-testid="tree-ask-cancel"
63
+ onClick={onCancel}
64
+ >
65
+ Cancel
66
+ </button>
67
+ <button
68
+ ref={okRef}
69
+ type="submit"
70
+ className="btn btn--primary"
71
+ disabled={busy}
72
+ data-testid="tree-ask-ok"
73
+ >
74
+ {busy ? busyLabel : confirm}
75
+ </button>
76
+ </div>
77
+ </form>
78
+ </div>
79
+ );
80
+ }
81
+
82
+ /**
83
+ * The host: `ask` is `{ kind, path, name? }` or null; `run(ask, name)` sends it; `onClose()` ends the ask.
84
+ */
85
+ export function TreeAsk({ ask, run, onClose }) {
86
+ const [busy, setBusy] = useState(false);
87
+ const [error, setError] = useState('');
88
+ const words = folderAskWords(ask);
89
+
90
+ const close = useCallback(() => {
91
+ setBusy(false);
92
+ setError('');
93
+ onClose();
94
+ }, [onClose]);
95
+
96
+ const send = useCallback(
97
+ async (name) => {
98
+ if (!ask || busy) return;
99
+ if (asksForName(ask)) {
100
+ const v = checkAskName(ask, name);
101
+ if (v.kind === 'keep') return close();
102
+ if (v.kind === 'error') return setError(v.error);
103
+ name = v.name;
104
+ }
105
+ setBusy(true);
106
+ setError('');
107
+ let res;
108
+ try {
109
+ res = await run(ask, name);
110
+ } catch {
111
+ res = { ok: false, network: true };
112
+ }
113
+ if (res?.ok) return close();
114
+ setBusy(false);
115
+ setError(askFailure(ask.kind, res));
116
+ return undefined;
117
+ },
118
+ [ask, busy, run, close]
119
+ );
120
+
121
+ if (!ask || !words) return null;
122
+ if (asksForName(ask)) {
123
+ return (
124
+ <NameDialog
125
+ key={`${ask.kind}:${ask.path}`}
126
+ title={words.title}
127
+ label={words.label}
128
+ initial={words.initial}
129
+ confirm={words.confirm}
130
+ busyLabel={words.busy}
131
+ busy={busy}
132
+ error={error}
133
+ onSubmit={send}
134
+ onCancel={close}
135
+ />
136
+ );
137
+ }
138
+ return (
139
+ <ConfirmAskDialog
140
+ title={words.title}
141
+ body={words.body}
142
+ confirm={words.confirm}
143
+ busyLabel={words.busy}
144
+ busy={busy}
145
+ error={error}
146
+ onConfirm={() => send()}
147
+ onCancel={close}
148
+ />
149
+ );
150
+ }
@@ -6,6 +6,8 @@
6
6
  // `DELETE /_api/canvas` answers with the folder it made, and `sync/trash.ts` reads that folder's manifest to
7
7
  // say where each file goes. The kernel's `trash.restore` (S1.6) replaces this; the words stay.
8
8
 
9
+ import { fetchIfServed } from '../shell/served-routes.js';
10
+
9
11
  export const TRASH_WORDS = {
10
12
  moved: (label) => `“${label}” moved to the trash.`,
11
13
  back: (label) => `“${label}” is back.`,
@@ -37,7 +39,7 @@ export async function restoreTrashedCanvas({ trashDir, fetchImpl = fetch }) {
37
39
  if (!folder) return { ok: false, restored: 0, failed: 0 };
38
40
  let entries = [];
39
41
  try {
40
- const r = await fetchImpl('/_api/sync/trash', { cache: 'no-store' });
42
+ const r = await fetchIfServed('/_api/sync/trash', { cache: 'no-store' }, fetchImpl);
41
43
  if (r.ok) entries = (await jsonOf(r)).entries || [];
42
44
  } catch {
43
45
  return { ok: false, restored: 0, failed: 0 };
@@ -71,6 +73,10 @@ const TRASH_TOAST = Object.freeze({ icon: 'trash' });
71
73
  * @param reload re-reads the tree (`loadTree`)
72
74
  * @param onTrashed (path) — the shell closes the canvas if it was open
73
75
  * @param onUndone (path) — the shell opens it again if it had been open
76
+ * @param onRemoved () — #194: the server took the move (the trash queue hides the row at once)
77
+ *
78
+ * #194 (2.0.4): the row, the tab and the toast follow the SERVER's answer; the list re-read comes after and
79
+ * no longer holds them back (it used to: a slow `/_index-data` read was the "nothing happens for a while").
74
80
  */
75
81
  export async function trashCanvas({
76
82
  path,
@@ -80,6 +86,7 @@ export async function trashCanvas({
80
86
  reload,
81
87
  onTrashed,
82
88
  onUndone,
89
+ onRemoved,
83
90
  }) {
84
91
  let j = {};
85
92
  try {
@@ -95,7 +102,7 @@ export async function trashCanvas({
95
102
  toast?.(TRASH_WORDS.failed(label), false);
96
103
  return { ok: false, error: 'network error' };
97
104
  }
98
- await reload?.();
105
+ onRemoved?.();
99
106
  onTrashed?.(path);
100
107
  // the board's toast wears the trash glyph, not a check (11 · pn-trash)
101
108
  toast?.(
@@ -116,5 +123,6 @@ export async function trashCanvas({
116
123
  },
117
124
  TRASH_TOAST
118
125
  );
126
+ await reload?.();
119
127
  return { ok: true, trashDir: j.trashDir };
120
128
  }