8000 [pull] main from can1357:main by pull[bot] · Pull Request #103 · ericrihm/oh-my-pi · GitHub
[go: up one dir, main page]

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
4 changes: 4 additions & 0 deletions packages/coding-agent/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Removed support for the env parameter in the bash tool

### Added

- Added `Target.getTargets` to the browser relay's CDP surface so clients can enumerate eligible pages without attaching to or claiming them.

### Fixed

- Fixed resume clutter: elide 0-turn sessions from the /resume menu; -c similarly skips empty sessions.
Expand Down
8 changes: 8 additions & 0 deletions packages/coding-agent/src/tools/browser/relay/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,14 @@ export class RelayBridge {
case "Target.getBrowserContexts":
this.#reply(conn, msg, { browserContextIds: [] });
return;
case "Target.getTargets": {
const targetInfos: TargetInfo[] = [];
for (const tab of this.#tabs.values()) {
if (this.#eligible(tab)) targetInfos.push(this.#pageInfo(tab, tab.attached));
}
this.#reply(conn, msg, { targetInfos });
return;
}
case "Target.setDiscoverTargets": {
conn.discover = true;
for (const tab of this.#tabs.values()) {
Expand Down
29 changes: 29 additions & 0 deletions packages/coding-agent/test/tools/browser-relay-bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,35 @@ async function claimTab(
await flush();
}

describe("RelayBridge target discovery", () => {
it("enumerates current eligible pages without attaching or claiming tabs", () => {
const bridge = new RelayBridge({ group: { title: "omp", color: "cyan" } });
const ext = new FakeExtSocket();
connect(bridge, ext, [
tab({ tabId: 1 }),
tab({ tabId: 2, url: "about:blank" }),
tab({ tabId: 3, url: "chrome://extensions/" }),
]);
const cdp = new FakeCdpSocket();
const connId = bridge.cdpConnected(cdp);
bridge.cdpMessage(connId, JSON.stringify({ id: 1, method: "Target.getTargets" }));
const first = cdp.messages.find(message => message.id === 1)?.result as
| { targetInfos: Array<{ targetId: string; type: string }> }
| undefined;
expect(first?.targetInfos.map(info => [info.targetId, info.type]).sort()).toEqual([
["PAGE1", "page"],
["PAGE2", "page"],
]);
bridge.extMessage(ext, JSON.stringify({ t: "tabRemoved", tabId: 2 }));
bridge.cdpMessage(connId, JSON.stringify({ id: 2, method: "Target.getTargets" }));
const second = cdp.messages.find(message => message.id === 2)?.result as
| { targetInfos: Array<{ targetId: string }> }
| undefined;
expect(second?.targetInfos.map(info => info.targetId)).toEqual(["PAGE1"]);
expect(ext.messages.filter(message => message.t === "rpc")).toEqual([]);
});
});

describe("RelayBridge tab grouping", () => {
it("groups nothing on hello or tab lifecycle events — only claimed tabs join the omp group", () => {
const bridge = new RelayBridge({ group: { title: "omp", color: "cyan" } });
Expand Down
Loading
0