Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions bridge-browser/src/content/tool_activity_overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ export class ToolActivityOverlay {
return;
}

if (currentEntry.turn.id !== this.currentTurnId) {
const isSameTurn = currentEntry.turn.id === this.currentTurnId;
const currentScrollTop = isSameTurn ? this.getCurrentScrollTop() : 0;
const historyScrollTop = this.getHistoryScrollTop();
if (!isSameTurn) {
this.startTurn(currentEntry.turn.id);
}

const historyScrollTop = this.getHistoryScrollTop();
const historyEntries = entries.slice(0, -1).reverse();
this.host.style.display = "block";
this.host.className = this.collapsed && !this.historyVisible ? "current-collapsed" : "";
Expand All @@ -70,6 +72,7 @@ export class ToolActivityOverlay {
...(this.historyVisible ? [this.createHistoryPanel(historyEntries)] : []),
this.panel
);
this.restoreCurrentScrollTop(currentScrollTop);
this.restoreHistoryScrollTop(historyScrollTop);
this.syncTicker(snapshot.items.some((item) => item.status === "executing"));
this.dragController.scheduleClamp();
Expand Down Expand Up @@ -209,11 +212,22 @@ export class ToolActivityOverlay {
}
}

private getCurrentScrollTop(): number {
if (this.collapsed) {return 0;}
return this.panel.querySelector<HTMLElement>(".list")?.scrollTop ?? 0;
}

private getHistoryScrollTop(): number {
if (!this.historyVisible) {return 0;}
return this.stack.querySelector<HTMLElement>(".history-list")?.scrollTop ?? 0;
}

private restoreCurrentScrollTop(scrollTop: number): void {
if (this.collapsed) {return;}
const list = this.panel.querySelector<HTMLElement>(".list");
if (list) {list.scrollTop = scrollTop;}
}

private restoreHistoryScrollTop(scrollTop: number): void {
if (!this.historyVisible) {return;}
const history = this.stack.querySelector<HTMLElement>(".history-list");
Expand Down
3 changes: 3 additions & 0 deletions bridge-browser/test/tool_activity_overlay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,12 @@ function testDetailedHistoryBlock(Overlay: OverlayConstructor): void {
assertIncludes(historyPanel.getText(), "Run read_file", "history omitted the tool purpose");
assertIncludes(harness.panel.getText(), "Running", "current status was not kept visible");

const currentBeforeUpdate = getRequired(harness.panel, ".list");
currentBeforeUpdate.scrollTop = 67;
const historyBeforeUpdate = getRequired(harness.stack, ".history-list");
historyBeforeUpdate.scrollTop = 41;
harness.tracker.updateStatus({ requestKey: currentKey }, "awaiting_approval");
assertEqual(getRequired(harness.panel, ".list").scrollTop, 67, "live update reset current scroll");
assertEqual(getRequired(harness.stack, ".history-list").scrollTop, 41, "live update reset history scroll");
assertIncludes(harness.panel.getText(), "Approval", "current approval state did not update");

Expand Down
Loading