@dfosco/storyboard 0.6.12 → 0.6.13

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.
@@ -0,0 +1,40 @@
1
+ /**
2
+ * storyboard canvas undo — append the inverse of a previously-applied event.
3
+ *
4
+ * Usage:
5
+ * storyboard canvas undo --canvas my-canvas --event evt_xxx
6
+ *
7
+ * Flags:
8
+ * -c, --canvas Canvas name (required)
9
+ * -e, --event Event ID to undo (required)
10
+ * --json Output as JSON
11
+ */
12
+
13
+ import { post, parseSimpleArgs, jsonOut, die } from './cliHelpers.js'
14
+
15
+ const args = process.argv.slice(4) // skip: node, sb, canvas, undo
16
+
17
+ if (args.includes('--help') || args.includes('-h')) {
18
+ console.log(`
19
+ canvas undo flags:
20
+
21
+ -c, --canvas Canvas name (required)
22
+ -e, --event Event ID to undo (required)
23
+ --json Output as JSON
24
+ `)
25
+ process.exit(0)
26
+ }
27
+
28
+ const { flags } = parseSimpleArgs(args)
29
+ const canvas = flags.canvas || flags.c
30
+ const eventId = flags.event || flags.e
31
+
32
+ if (!canvas) die('--canvas is required')
33
+ if (!eventId) die('--event is required')
34
+
35
+ try {
36
+ const result = await post('/_storyboard/canvas/undo', { name: canvas, eventId })
37
+ if (flags.json) { jsonOut(result) } else {
38
+ console.log(`Undid event ${eventId} → appended ${result.eventId} (${result.inverseEvent?.event})`)
39
+ }
40
+ } catch (err) { die(err.message) }
@@ -256,14 +256,11 @@ async function main() {
256
256
  }
257
257
 
258
258
  const renameWatcher = startRenameWatcher(targetCwd)
259
- const compactInterval = setInterval(() => {
260
- try {
261
- const r = compactAll(targetCwd)
262
- if (verbose) {
263
- for (const x of r) p.log.info(`[compact] ${x.name}: ${(x.before / 1024).toFixed(0)}KB → ${(x.after / 1024).toFixed(0)}KB`)
264
- }
265
- } catch { /* non-critical */ }
266
- }, 15 * 60 * 1000)
259
+ // Note: no background compaction timer — the previous 15-min interval
260
+ // would silently wipe per-tab undo history mid-session. Files are now
261
+ // compacted on dev startup (above) and via a 2 MB hard-ceiling check
262
+ // inside the canvas server's appendEvent (kicks in only for runaway
263
+ // sessions that genuinely need it).
267
264
 
268
265
  const npmBin = process.platform === 'win32' ? 'npx.cmd' : 'npx'
269
266
  const viteArgs = ['vite', '--port', String(port)]
@@ -375,7 +372,6 @@ async function main() {
375
372
  process.exit(130)
376
373
  }
377
374
  shuttingDown = true
378
- clearInterval(compactInterval)
379
375
  renameWatcher.close()
380
376
  // Suppress Vite's shutdown-time esbuild noise ("Pre-transform error:
381
377
  // The service was stopped" for every in-flight transform) AND the
@@ -397,7 +393,6 @@ async function main() {
397
393
  process.on('SIGTERM', shutdown)
398
394
 
399
395
  child.on('exit', (code) => {
400
- clearInterval(compactInterval)
401
396
  renameWatcher.close()
402
397
  releasePort(worktreeName)
403
398
  process.exit(code ?? 0)
@@ -86,6 +86,8 @@ function helpScreen(version) {
86
86
  cmd('canvas delete-canvas', 'Delete a canvas and its directory'),
87
87
  cmd('canvas roles', 'List available hub roles'),
88
88
  cmd('canvas batch', 'Execute multiple canvas operations in one call'),
89
+ cmd('canvas undo --event <id>', 'Undo a previously-applied canvas event'),
90
+ cmd('canvas redo --event <id>', 'Redo a previously-undone canvas event'),
89
91
  cmd('compact [name]', 'Compact canvas JSONL files (removes bloat)'),
90
92
  cmd('compact --all', 'Force compact all canvases'),
91
93
  '',
@@ -196,6 +198,10 @@ switch (command) {
196
198
  import('./canvasRoles.js')
197
199
  } else if (process.argv[3] === 'batch') {
198
200
  import('./canvasBatch.js')
201
+ } else if (process.argv[3] === 'undo') {
202
+ import('./canvasUndo.js')
203
+ } else if (process.argv[3] === 'redo') {
204
+ import('./canvasRedo.js')
199
205
  } else {
200
206
  const version = getVersion()
201
207
  console.log(helpScreen(version))