safari-mcp 2.15.3 → 2.15.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/safari.js +11 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "safari-mcp",
3
- "version": "2.15.3",
3
+ "version": "2.15.4",
4
4
  "mcpName": "io.github.achiya-automation/safari-mcp",
5
5
  "description": "Safari browser automation for AI agents — native macOS, zero Chrome overhead. 96 tools via AppleScript + JavaScript.",
6
6
  "type": "module",
package/safari.js CHANGED
@@ -670,7 +670,7 @@ async function resolveActiveTab() {
670
670
  // Parse result — can be "N" (found) or "0:tabCount" (not found)
671
671
  const resultStr = String(result);
672
672
  if (resultStr.includes(':')) {
673
- // Not found — clamp stale index to tabCount
673
+ // Not found — every exit below fails closed (drops the index); nothing here guesses.
674
674
  const tabCount = Number(resultStr.split(':')[1]) || 1;
675
675
  _st().lastTabCount = tabCount;
676
676
  _st().activeTabURL = null;
@@ -682,8 +682,16 @@ async function resolveActiveTab() {
682
682
  return null;
683
683
  }
684
684
  if (_st().activeTabIndex && _st().activeTabIndex > tabCount) {
685
- console.error(`[Safari MCP] Tab ghost proactive fix: index ${_st().activeTabIndex} > tabCount ${tabCount}, clamping to ${tabCount}`);
686
- _st().activeTabIndex = tabCount;
685
+ // Our index is past the end of the window: the user closed a tab or tore one
686
+ // into its own window, so the index no longer names any tab — least of all ours.
687
+ // This used to clamp to `tabCount` ("tab ghost proactive fix"), which silently
688
+ // retargeted us at the LAST tab in the window — the user's. That predates the
689
+ // identity marker (clamp: Mar 31, marker: v2.8.3 Apr 14) and was the one exit
690
+ // here that still guessed. Fail closed like the two branches above; callers
691
+ // re-anchor via _assertNotFallingBackToUserTab's "re-run safari_new_tab" error.
692
+ console.error(`[Safari MCP] Tab identity lost (index ${_st().activeTabIndex} > tabCount ${tabCount}) — clearing index to avoid targeting the user's tab`);
693
+ _st().activeTabIndex = null;
694
+ return null;
687
695
  }
688
696
  return _st().activeTabIndex;
689
697
  }