@nextclaw/x-harness 0.2.50 → 0.2.52

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/SOURCE.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Corresponding source
2
2
 
3
- Version 0.2.50, commit 574f6379381dcf0bab9269f063474771df0067ee.
3
+ Version 0.2.52, commit b3e3310d4977db067f05ee409f58ae619f042c9a.
4
4
 
5
- Complete source, build scripts and dependencies: https://github.com/Peiiii/x-harness/tree/574f6379381dcf0bab9269f063474771df0067ee
5
+ Complete source, build scripts and dependencies: https://github.com/Peiiii/x-harness/tree/b3e3310d4977db067f05ee409f58ae619f042c9a
6
6
 
7
7
  Clone this revision, run npm ci, npm run bootstrap and npm run release:build.
8
8
 
@@ -26,6 +26,7 @@ export class DOMCapabilities {
26
26
  base.push(...missingMethods(this.#tab.playwright.locator("div"), [
27
27
  "filter",
28
28
  "count",
29
+ "nth",
29
30
  "click",
30
31
  "innerText",
31
32
  ]));
@@ -30,16 +30,23 @@ export class DOMNavigation {
30
30
  posts?.length !== 1 ||
31
31
  posts[0].quoteCards?.length !== 1 ||
32
32
  posts[0].quoteCards[0].text !== command.cardText)
33
- throw Error("unique-observed-quote-required");
33
+ throw Error(`unique-observed-quote-required:snapshot:${posts?.length ?? 0}:${posts?.[0]?.quoteCards?.length ?? 0}`);
34
34
  const article = this.#tab.playwright.getByRole("article").filter({
35
35
  has: this.#tab.playwright.locator(`a[href=${JSON.stringify(posts[0].primary)}]`),
36
36
  });
37
- const card = article
37
+ const cards = article
38
38
  .locator('[role="link"][tabindex="0"]')
39
- .filter({ visible: true, hasText: command.cardText });
40
- if ((await card.count()) !== 1 ||
41
- (await card.innerText()) !== command.cardText)
42
- throw Error("unique-observed-quote-required");
39
+ .filter({ visible: true });
40
+ const count = await cards.count();
41
+ const matches = [];
42
+ for (let i = 0; i < count; i++) {
43
+ const candidate = cards.nth(i);
44
+ if ((await candidate.innerText()) === command.cardText)
45
+ matches.push(candidate);
46
+ }
47
+ if (matches.length !== 1)
48
+ throw Error(`unique-observed-quote-required:controls:${count}:matches:${matches.length}`);
49
+ const card = matches[0];
43
50
  this.#session.current = null;
44
51
  await this.#tab.playwright.expectNavigation(() => card.click(), {
45
52
  waitUntil: "commit",
@@ -64,6 +71,12 @@ export class DOMNavigation {
64
71
  return;
65
72
  }
66
73
  async handleWaitForFolder(command) {
74
+ if (command.selected) {
75
+ await this.#tab.playwright
76
+ .getByRole("heading", { name: command.folder, exact: true })
77
+ .waitFor({ state: "visible", timeoutMs: 5000 });
78
+ return;
79
+ }
67
80
  if (command.folderDiscovery) {
68
81
  // "All bookmarks" renders before the asynchronously loaded named cards.
69
82
  // Wait for any named card inside that specific menu, never an unrelated
package/dist/browser.js CHANGED
@@ -138,7 +138,7 @@ export function readXSurface({ view, posts = [], targetId, replyTargetId, } = {}
138
138
  .querySelector?.("time")
139
139
  ?.getAttribute("datetime"),
140
140
  }))
141
- .filter((card) => card.text?.trim() && card.datetime)
141
+ .filter((card) => card.text?.trim())
142
142
  : [],
143
143
  };
144
144
  }),
@@ -9,6 +9,7 @@ export declare class PlatformCollections {
9
9
  private handleCollectSources;
10
10
  private handleReadCreator;
11
11
  private handleReadBookmarks;
12
+ private confirmBookmarkFolder;
12
13
  private bookmarkDiscovery;
13
14
  private waitForBookmarkLabel;
14
15
  private handleSearchSources;
@@ -294,15 +294,9 @@ export class PlatformCollections {
294
294
  folder,
295
295
  controls: nav.controls,
296
296
  };
297
- const selected = await this.#ready({ view: "navigation" });
298
- if (selected.page === nav.page && !selected.headings?.includes(folder))
299
- return {
300
- status: "needsDecision",
301
- complete: false,
302
- missing: ["folder-selection-unconfirmed"],
303
- folder,
304
- page: selected.page,
305
- };
297
+ const selected = await this.confirmBookmarkFolder(folder);
298
+ if (selected.status)
299
+ return selected;
306
300
  const value = await this.handleCollectSources(window);
307
301
  return {
308
302
  ...value,
@@ -314,6 +308,35 @@ export class PlatformCollections {
314
308
  },
315
309
  };
316
310
  }
311
+ async confirmBookmarkFolder(folder) {
312
+ let selected = await this.#ready({ view: "navigation" });
313
+ if (!selected.headings?.includes(folder)) {
314
+ try {
315
+ await this.#browser.act({
316
+ operation: "waitForFolder",
317
+ folder,
318
+ selected: true,
319
+ });
320
+ }
321
+ catch (error) {
322
+ if (!/timed out|timeout/i.test(error.message))
323
+ throw error;
324
+ }
325
+ selected = await this.#ready({ view: "navigation" });
326
+ }
327
+ if (!selected.headings?.includes(folder) ||
328
+ !/\/i\/(?:history\/)?bookmarks\//.test(selected.page ?? "") ||
329
+ selected.needsStateCheck ||
330
+ selected.alerts?.length)
331
+ return {
332
+ status: "needsDecision",
333
+ complete: false,
334
+ missing: ["folder-selection-unconfirmed"],
335
+ folder,
336
+ page: selected.page,
337
+ };
338
+ return selected;
339
+ }
317
340
  bookmarkDiscovery(nav) {
318
341
  const folders = nav.bookmarkFolders ?? [];
319
342
  return {
@@ -640,7 +640,7 @@ export const readXObservation = (query) => {
640
640
  .querySelector?.("time")
641
641
  ?.getAttribute("datetime"),
642
642
  }))
643
- .filter((card) => card.text?.trim() && card.datetime)
643
+ .filter((card) => card.text?.trim())
644
644
  : [],
645
645
  };
646
646
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/x-harness",
3
- "version": "0.2.50",
3
+ "version": "0.2.52",
4
4
  "type": "module",
5
5
  "description": "Typed X task harness with compact business results and explicit diagnostics.",
6
6
  "main": "./dist/index.js",
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "574f6379381dcf0bab9269f063474771df0067ee"
45
+ "gitHead": "b3e3310d4977db067f05ee409f58ae619f042c9a"
46
46
  }