browser-workspace 0.4.0 → 0.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-workspace",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Agent browser workspace with persistent sessions, tab leasing, snapshots, and platform workflows.",
5
5
  "bin": {
6
6
  "browser-workspace": "bin/browser-workspace"
@@ -17,7 +17,7 @@ def open_or_reuse_xhs(url):
17
17
  target=tabs[0] if tabs else None
18
18
  if target:
19
19
  switch_tab(target)
20
- if page_info()["url"] != url:
20
+ if (current_tab().get("url") or "") != url:
21
21
  goto_url(url)
22
22
  else:
23
23
  new_tab(url)
@@ -86,7 +86,7 @@ def open_update_editor(row):
86
86
  return None, clicked
87
87
  for _ in range(30):
88
88
  time.sleep(.5)
89
- url=page_info()["url"]
89
+ url=current_tab().get("url") or ""
90
90
  if "/publish/update" in url:
91
91
  tab=current_tab()
92
92
  return {"update_url":url,"target_id":tab.get("targetId") or tab.get("target_id")}, None
@@ -212,7 +212,7 @@ def open_post_detail(note_id):
212
212
  ready=js('document.querySelector(".note-container") ? "yes" : "no"')
213
213
  if ready!="yes":
214
214
  return None, "post_detail_not_opened"
215
- return {"profile_url":profile,"detail_url":page_info()["url"]}, None
215
+ return {"profile_url":profile,"detail_url":current_tab().get("url") or ""}, None
216
216
 
217
217
 
218
218
  def expand_replies():
@@ -17,7 +17,7 @@ def open_or_reuse_xhs(url):
17
17
  target=tabs[0] if tabs else None
18
18
  if target:
19
19
  switch_tab(target)
20
- if page_info()["url"] != url:
20
+ if (current_tab().get("url") or "") != url:
21
21
  goto_url(url)
22
22
  else:
23
23
  new_tab(url)
@@ -47,7 +47,7 @@ open_or_reuse_xhs("https://creator.xiaohongshu.com/publish/publish")
47
47
  wait_for_load()
48
48
  time.sleep(3)
49
49
 
50
- url = page_info()["url"]
50
+ url = current_tab().get("url") or ""
51
51
  if "login" in url:
52
52
  print("ERROR: Not logged in. Log in at creator.xiaohongshu.com first.")
53
53
  capture_screenshot()
@@ -0,0 +1,17 @@
1
+ from pathlib import Path
2
+
3
+
4
+ HERE = Path(__file__).resolve().parents[1]
5
+
6
+
7
+ def test_actions_do_not_use_page_info_as_tab_url_authority():
8
+ for name in ("_post.py", "_manage.py"):
9
+ source = (HERE / "actions" / name).read_text()
10
+ assert 'page_info()["url"]' not in source
11
+
12
+
13
+ def test_actions_use_current_tab_url_for_navigation_identity():
14
+ post = (HERE / "actions" / "_post.py").read_text()
15
+ manage = (HERE / "actions" / "_manage.py").read_text()
16
+ assert '(current_tab().get("url") or "") != url' in post
17
+ assert '(current_tab().get("url") or "") != url' in manage