adhdev 0.8.46 → 0.8.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -1833,6 +1833,8 @@ var init_manager = __esm({
1833
1833
  allTargets = result?.targetInfos || [];
1834
1834
  }
1835
1835
  const pageWebviewUrls = await this.getCurrentPageWebviewUrls();
1836
+ const pageWebviewOrder = /* @__PURE__ */ new Map();
1837
+ Array.from(pageWebviewUrls).forEach((url2, index) => pageWebviewOrder.set(url2, index));
1836
1838
  const iframes = allTargets.filter((t) => t.type === "iframe");
1837
1839
  const typeMap = /* @__PURE__ */ new Map();
1838
1840
  for (const t of allTargets) {
@@ -1874,6 +1876,14 @@ var init_manager = __esm({
1874
1876
  }
1875
1877
  }
1876
1878
  }
1879
+ agents.sort((lhs, rhs) => {
1880
+ const leftOrder = pageWebviewOrder.get(lhs.url);
1881
+ const rightOrder = pageWebviewOrder.get(rhs.url);
1882
+ if (leftOrder != null && rightOrder != null) return leftOrder - rightOrder;
1883
+ if (leftOrder != null) return -1;
1884
+ if (rightOrder != null) return 1;
1885
+ return lhs.url.localeCompare(rhs.url);
1886
+ });
1877
1887
  this._lastDiscoveredTargets = new Set(agents.map((a) => a.targetId));
1878
1888
  return agents;
1879
1889
  } catch (e) {
@@ -2012,6 +2022,26 @@ var init_manager = __esm({
2012
2022
  }
2013
2023
  async getCurrentPageWebviewUrls() {
2014
2024
  if (!this.isConnected) return /* @__PURE__ */ new Set();
2025
+ try {
2026
+ const raw = await this.evaluate(
2027
+ `JSON.stringify(Array.from(document.querySelectorAll('iframe,webview'))
2028
+ .filter((el) => {
2029
+ const rect = el.getBoundingClientRect();
2030
+ if (rect.width <= 8 || rect.height <= 8) return false;
2031
+ const style = window.getComputedStyle(el);
2032
+ return style.display !== 'none' && style.visibility !== 'hidden';
2033
+ })
2034
+ .map((el) => el.src || el.getAttribute('src') || '')
2035
+ .filter((src) => typeof src === 'string' && src.includes('vscode-webview')))`,
2036
+ 5e3
2037
+ );
2038
+ const parsed = typeof raw === "string" ? JSON.parse(raw) : raw;
2039
+ if (Array.isArray(parsed)) {
2040
+ const urls = parsed.filter((src) => typeof src === "string" && src.length > 0);
2041
+ if (urls.length > 0) return new Set(urls);
2042
+ }
2043
+ } catch {
2044
+ }
2015
2045
  try {
2016
2046
  const urls = /* @__PURE__ */ new Set();
2017
2047
  const { frameTree } = await this.sendInternal("Page.getFrameTree", {}, 5e3);
@@ -2023,19 +2053,7 @@ var init_manager = __esm({
2023
2053
  for (const child of node?.childFrames || []) visit(child);
2024
2054
  };
2025
2055
  if (frameTree) visit(frameTree);
2026
- if (urls.size > 0) return urls;
2027
- } catch {
2028
- }
2029
- try {
2030
- const raw = await this.evaluate(
2031
- `JSON.stringify(Array.from(document.querySelectorAll('iframe,webview'))
2032
- .map((el) => el.src || el.getAttribute('src') || '')
2033
- .filter((src) => typeof src === 'string' && src.includes('vscode-webview')))`,
2034
- 5e3
2035
- );
2036
- const parsed = typeof raw === "string" ? JSON.parse(raw) : raw;
2037
- if (!Array.isArray(parsed)) return /* @__PURE__ */ new Set();
2038
- return new Set(parsed.filter((src) => typeof src === "string" && src.length > 0));
2056
+ return urls;
2039
2057
  } catch {
2040
2058
  return /* @__PURE__ */ new Set();
2041
2059
  }
@@ -6563,7 +6581,7 @@ async function executeProviderScript(h, args, scriptName) {
6563
6581
  }
6564
6582
  const managed = runtimeSessionId ? h.agentStream?.getManagedSession(runtimeSessionId) : null;
6565
6583
  const targetSessionId = managed?.cdpSessionId || null;
6566
- const IDE_LEVEL_SCRIPTS = ["listModes", "setMode", "listModels", "setModel"];
6584
+ const IDE_LEVEL_SCRIPTS = provider.type === "claude-code-vscode" ? ["listModes", "setMode"] : ["listModes", "setMode", "listModels", "setModel"];
6567
6585
  if (IDE_LEVEL_SCRIPTS.includes(scriptName)) {
6568
6586
  if (targetSessionId) {
6569
6587
  try {
@@ -42255,7 +42273,6 @@ async function initiateConnection(deps, peerId, sharePermission) {
42255
42273
  const peer = deps.peers.get(pid);
42256
42274
  if (!peer) return;
42257
42275
  if (pcState === "connected") {
42258
- peer.state = "connected";
42259
42276
  try {
42260
42277
  const pair = pc.getSelectedCandidatePair?.();
42261
42278
  if (pair) {
@@ -42270,7 +42287,6 @@ async function initiateConnection(deps, peerId, sharePermission) {
42270
42287
  clearTimeout(peer.failedCleanupTimer);
42271
42288
  peer.failedCleanupTimer = void 0;
42272
42289
  }
42273
- startHeartbeat(deps.peers, pid, deps.notifyStateChange);
42274
42290
  deps.notifyStateChange();
42275
42291
  } else if (pcState === "failed" || pcState === "closed") {
42276
42292
  peer.state = "failed";
@@ -42293,6 +42309,7 @@ async function initiateConnection(deps, peerId, sharePermission) {
42293
42309
  const peer = deps.peers.get(pid);
42294
42310
  if (peer) {
42295
42311
  peer.state = "connected";
42312
+ startHeartbeat(deps.peers, pid, deps.notifyStateChange);
42296
42313
  deps.notifyStateChange();
42297
42314
  if (peer.screenshotActive) {
42298
42315
  log(`Screenshots auto-starting for peer ${pid} (was waiting for channel open)`);
@@ -50075,7 +50092,7 @@ var init_adhdev_daemon = __esm({
50075
50092
  import_ws3 = require("ws");
50076
50093
  import_chalk2 = __toESM(require("chalk"));
50077
50094
  init_version();
50078
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.46" });
50095
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.47" });
50079
50096
  ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
50080
50097
  "generating",
50081
50098
  "waiting_approval",