@1agh/maude 2.0.3 → 2.0.6

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 (242) hide show
  1. package/README.md +6 -5
  2. package/apps/hub/src/project-transactions/kernel.mjs +10 -1
  3. package/apps/studio/access/filters.ts +12 -5
  4. package/apps/studio/access/known-canvases.ts +24 -1
  5. package/apps/studio/access/refused-inputs.ts +89 -0
  6. package/apps/studio/access/request.ts +0 -1
  7. package/apps/studio/acp/adapter-stderr.ts +43 -13
  8. package/apps/studio/acp/background-tasks.ts +155 -0
  9. package/apps/studio/acp/bridge.ts +44 -5
  10. package/apps/studio/acp/connected-fact.ts +15 -4
  11. package/apps/studio/acp/index.ts +14 -5
  12. package/apps/studio/actions/agents.ts +10 -0
  13. package/apps/studio/actions/defs/app.ts +12 -0
  14. package/apps/studio/actions/defs/view.ts +12 -0
  15. package/apps/studio/actions.manifest.json +25 -1
  16. package/apps/studio/actions.parity.json +13 -1
  17. package/apps/studio/annotations/ui/element-node.tsx +139 -54
  18. package/apps/studio/annotations/ui/lod.tsx +1 -1
  19. package/apps/studio/annotations/ui/text-style.ts +1 -1
  20. package/apps/studio/annotations-layer.tsx +0 -12
  21. package/apps/studio/api.ts +73 -24
  22. package/apps/studio/artboard-live-gate.tsx +267 -0
  23. package/apps/studio/artboard-live.ts +336 -0
  24. package/apps/studio/artboard-webgl.ts +668 -0
  25. package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
  26. package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
  27. package/apps/studio/bin/_canvas-reasons.mjs +34 -0
  28. package/apps/studio/bin/_ds-check-live.mjs +37 -0
  29. package/apps/studio/bin/_ds-check.mjs +4 -1
  30. package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
  31. package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
  32. package/apps/studio/bin/_import-asset.mjs +2 -1
  33. package/apps/studio/bin/_perf-probe.mjs +2 -1
  34. package/apps/studio/bin/_png-playwright.mjs +10 -1
  35. package/apps/studio/bin/_pw-launch.mjs +14 -0
  36. package/apps/studio/bin/_studio-verb.mjs +24 -3
  37. package/apps/studio/bin/_thumb-blank.mjs +70 -0
  38. package/apps/studio/bin/_thumb-cover.mjs +35 -0
  39. package/apps/studio/bin/_thumbs-playwright.mjs +93 -13
  40. package/apps/studio/bin/ds-check.sh +5 -1
  41. package/apps/studio/bin/perf.sh +11 -1
  42. package/apps/studio/bin/server-up.sh +7 -2
  43. package/apps/studio/bin/smoke.sh +19 -0
  44. package/apps/studio/boot-progress.ts +31 -0
  45. package/apps/studio/canvas-build-sandbox.ts +275 -42
  46. package/apps/studio/canvas-build-worker.ts +10 -0
  47. package/apps/studio/canvas-create.ts +24 -0
  48. package/apps/studio/canvas-lib.tsx +131 -12
  49. package/apps/studio/canvas-module-cache.ts +93 -0
  50. package/apps/studio/canvas-source/errors.ts +39 -0
  51. package/apps/studio/canvas-source/waiting.ts +290 -0
  52. package/apps/studio/client/actions/shell-key-handlers.js +5 -0
  53. package/apps/studio/client/app.jsx +19 -9
  54. package/apps/studio/client/canvas-url.js +13 -0
  55. package/apps/studio/client/github.js +23 -3
  56. package/apps/studio/client/home/HomeAccounts.jsx +262 -0
  57. package/apps/studio/client/home/Shelves.jsx +4 -3
  58. package/apps/studio/client/home/home-accounts-model.js +121 -0
  59. package/apps/studio/client/home/home-api.js +36 -19
  60. package/apps/studio/client/home/home-app.jsx +141 -40
  61. package/apps/studio/client/home/home-model.js +172 -6
  62. package/apps/studio/client/home/home.css +169 -5
  63. package/apps/studio/client/home/shell-mode.js +8 -1
  64. package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
  65. package/apps/studio/client/hooks/use-project-data.jsx +2 -0
  66. package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
  67. package/apps/studio/client/hooks/use-tabs.jsx +64 -35
  68. package/apps/studio/client/index-loader.ts +23 -3
  69. package/apps/studio/client/panels/ChatPanel.jsx +49 -57
  70. package/apps/studio/client/panels/CreateProject.jsx +19 -5
  71. package/apps/studio/client/panels/DiffView.jsx +314 -248
  72. package/apps/studio/client/panels/TeamProjects.jsx +119 -69
  73. package/apps/studio/client/panels/acp-runtime.js +25 -0
  74. package/apps/studio/client/panels/caps-cache.js +46 -0
  75. package/apps/studio/client/panels/chat-finish.js +66 -0
  76. package/apps/studio/client/shell/frame-cap.js +53 -0
  77. package/apps/studio/client/shell/viewport.jsx +45 -8
  78. package/apps/studio/client/styles/_index.css +2 -0
  79. package/apps/studio/client/tree/tree.jsx +48 -21
  80. package/apps/studio/client/v2/access/access-client.js +2 -0
  81. package/apps/studio/client/v2/access/access-host.jsx +12 -1
  82. package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
  83. package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
  84. package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
  85. package/apps/studio/client/v2/ai/Composer.jsx +27 -10
  86. package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
  87. package/apps/studio/client/v2/ai/ai-run.css +87 -3
  88. package/apps/studio/client/v2/ai/background-model.js +113 -0
  89. package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
  90. package/apps/studio/client/v2/ai/run-api.js +7 -3
  91. package/apps/studio/client/v2/ai/runs-store.js +2 -1
  92. package/apps/studio/client/v2/annotations/vote-store.js +11 -5
  93. package/apps/studio/client/v2/assets/asset-state-lane.js +6 -3
  94. package/apps/studio/client/v2/assets/assets-bus.js +10 -8
  95. package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
  96. package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
  97. package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
  98. package/apps/studio/client/v2/assets/spotlight.css +153 -0
  99. package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
  100. package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
  101. package/apps/studio/client/v2/assets/tile.jsx +3 -0
  102. package/apps/studio/client/v2/assets/use-assets.js +2 -1
  103. package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
  104. package/apps/studio/client/v2/canvases/covers.js +11 -5
  105. package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
  106. package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
  107. package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
  108. package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
  109. package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
  110. package/apps/studio/client/v2/canvases/use-pins.js +2 -1
  111. package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
  112. package/apps/studio/client/v2/code/canvas-imports-card.jsx +15 -14
  113. package/apps/studio/client/v2/code/canvas-imports-words.js +44 -0
  114. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
  115. package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
  116. package/apps/studio/client/v2/code/code-bus.js +5 -0
  117. package/apps/studio/client/v2/code/code.css +67 -0
  118. package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
  119. package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
  120. package/apps/studio/client/v2/create/name-dialog.css +10 -0
  121. package/apps/studio/client/v2/ds/advanced-host.jsx +11 -23
  122. package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
  123. package/apps/studio/client/v2/ds/library-host.jsx +45 -45
  124. package/apps/studio/client/v2/ds/make-host.jsx +13 -12
  125. package/apps/studio/client/v2/ds/off-system-host.jsx +18 -16
  126. package/apps/studio/client/v2/ds/review-host.jsx +7 -1
  127. package/apps/studio/client/v2/ds/truth-host.jsx +15 -14
  128. package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
  129. package/apps/studio/client/v2/empty/arriving.jsx +29 -12
  130. package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
  131. package/apps/studio/client/v2/empty/not-local.jsx +31 -1
  132. package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
  133. package/apps/studio/client/v2/export/last-finished.js +2 -1
  134. package/apps/studio/client/v2/history/branch-actions.js +13 -9
  135. package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
  136. package/apps/studio/client/v2/history/git-model.js +21 -5
  137. package/apps/studio/client/v2/history/git-parts.jsx +76 -43
  138. package/apps/studio/client/v2/history/history.css +6 -0
  139. package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
  140. package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
  141. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
  142. package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
  143. package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
  144. package/apps/studio/client/v2/presence/faces.jsx +42 -14
  145. package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
  146. package/apps/studio/client/v2/search/search-recent.js +3 -1
  147. package/apps/studio/client/v2/search/search-remote.js +6 -4
  148. package/apps/studio/client/v2/settings/connections-model.js +1 -1
  149. package/apps/studio/client/v2/shell/account-card.jsx +10 -4
  150. package/apps/studio/client/v2/shell/canvas-crash-guard.js +137 -0
  151. package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
  152. package/apps/studio/client/v2/shell/menu-runner.js +12 -0
  153. package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
  154. package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
  155. package/apps/studio/client/v2/shell/project-account-model.js +182 -0
  156. package/apps/studio/client/v2/shell/recovery-store.js +2 -1
  157. package/apps/studio/client/v2/shell/served-routes.js +120 -0
  158. package/apps/studio/client/v2/shell/share-cluster-host.jsx +139 -11
  159. package/apps/studio/client/v2/shell/share-cluster.css +58 -0
  160. package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
  161. package/apps/studio/client/v2/shell/shell-activity.js +19 -0
  162. package/apps/studio/client/v2/shell/team-switch.js +94 -0
  163. package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
  164. package/apps/studio/client/v2/shell/use-account.js +8 -1
  165. package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
  166. package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
  167. package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
  168. package/apps/studio/cloud/endpoints.ts +23 -1
  169. package/apps/studio/collab/persistence.ts +9 -1
  170. package/apps/studio/collab/registry.ts +32 -0
  171. package/apps/studio/collab/room.ts +8 -0
  172. package/apps/studio/config-reload-wire.ts +53 -0
  173. package/apps/studio/dist/client.bundle.js +1098 -1102
  174. package/apps/studio/dist/styles.css +1 -1
  175. package/apps/studio/ds/board/specimen.tsx +12 -1
  176. package/apps/studio/ds/canvas-cli.ts +58 -2
  177. package/apps/studio/ds/check.ts +26 -1
  178. package/apps/studio/ds/cli.ts +7 -3
  179. package/apps/studio/ds/convert.ts +34 -6
  180. package/apps/studio/ds/ds-verb.ts +13 -0
  181. package/apps/studio/ds/post-build.ts +38 -0
  182. package/apps/studio/ds/upgrade-apply.ts +27 -5
  183. package/apps/studio/ds/upgrade-cli.ts +22 -2
  184. package/apps/studio/ds/upgrade-prove.ts +198 -15
  185. package/apps/studio/ds/upgrade-stage.ts +4 -1
  186. package/apps/studio/editing/minimap-context.tsx +3 -3
  187. package/apps/studio/editing/page-activity.ts +251 -0
  188. package/apps/studio/editing/rotate-handle.tsx +9 -5
  189. package/apps/studio/editing/sticky-name.tsx +4 -4
  190. package/apps/studio/history/restore-artboard-action.ts +40 -0
  191. package/apps/studio/history/trash.ts +6 -0
  192. package/apps/studio/home/accounts.ts +87 -0
  193. package/apps/studio/home/hub.ts +77 -175
  194. package/apps/studio/home/index-reader.ts +24 -2
  195. package/apps/studio/home/routes.ts +66 -8
  196. package/apps/studio/http.ts +131 -68
  197. package/apps/studio/index-flight.ts +40 -0
  198. package/apps/studio/managed-projects.ts +52 -24
  199. package/apps/studio/migrate/hub.ts +7 -1
  200. package/apps/studio/routes/canvas-source.ts +44 -2
  201. package/apps/studio/routes/ds-convert.ts +18 -0
  202. package/apps/studio/routes/history.ts +28 -5
  203. package/apps/studio/routes/hub-signin.ts +115 -0
  204. package/apps/studio/routes/index.ts +4 -0
  205. package/apps/studio/routes/table.ts +7 -0
  206. package/apps/studio/routes/trash.ts +19 -1
  207. package/apps/studio/server.ts +19 -10
  208. package/apps/studio/sync/accepted-cold-start.ts +54 -16
  209. package/apps/studio/sync/accepted-link.ts +9 -4
  210. package/apps/studio/sync/asset-push.ts +146 -23
  211. package/apps/studio/sync/asset-state.ts +3 -2
  212. package/apps/studio/sync/code-module-consent.ts +74 -0
  213. package/apps/studio/sync/file-ledger.ts +35 -0
  214. package/apps/studio/sync/file-membership.ts +28 -3
  215. package/apps/studio/sync/file-plane.ts +483 -86
  216. package/apps/studio/sync/file-pull.ts +304 -33
  217. package/apps/studio/sync/hub-browser-signin.ts +377 -0
  218. package/apps/studio/sync/hub-link.ts +1 -2
  219. package/apps/studio/sync/hub-text-undo.ts +30 -10
  220. package/apps/studio/sync/index.ts +381 -161
  221. package/apps/studio/sync/journal-client.ts +94 -5
  222. package/apps/studio/sync/pending-deletes.ts +100 -0
  223. package/apps/studio/sync/projection.ts +121 -14
  224. package/apps/studio/sync/pull-pacer.ts +160 -0
  225. package/apps/studio/sync/pull-priority.ts +119 -0
  226. package/apps/studio/sync/seed-progress.ts +58 -3
  227. package/apps/studio/sync/status.ts +3 -1
  228. package/apps/studio/sync/transaction-client.ts +71 -6
  229. package/apps/studio/sync/workspace-signin.ts +6 -256
  230. package/apps/studio/sync/writer-registry.ts +5 -1
  231. package/apps/studio/thumbs/service.ts +12 -2
  232. package/apps/studio/thumbs/validate.ts +7 -0
  233. package/apps/studio/ui-prefs-migrate.ts +4 -0
  234. package/apps/studio/video-comp.tsx +23 -0
  235. package/apps/studio/video-links-overlay.tsx +3 -2
  236. package/apps/studio/whats-new.json +126 -0
  237. package/cli/lib/bash-guard.mjs +13 -1
  238. package/cli/lib/design-help.gen.mjs +1 -1
  239. package/cli/lib/design-hook.mjs +20 -0
  240. package/cli/lib/studio-locate.mjs +35 -10
  241. package/cli/lib/workspace-plan.mjs +14 -0
  242. package/package.json +8 -8
@@ -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
  }
@@ -0,0 +1,152 @@
1
+ // client/v2/canvases/trash-queue.js — #194 (2.0.4): Move to trash answers at once, and several in a row all land.
2
+ //
3
+ // The report: "nothing happens for a while when I click the trash can … moving several canvases one after
4
+ // another doesn't do anything". Before, the row stayed as it was until `DELETE /_api/canvas` answered AND a
5
+ // whole fresh project index (`/_index-data`) had been read — and every new delete's tree refresh threw the
6
+ // read in flight away (`index-loader.ts`: a newer request wins), so three quick deletes showed nothing until
7
+ // the last read settled. On a Maude Cloud project each of those is a trip to the cell.
8
+ //
9
+ // Now every door (the row menu, ⌘K, the File menu) goes through ONE queue:
10
+ // 1. the row says "Moving to trash…" and fades the moment it is asked (a `trash` row slot, row-slots.js);
11
+ // 2. the moves go out one at a time, in the order asked — none is dropped, a second ask for the same canvas
12
+ // while it is waiting is the same move;
13
+ // 3. the server's yes takes the row out of the list at once (`gone`, the panel hides it) and the toast with
14
+ // Undo shows; the list then re-reads, and the row stays out once the index agrees;
15
+ // 4. a refusal brings the row back as it was, and the toast says why (TRASH_WORDS.failed).
16
+ // Undo is unchanged (trash-canvas.js).
17
+
18
+ import { useSyncExternalStore } from 'react';
19
+
20
+ import { registerRowSlot } from './row-slots.js';
21
+ import { trashCanvas } from './trash-canvas.js';
22
+
23
+ export const TRASH_QUEUE_WORDS = Object.freeze({
24
+ moving: 'Moving to trash…',
25
+ });
26
+
27
+ /** How long a confirmed move keeps its row hidden after the list re-read, so the fresh list lands first. */
28
+ export const GONE_SETTLE_MS = 400;
29
+
30
+ /**
31
+ * A queue of canvas moves to the trash, with its own small store: which canvases are on their way
32
+ * (`moving`) and which the server has taken (`gone`).
33
+ * @param {{ settleMs?: number, slot?: typeof registerRowSlot }} [opts]
34
+ */
35
+ export function createTrashQueue({ settleMs = GONE_SETTLE_MS, slot = registerRowSlot } = {}) {
36
+ /** path → { state: 'moving' | 'gone', dispose?: () => void } */
37
+ const items = new Map();
38
+ const listeners = new Set();
39
+ let gone = Object.freeze(new Set());
40
+ let chain = Promise.resolve();
41
+
42
+ const publish = () => {
43
+ gone = Object.freeze(
44
+ new Set([...items].filter(([, it]) => it.state === 'gone').map(([p]) => p))
45
+ );
46
+ for (const fn of [...listeners]) fn();
47
+ };
48
+ const forget = (path) => {
49
+ const it = items.get(path);
50
+ if (!it) return;
51
+ it.dispose?.();
52
+ items.delete(path);
53
+ publish();
54
+ };
55
+
56
+ /**
57
+ * Ask for one move. `run({ path, label, removed })` does the move and calls `removed()` the moment the
58
+ * server has taken it; it resolves `{ ok }` when it is completely done (list re-read included).
59
+ * @returns {Promise<{ ok: boolean, error?: string, queued?: boolean }>}
60
+ */
61
+ function enqueue({ path, label, rel }, run) {
62
+ if (typeof path !== 'string' || !path) return Promise.resolve({ ok: false });
63
+ if (items.has(path)) return Promise.resolve({ ok: true, queued: true });
64
+ const dispose = slot(
65
+ 'trash',
66
+ rel || path,
67
+ Object.freeze({ sub: { text: TRASH_QUEUE_WORDS.moving, icon: 'trash' }, dim: true })
68
+ );
69
+ items.set(path, { state: 'moving', dispose });
70
+ publish();
71
+ let finish;
72
+ const result = new Promise((resolve) => {
73
+ finish = resolve;
74
+ });
75
+ // The queue moves on once the SERVER has answered this move — it never waits on the list re-read.
76
+ chain = chain.then(
77
+ () =>
78
+ new Promise((answered) => {
79
+ const removed = () => {
80
+ const it = items.get(path);
81
+ if (it && it.state === 'moving') {
82
+ it.dispose?.();
83
+ items.set(path, { state: 'gone' });
84
+ publish();
85
+ }
86
+ answered();
87
+ };
88
+ Promise.resolve()
89
+ .then(() => run({ path, label, removed }))
90
+ .catch(() => ({ ok: false }))
91
+ .then((res) => {
92
+ answered();
93
+ if (res?.ok) setTimeout(() => forget(path), settleMs);
94
+ else forget(path); // the row comes back as it was
95
+ finish(res ?? { ok: false });
96
+ });
97
+ })
98
+ );
99
+ return result;
100
+ }
101
+
102
+ return {
103
+ enqueue,
104
+ /** Canvases the server has taken whose row is still listed until the list re-reads. */
105
+ gone: () => gone,
106
+ stateOf: (path) => items.get(path)?.state ?? null,
107
+ subscribe(fn) {
108
+ listeners.add(fn);
109
+ return () => listeners.delete(fn);
110
+ },
111
+ /** Forget everything (tests, a project switch). */
112
+ reset() {
113
+ for (const it of items.values()) it.dispose?.();
114
+ items.clear();
115
+ chain = Promise.resolve();
116
+ publish();
117
+ },
118
+ };
119
+ }
120
+
121
+ /** The window's one queue. */
122
+ export const trashQueue = createTrashQueue();
123
+
124
+ /** The panel's hook: the set of repo paths to leave out of the list until the index agrees. */
125
+ export function useTrashGone(queue = trashQueue) {
126
+ return useSyncExternalStore(queue.subscribe, queue.gone, queue.gone);
127
+ }
128
+
129
+ /**
130
+ * `groups` (the `/_index-data` groups) without the canvases the server has taken: the canvas and its
131
+ * same-name sidecars (`<name>.meta.json` …) leave every group's `paths`, so folder counts follow.
132
+ */
133
+ export function withoutGone(groups, gone) {
134
+ if (!gone?.size || !Array.isArray(groups)) return groups;
135
+ const prefixes = [...gone].map((p) => p.replace(/\.tsx$/i, '.'));
136
+ const hidden = (p) => gone.has(p) || prefixes.some((pre) => p.startsWith(pre));
137
+ return groups.map((g) =>
138
+ Array.isArray(g.paths) && g.paths.some(hidden)
139
+ ? { ...g, paths: g.paths.filter((p) => !hidden(p)) }
140
+ : g
141
+ );
142
+ }
143
+
144
+ /**
145
+ * Move one canvas to the trash through the queue: the shell's `deleteBoard`. Same arguments as
146
+ * `trashCanvas`, plus `rel` (the designRoot-relative path the row slots are keyed by) and `queue`.
147
+ */
148
+ export function queueTrashCanvas({ queue = trashQueue, path, label, rel, ...rest }) {
149
+ return queue.enqueue({ path, label, rel }, ({ removed }) =>
150
+ trashCanvas({ ...rest, path, label, onRemoved: removed })
151
+ );
152
+ }