fix(coding-agent): use visible leaf for tree display, preserve metadata on branch

This commit is contained in:
Mario Zechner 2025-12-29 14:24:28 +01:00
parent 5726770d1f
commit e8debe78c6

View file

@ -1597,7 +1597,16 @@ export class InteractiveMode {
private showTreeSelector(): void { private showTreeSelector(): void {
const tree = this.sessionManager.getTree(); const tree = this.sessionManager.getTree();
const currentLeafId = this.sessionManager.getLeafUuid(); const realLeafId = this.sessionManager.getLeafUuid();
// Find the visible leaf for display (skip metadata entries like labels)
let visibleLeafId = realLeafId;
while (visibleLeafId) {
const entry = this.sessionManager.getEntry(visibleLeafId);
if (!entry) break;
if (entry.type !== "label" && entry.type !== "custom") break;
visibleLeafId = entry.parentId ?? null;
}
if (tree.length === 0) { if (tree.length === 0) {
this.showStatus("No entries in session"); this.showStatus("No entries in session");
@ -1607,11 +1616,11 @@ export class InteractiveMode {
this.showSelector((done) => { this.showSelector((done) => {
const selector = new TreeSelectorComponent( const selector = new TreeSelectorComponent(
tree, tree,
currentLeafId, visibleLeafId,
this.ui.terminal.rows, this.ui.terminal.rows,
async (entryId) => { async (entryId) => {
// Check if selecting current leaf (no-op) // Selecting the visible leaf is a no-op (already there)
if (entryId === currentLeafId) { if (entryId === visibleLeafId) {
done(); done();
this.showStatus("Already at this point"); this.showStatus("Already at this point");
return; return;