(
api: TuiPluginApi,
resume?: { stagedCount: number; stagedThrough: number },
targetSessionId = getSessionId(api),
)
| 422 | } |
| 423 | |
| 424 | function showUpgradeDialog( |
| 425 | api: TuiPluginApi, |
| 426 | resume?: { stagedCount: number; stagedThrough: number }, |
| 427 | targetSessionId = getSessionId(api), |
| 428 | ): boolean { |
| 429 | const sessionId = targetSessionId |
| 430 | if (!sessionId) { |
| 431 | // No active session — nothing to upgrade. Silently skip (the server only |
| 432 | // enqueues this for sessions with legacy compartments, but the TUI may |
| 433 | // have switched sessions before the poller fired). |
| 434 | return false |
| 435 | } |
| 436 | |
| 437 | if (getSessionId(api) !== sessionId) return false |
| 438 | |
| 439 | const title = resume ? "🎆 Resume the interrupted upgrade?" : "🎆 Historian V2 is released!" |
| 440 | const message = resume |
| 441 | ? [ |
| 442 | `An earlier upgrade to the new historian format was interrupted. ${resume.stagedCount} compartment${resume.stagedCount === 1 ? " was" : "s were"} already rebuilt (through message ${resume.stagedThrough}). Resuming continues from where it left off — nothing already rebuilt is reprocessed.`, |
| 443 | "", |
| 444 | "Resuming will:", |
| 445 | "• Rebuild the remaining compartments into the new layered format", |
| 446 | "• Re-organize this project's memories into the new taxonomy (once per project)", |
| 447 | "", |
| 448 | "The historian runs in the background and you can keep working. You can also resume via /ctx-session-upgrade later.", |
| 449 | "", |
| 450 | "Resume the upgrade now?", |
| 451 | ].join("\n") |
| 452 | : [ |
| 453 | "This session's compartments are written by the old historian. The session is still usable with its old compartments, however it's strongly advised to upgrade them to the new format. This means every compartment needs to be reprocessed by the new historian, which might take a while depending on how big your session is.", |
| 454 | "", |
| 455 | "Running the upgrade will:", |
| 456 | "• Rebuild this session's compartments into the new layered format", |
| 457 | "• Re-organize this project's memories into the new taxonomy (once per project)", |
| 458 | "", |
| 459 | "The historian runs in the background and you can keep working while older compartments are reprocessed. You can also upgrade via /ctx-session-upgrade later.", |
| 460 | "", |
| 461 | "Run the upgrade now?", |
| 462 | ].join("\n") |
| 463 | |
| 464 | api.ui.dialog.replace( |
| 465 | () => ( |
| 466 | <api.ui.DialogConfirm |
| 467 | title={title} |
| 468 | message={message} |
| 469 | onConfirm={() => { |
| 470 | // Start the sidebar's recomp self-poll immediately — the RPC |
| 471 | // call fires no message event, so without this the progress |
| 472 | // bar wouldn't appear until the upgrade finished. |
| 473 | kickRecompProgressRefresh() |
| 474 | showToast(api, { |
| 475 | message: resume |
| 476 | ? "Resuming session upgrade — running in the background" |
| 477 | : "Session upgrade started — running in the background", |
| 478 | variant: "info", |
| 479 | }) |
| 480 | // Dismiss the durable reminder ONLY after the upgrade request |
| 481 | // actually started. If requestUpgrade() returns false (RPC / |
no test coverage detected