adhdev 0.8.46 → 0.8.48

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 {
@@ -10634,14 +10652,18 @@ var init_cli_provider_instance = __esm({
10634
10652
  }
10635
10653
  const runtime = this.adapter.getRuntimeMetadata();
10636
10654
  this.maybeAppendRuntimeRecoveryMessage(runtime);
10637
- const parsedMessages = Array.isArray(parsedStatus?.messages) ? parsedStatus.messages : [];
10655
+ let parsedMessages = Array.isArray(parsedStatus?.messages) ? parsedStatus.messages : [];
10656
+ const historyMessageCount = Number.isFinite(parsedStatus?.historyMessageCount) ? Math.max(0, Number(parsedStatus.historyMessageCount)) : null;
10657
+ if (historyMessageCount !== null) {
10658
+ parsedMessages = historyMessageCount > 0 ? parsedMessages.slice(-historyMessageCount) : [];
10659
+ }
10638
10660
  const controlValues = extractProviderControlValues(this.provider.controls, parsedStatus);
10639
10661
  if (controlValues) {
10640
- this.controlValues = controlValues;
10641
- } else if (Object.keys(this.controlValues).length > 0) {
10642
- this.controlValues = {};
10662
+ this.controlValues = { ...this.controlValues, ...controlValues };
10643
10663
  }
10644
10664
  const mergedMessages = this.mergeConversationMessages(parsedMessages);
10665
+ const currentModel = typeof parsedStatus?.model === "string" && parsedStatus.model.trim() ? parsedStatus.model.trim() : typeof this.controlValues.model === "string" && this.controlValues.model.trim() ? this.controlValues.model.trim() : void 0;
10666
+ const currentPlan = typeof parsedStatus?.mode === "string" && parsedStatus.mode.trim() ? parsedStatus.mode.trim() : typeof this.controlValues.mode === "string" && this.controlValues.mode.trim() ? this.controlValues.mode.trim() : void 0;
10645
10667
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
10646
10668
  if (parsedMessages.length > 0) {
10647
10669
  const shouldSkipReplayPersist = this.suppressIdleHistoryReplay && adapterStatus.status === "idle" && parsedStatus?.status === "idle";
@@ -10678,6 +10700,8 @@ var init_cli_provider_instance = __esm({
10678
10700
  inputContent: ""
10679
10701
  },
10680
10702
  workspace: this.workingDir,
10703
+ currentModel,
10704
+ currentPlan,
10681
10705
  instanceId: this.instanceId,
10682
10706
  providerSessionId: this.providerSessionId,
10683
10707
  lastUpdated: Date.now(),
@@ -10867,6 +10891,15 @@ var init_cli_provider_instance = __esm({
10867
10891
  }
10868
10892
  applyProviderResponse(data, options) {
10869
10893
  if (!data || typeof data !== "object") return;
10894
+ const patchedProviderSessionId = typeof data.providerSessionId === "string" ? data.providerSessionId.trim() : "";
10895
+ if (patchedProviderSessionId) {
10896
+ this.promoteProviderSessionId(patchedProviderSessionId);
10897
+ }
10898
+ if (data.sessionEvent === "new_session") {
10899
+ this.runtimeMessages = [];
10900
+ this.suppressIdleHistoryReplay = false;
10901
+ this.adapter.clearHistory();
10902
+ }
10870
10903
  const controlValues = extractProviderControlValues(this.provider.controls, data);
10871
10904
  if (controlValues) {
10872
10905
  this.controlValues = { ...this.controlValues, ...controlValues };
@@ -42255,7 +42288,6 @@ async function initiateConnection(deps, peerId, sharePermission) {
42255
42288
  const peer = deps.peers.get(pid);
42256
42289
  if (!peer) return;
42257
42290
  if (pcState === "connected") {
42258
- peer.state = "connected";
42259
42291
  try {
42260
42292
  const pair = pc.getSelectedCandidatePair?.();
42261
42293
  if (pair) {
@@ -42270,7 +42302,6 @@ async function initiateConnection(deps, peerId, sharePermission) {
42270
42302
  clearTimeout(peer.failedCleanupTimer);
42271
42303
  peer.failedCleanupTimer = void 0;
42272
42304
  }
42273
- startHeartbeat(deps.peers, pid, deps.notifyStateChange);
42274
42305
  deps.notifyStateChange();
42275
42306
  } else if (pcState === "failed" || pcState === "closed") {
42276
42307
  peer.state = "failed";
@@ -42293,6 +42324,7 @@ async function initiateConnection(deps, peerId, sharePermission) {
42293
42324
  const peer = deps.peers.get(pid);
42294
42325
  if (peer) {
42295
42326
  peer.state = "connected";
42327
+ startHeartbeat(deps.peers, pid, deps.notifyStateChange);
42296
42328
  deps.notifyStateChange();
42297
42329
  if (peer.screenshotActive) {
42298
42330
  log(`Screenshots auto-starting for peer ${pid} (was waiting for channel open)`);
@@ -50075,7 +50107,7 @@ var init_adhdev_daemon = __esm({
50075
50107
  import_ws3 = require("ws");
50076
50108
  import_chalk2 = __toESM(require("chalk"));
50077
50109
  init_version();
50078
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.46" });
50110
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.48" });
50079
50111
  ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
50080
50112
  "generating",
50081
50113
  "waiting_approval",