File size: 1,443 Bytes
be22d4d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { ConfirmDialog } from "@/components/ConfirmDialog";

/**

 * Confirm + full-page reload after a model change.

 *

 * Changing the main model persists to config.yaml, but the RUNNING chat keeps

 * its model until its session is rebuilt. A full reload (fresh PTY session that

 * boots its agent from the just-saved config) is the reliable way to apply it —

 * the in-place hot-swap and partial remount both proved unreliable. We confirm

 * first because the reload starts a fresh chat (the current one stays resumable

 * in Sessions and the agent's memory is kept).

 *

 * Shared by the chat sidebar picker and the Models page so both behave

 * identically. `model` is the short model name awaiting confirmation, or null

 * when the dialog is closed.

 */
export function ModelReloadConfirm({

  model,

  description,

  onCancel,

}: {

  model: string | null;

  /** Override the default body copy (e.g. the Models-page phrasing). */

  description?: string;

  onCancel: () => void;

}) {
  return (
    <ConfirmDialog

      open={model !== null}

      title="Switch model?"

      description={

        description ??

        `Switching to ${model ?? ""} starts a fresh chat. Your current chat stays in your Sessions list and the agent's memory is kept. Reload now to apply it?`

      }

      confirmLabel="Reload"

      onConfirm={() => window.location.reload()}

      onCancel={onCancel}

    />
  );
}