(api: TuiPluginApi, targetSessionId = getSessionId(api))
| 384 | } |
| 385 | |
| 386 | async function showRecompDialog(api: TuiPluginApi, targetSessionId = getSessionId(api)): Promise<boolean> { |
| 387 | const sessionId = targetSessionId |
| 388 | if (!sessionId) { |
| 389 | showToast(api, { message: "No active session", variant: "warning" }) |
| 390 | return false |
| 391 | } |
| 392 | |
| 393 | const count = await getCompartmentCount(sessionId) |
| 394 | // Ack only after the dialog is actually shown for the same active session; |
| 395 | // route switches while the RPC detail load is in flight must leave it pending. |
| 396 | if (getSessionId(api) !== sessionId) return false |
| 397 | |
| 398 | api.ui.dialog.replace(() => ( |
| 399 | <api.ui.DialogConfirm |
| 400 | title="⚠️ Recomp Confirmation" |
| 401 | message={[ |
| 402 | count === 0 |
| 403 | ? "This session has no compartments yet — recomp will build them from raw history." |
| 404 | : `You have ${count} compartments.`, |
| 405 | "", |
| 406 | "Recomp will regenerate all compartments and facts from raw history.", |
| 407 | "This may take a long time and consume significant tokens.", |
| 408 | "", |
| 409 | "Proceed?", |
| 410 | ].join("\n")} |
| 411 | onConfirm={() => { |
| 412 | void requestRecomp(sessionId) |
| 413 | kickRecompProgressRefresh() |
| 414 | showToast(api, { message: "Recomp requested — historian will start shortly", variant: "info" }) |
| 415 | }} |
| 416 | onCancel={() => { |
| 417 | showToast(api, { message: "Recomp cancelled", variant: "info", durationOverrideMs: 3000 }) |
| 418 | }} |
| 419 | /> |
| 420 | )) |
| 421 | return true |
| 422 | } |
| 423 | |
| 424 | function showUpgradeDialog( |
| 425 | api: TuiPluginApi, |
no test coverage detected