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/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 {
@@ -41758,7 +41776,6 @@ async function initiateConnection(deps, peerId, sharePermission) {
41758
41776
  const peer = deps.peers.get(pid);
41759
41777
  if (!peer) return;
41760
41778
  if (pcState === "connected") {
41761
- peer.state = "connected";
41762
41779
  try {
41763
41780
  const pair = pc.getSelectedCandidatePair?.();
41764
41781
  if (pair) {
@@ -41773,7 +41790,6 @@ async function initiateConnection(deps, peerId, sharePermission) {
41773
41790
  clearTimeout(peer.failedCleanupTimer);
41774
41791
  peer.failedCleanupTimer = void 0;
41775
41792
  }
41776
- startHeartbeat(deps.peers, pid, deps.notifyStateChange);
41777
41793
  deps.notifyStateChange();
41778
41794
  } else if (pcState === "failed" || pcState === "closed") {
41779
41795
  peer.state = "failed";
@@ -41796,6 +41812,7 @@ async function initiateConnection(deps, peerId, sharePermission) {
41796
41812
  const peer = deps.peers.get(pid);
41797
41813
  if (peer) {
41798
41814
  peer.state = "connected";
41815
+ startHeartbeat(deps.peers, pid, deps.notifyStateChange);
41799
41816
  deps.notifyStateChange();
41800
41817
  if (peer.screenshotActive) {
41801
41818
  log(`Screenshots auto-starting for peer ${pid} (was waiting for channel open)`);
@@ -49526,7 +49543,7 @@ var init_adhdev_daemon = __esm({
49526
49543
  import_ws3 = require("ws");
49527
49544
  import_chalk2 = __toESM(require("chalk"));
49528
49545
  init_version();
49529
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.46" });
49546
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.47" });
49530
49547
  ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
49531
49548
  "generating",
49532
49549
  "waiting_approval",