fix(session): prevented stale /btw branch promotion

- Passed the authorized leaf through the branch executor and revalidated it before rewriting history.
- Refused promotion during active turns and bounded post-prompt drains.
- Consumed unavailable branch keys while showing pending and refusal state in the panel.

Fixes #7474
This commit is contained in:
roboomp
2026-08-03 09:07:12 +00:00
parent 5039b33a11
commit 7a1183da91
10 changed files with 293 additions and 100 deletions
@@ -250,7 +250,7 @@ export class InputController {
this.#btwBranchListenerInstalled = true;
this.ctx.ui.addInputListener(data => {
if (!matchesKey(data, "b")) return undefined;
if (!this.ctx.canBranchBtw()) return undefined;
if (!this.ctx.hasActiveBtw()) return undefined;
if (this.ctx.ui.getFocused() !== this.ctx.editor) return undefined;
if (this.ctx.editor.getText().trim()) return undefined;
void this.ctx.handleBtwBranchKey();