Fix editor text clearing during compaction, fixes #179

This commit is contained in:
Mario Zechner 2025-12-16 15:15:37 +01:00
parent 7ac832586f
commit 871188219b
2 changed files with 13 additions and 3 deletions

View file

@ -14,6 +14,7 @@
### Fixed
- Fixed editor text being cleared during compaction. Text typed while compaction is running is now preserved. ([#179](https://github.com/badlogic/pi-mono/issues/179))
- Improved RGB to 256-color mapping for terminals without truecolor support. Now correctly uses grayscale ramp for neutral colors and preserves semantic tints (green for success, red for error, blue for pending) instead of mapping everything to wrong cube colors.
- `/think off` now actually disables thinking for all providers. Previously, providers like Gemini with "dynamic thinking" enabled by default would still use thinking even when turned off. ([#180](https://github.com/badlogic/pi-mono/pull/180) by [@markusylisiurunen](https://github.com/markusylisiurunen))

View file

@ -577,14 +577,19 @@ export class InteractiveMode {
return;
}
if (text === "/clear") {
await this.handleClearCommand();
this.editor.setText("");
await this.handleClearCommand();
return;
}
if (text === "/compact" || text.startsWith("/compact ")) {
const customInstructions = text.startsWith("/compact ") ? text.slice(9).trim() : undefined;
await this.handleCompactCommand(customInstructions);
this.editor.setText("");
this.editor.disableSubmit = true;
try {
await this.handleCompactCommand(customInstructions);
} finally {
this.editor.disableSubmit = false;
}
return;
}
if (text === "/autocompact") {
@ -625,7 +630,7 @@ export class InteractiveMode {
}
}
// Block input during compaction (will retry automatically)
// Block input during compaction
if (this.session.isCompacting) {
return;
}
@ -789,6 +794,8 @@ export class InteractiveMode {
break;
case "auto_compaction_start": {
// Disable submit to preserve editor text during compaction
this.editor.disableSubmit = true;
// Set up escape to abort auto-compaction
this.autoCompactionEscapeHandler = this.editor.onEscape;
this.editor.onEscape = () => {
@ -809,6 +816,8 @@ export class InteractiveMode {
}
case "auto_compaction_end": {
// Re-enable submit
this.editor.disableSubmit = false;
// Restore escape handler
if (this.autoCompactionEscapeHandler) {
this.editor.onEscape = this.autoCompactionEscapeHandler;