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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Browser: recognize the open chat's header “Chat actions” menu for archiving and avoid falling back to composer or sidebar controls. Thanks @larsmartens (#639).

## 0.24.0 - 2026-12-05

**Highlights:** Support current Pro and effort sliders, preserve browser model selection, and include remote authentication and dependency security fixes.
Expand Down
4 changes: 3 additions & 1 deletion src/browser/actions/archiveConversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ function buildArchiveConversationExpression(): string {
.map((element) => ({ element, label: labelFor(element), rect: element.getBoundingClientRect() }))
.filter(({ label }) =>
label.includes('more') ||
label.includes('chat actions') ||
label.includes('conversation options') ||
label.includes('open menu') ||
label.includes('więcej') ||
Expand All @@ -175,7 +176,8 @@ function buildArchiveConversationExpression(): string {
const headerCandidates = labelled
.filter(({ rect }) => rect.top < 180 && rect.right > window.innerWidth - 420)
.sort((a, b) => b.rect.right - a.rect.right);
return (headerCandidates[0] ?? labelled[0])?.element ?? null;
// Other labelled buttons can belong to the composer or a sidebar conversation.
return headerCandidates[0]?.element ?? null;
};
const visibleMenuCandidates = () => {
const menuRoots = Array.from(document.querySelectorAll('[role="menu"]'))
Expand Down
75 changes: 75 additions & 0 deletions tests/browser/archiveConversation.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import vm from "node:vm";
import { describe, expect, test, vi } from "vitest";
import {
archiveChatGptConversation,
Expand All @@ -7,6 +8,79 @@ import {
resolveBrowserArchiveDecision,
} from "../../src/browser/actions/archiveConversation.js";

async function runArchiveMenuFixture(headerLabel?: string) {
const clicks: string[] = [];
const location = { href: "https://chatgpt.com/c/current" };
let menuOpen = false;
class Element {
constructor(
readonly textContent: string,
readonly top: number,
readonly right: number,
) {}
getAttribute() {
return null;
}
getBoundingClientRect() {
return { top: this.top, right: this.right, left: this.right - 30, width: 30, height: 30 };
}
dispatchEvent(event: { type: string }) {
if (event.type !== "click") return true;
clicks.push(this.textContent);
if (this === header) menuOpen = true;
if (this === archive) location.href = "https://chatgpt.com/";
return true;
}
querySelectorAll() {
return [archive];
}
}
class Event {
constructor(readonly type: string) {}
}
const composer = new Element("Add files and more", 700, 1200);
const sidebar = new Element("Chat actions", 100, 200);
const legacySidebar = new Element("More", 300, 200);
const header = headerLabel ? new Element(headerLabel, 8, 1314) : undefined;
const archive = new Element("Archive", 50, 1300);
const menu = new Element("", 40, 1300);
const document = {
querySelectorAll(selector: string) {
if (selector === 'button,[role="button"]') {
return [composer, sidebar, legacySidebar, ...(header ? [header] : [])];
}
if (selector === '[role="menu"]') return menuOpen ? [menu] : [];
return [];
},
dispatchEvent() {},
};
const result = await vm.runInNewContext(buildArchiveConversationExpressionForTest(), {
document,
location,
window: { innerWidth: 1366 },
HTMLElement: Element,
MouseEvent: Event,
KeyboardEvent: Event,
getComputedStyle: () => ({ visibility: "visible", display: "block" }),
setTimeout: (callback: () => void) => callback(),
});
return { result, clicks };
}

describe("archive menu ownership", () => {
test.each(["Chat actions", "More"])("archives through the header %s control", async (label) => {
const { result, clicks } = await runArchiveMenuFixture(label);
expect(result.status).toBe("archived");
expect(clicks).toEqual([label, "Archive"]);
});

test("does not open composer or sidebar menus when the header control is absent", async () => {
const { result, clicks } = await runArchiveMenuFixture();
expect(result).toMatchObject({ status: "skipped", reason: "conversation-menu-not-found" });
expect(clicks).toEqual([]);
});
});

describe("browser conversation archive policy", () => {
test("archives successful non-project one-shots in auto mode", () => {
expect(
Expand Down Expand Up @@ -212,6 +286,7 @@ describe("archive expression locale label inventory", () => {
test("conversation menu ('more options') labels are present", () => {
for (const label of [
"more",
"chat actions",
"conversation options",
"open menu",
"więcej",
Expand Down