mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-19 19:04:41 +00:00
Add custom session events for thinking level and model changes
Session manager changes: - Add ThinkingLevelChangeEntry and ModelChangeEntry types - Add saveThinkingLevelChange() and saveModelChange() methods - Update loadThinkingLevel() to also check for thinking_level_change events (not just session headers) TUI changes: - Pass SessionManager to TuiRenderer constructor - Call saveThinkingLevelChange() when user changes thinking level via /thinking - Store session manager as instance variable for future use This ensures thinking level changes during a session are persisted and correctly restored on --continue.
This commit is contained in:
parent
02a21dd936
commit
bf5f4b17c0
3 changed files with 42 additions and 4 deletions
|
|
@ -11,6 +11,7 @@ import {
|
|||
TUI,
|
||||
} from "@mariozechner/pi-tui";
|
||||
import chalk from "chalk";
|
||||
import type { SessionManager } from "../session-manager.js";
|
||||
import { AssistantMessageComponent } from "./assistant-message.js";
|
||||
import { CustomEditor } from "./custom-editor.js";
|
||||
import { FooterComponent } from "./footer.js";
|
||||
|
|
@ -29,6 +30,7 @@ export class TuiRenderer {
|
|||
private editorContainer: Container; // Container to swap between editor and selector
|
||||
private footer: FooterComponent;
|
||||
private agent: Agent;
|
||||
private sessionManager: SessionManager;
|
||||
private version: string;
|
||||
private isInitialized = false;
|
||||
private onInputCallback?: (text: string) => void;
|
||||
|
|
@ -48,8 +50,9 @@ export class TuiRenderer {
|
|||
// Track if this is the first user message (to skip spacer)
|
||||
private isFirstUserMessage = true;
|
||||
|
||||
constructor(agent: Agent, version: string) {
|
||||
constructor(agent: Agent, sessionManager: SessionManager, version: string) {
|
||||
this.agent = agent;
|
||||
this.sessionManager = sessionManager;
|
||||
this.version = version;
|
||||
this.ui = new TUI(new ProcessTerminal());
|
||||
this.chatContainer = new Container();
|
||||
|
|
@ -409,6 +412,9 @@ export class TuiRenderer {
|
|||
// Apply the selected thinking level
|
||||
this.agent.setThinkingLevel(level);
|
||||
|
||||
// Save thinking level change to session
|
||||
this.sessionManager.saveThinkingLevelChange(level);
|
||||
|
||||
// Show confirmation message with proper spacing
|
||||
this.chatContainer.addChild(new Spacer(1));
|
||||
const confirmText = new Text(chalk.dim(`Thinking level: ${level}`), 1, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue