Add thinking level persistence and fix UI issues

- Save and restore thinking level when continuing sessions
- Fix thinking level confirmation message spacing and styling
- Fix thinking text wrapping to preserve ANSI formatting across lines
This commit is contained in:
Mario Zechner 2025-11-11 23:18:40 +01:00
parent 159075cad7
commit 7beb354337
4 changed files with 37 additions and 7 deletions

View file

@ -19,6 +19,7 @@ export interface SessionHeader {
cwd: string;
systemPrompt: string;
model: string;
thinkingLevel: string;
}
export interface SessionMessageEntry {
@ -115,6 +116,7 @@ export class SessionManager {
cwd: process.cwd(),
systemPrompt: state.systemPrompt,
model: `${state.model.provider}/${state.model.id}`,
thinkingLevel: state.thinkingLevel,
};
appendFileSync(this.sessionFile, JSON.stringify(entry) + "\n");
}
@ -157,6 +159,27 @@ export class SessionManager {
return messages;
}
loadThinkingLevel(): string {
if (!existsSync(this.sessionFile)) return "off";
const lines = readFileSync(this.sessionFile, "utf8").trim().split("\n");
// Find the most recent session header with thinking level
let lastThinkingLevel = "off";
for (const line of lines) {
try {
const entry = JSON.parse(line);
if (entry.type === "session" && entry.thinkingLevel) {
lastThinkingLevel = entry.thinkingLevel;
}
} catch {
// Skip malformed lines
}
}
return lastThinkingLevel;
}
getSessionId(): string {
return this.sessionId;
}