Commit 5a7230b
fix: keep node preview images across workflow tab switches (#15360)
## Summary
Node preview images are lost permanently on a workflow tab switch,
because `app.clean()` revokes their object URLs and nothing restores
them. This scopes preview state per workflow instead.
Fixes FE-1645
## Changes
- **What**: `workflowService.beforeLoadNewGraph()` hands the live
previews to `nodeOutputStore` keyed by the outgoing workflow path, so
`app.clean()` has nothing left to revoke. `afterLoadNewGraph()` puts
back the previews belonging to the workflow that just became active.
### Before
1. Open workflow A with a KSampler, preview method anything but `none`.
2. Queue it and let it finish — the KSampler shows its final latent
preview.
3. Switch to tab B, switch back to tab A.
4. The preview is gone and never comes back. Output images on other
nodes survive the same switch.
`app.clean()` (`src/scripts/app.ts:2434`) runs on every workflow load
and calls `resetAllOutputsAndPreviews()` → `revokeAllPreviews()`
(`src/stores/nodeOutputStore.ts:301`), which releases every preview
object URL and empties the maps. `nodeOutputs` survives only because
`ChangeTracker` snapshots and restores it
(`src/scripts/changeTracker.ts:306`/`350`); previews have no equivalent.
Nothing revokes previews at execution end, so a finished run's last
frame is real state a user is looking at — and a `b_preview` websocket
frame cannot be re-fetched, so revoking makes the loss permanent.
### After
The preview is still there when you come back to the tab.
## Review Focus
- Keying by workflow path is load-bearing, not incidental. Node locator
ids for root-graph nodes are bare node ids, so simply not clearing on
load would show workflow A's node 5 preview on workflow B's node 5.
- Ownership of the object URL retain moves from the live map to the
stash and back, so nothing is released on a tab switch. Released instead
when: the workflow is cleared in place (`Clear Workflow` still calls
`app.clean()` with no load following it), the workflow has been closed,
or a preview arriving for the incoming graph supersedes the stashed one.
- Undo/redo goes through `loadGraphData(..., clean = false)` for the
same workflow — it stashes and restores under the same path, so the net
effect is unchanged.
- Deliberately not done: no `ChangeTracker` snapshot/restore field for
previews, and no use of the `workflowTransientState` mechanism proposed
in #14941, so this does not prejudge that review.
## Tests
`src/stores/nodeOutputStore.workflowSwitch.test.ts` covers the round
trip, the same-node-id cross-workflow case, release on close, and
clear-in-place. `workflowService.test.ts` covers the two lifecycle
hooks.1 parent 76c8029 commit 5a7230b
5 files changed
Lines changed: 344 additions & 8 deletions
File tree
- src
- platform/workflow/core/services
- scripts
- stores
Lines changed: 43 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
87 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
88 | 91 | | |
89 | 92 | | |
90 | 93 | | |
| |||
314 | 317 | | |
315 | 318 | | |
316 | 319 | | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
317 | 335 | | |
318 | 336 | | |
319 | 337 | | |
| |||
542 | 560 | | |
543 | 561 | | |
544 | 562 | | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
545 | 577 | | |
546 | 578 | | |
547 | 579 | | |
| |||
561 | 593 | | |
562 | 594 | | |
563 | 595 | | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
564 | 606 | | |
565 | 607 | | |
566 | 608 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
348 | 349 | | |
349 | 350 | | |
350 | 351 | | |
| 352 | + | |
351 | 353 | | |
352 | 354 | | |
353 | 355 | | |
| |||
423 | 425 | | |
424 | 426 | | |
425 | 427 | | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
426 | 431 | | |
427 | 432 | | |
428 | 433 | | |
| |||
447 | 452 | | |
448 | 453 | | |
449 | 454 | | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
450 | 466 | | |
451 | 467 | | |
452 | 468 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
56 | 62 | | |
57 | 63 | | |
58 | 64 | | |
| |||
298 | 304 | | |
299 | 305 | | |
300 | 306 | | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
305 | 310 | | |
306 | | - | |
| 311 | + | |
307 | 312 | | |
308 | 313 | | |
309 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
310 | 353 | | |
311 | 354 | | |
312 | 355 | | |
313 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
314 | 376 | | |
315 | 377 | | |
316 | 378 | | |
| |||
444 | 506 | | |
445 | 507 | | |
446 | 508 | | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
447 | 512 | | |
448 | 513 | | |
449 | 514 | | |
| |||
0 commit comments