Merge PR #8598: fix(session): repair torn JSONL appends (@roboomp)

# Conflicts:
#	packages/coding-agent/src/session/session-loader.ts
#	packages/coding-agent/src/session/session-manager.ts
#	packages/coding-agent/test/session-loader-stream.test.ts
This commit is contained in:
can1357
2026-08-16 02:48:12 +02:00
11 changed files with 232 additions and 104 deletions
@@ -50,6 +50,7 @@ import {
logger,
postmortem,
prompt,
sanitizeText,
setProjectDir,
} from "@oh-my-pi/pi-utils";
import chalk from "@oh-my-pi/pi-utils/chalk";
@@ -1112,6 +1113,15 @@ export class InteractiveMode implements InteractiveModeContext {
// before initHooksAndCustomTools/#reconcileModeFromSession/#enterPlanMode —
// all of which can reach setSessionName during init.
this.#eventBusUnsubscribers.push(
this.sessionManager.onPersistenceError(error => {
const detail = truncateToWidth(
replaceTabs(sanitizeText(error.message)).replace(/[\r\n]+/g, " "),
TRUNCATE_LENGTHS.LINE,
);
this.showWarning(
`Session persistence failed: ${detail}. Unsaved entries remain in memory; persistence will retry on the next entry.`,
);
}),
this.sessionManager.onSessionNameChanged(() => {
setSessionTerminalTitle(this.sessionManager.getSessionName(), this.sessionManager.getCwd());
this.#handleSessionAccentInputsChanged();