Skip to content

fix(grok): preserve conversation across repeated ask calls#332

Open
Astro-Han wants to merge 1 commit intojackwener:mainfrom
Astro-Han:worktree-fix-grok-session
Open

fix(grok): preserve conversation across repeated ask calls#332
Astro-Han wants to merge 1 commit intojackwener:mainfrom
Astro-Han:worktree-fix-grok-session

Conversation

@Astro-Han
Copy link
Contributor

Description

Fix session continuity for grok ask — repeated calls now continue the same conversation instead of creating a new one each time.

Root cause: the adapter unconditionally navigated to https://grok.com/ (the new-chat homepage) on every invocation, destroying the existing conversation URL. Since the browser daemon already reuses the same Chrome tab across commands, simply skipping the navigation lets the tab stay on the current chat thread.

Related issue: #330

Type of Change

  • 🐛 Bug fix

Checklist

  • I ran the checks relevant to this PR
  • I updated tests or docs if needed
  • I included output or screenshots when useful

Changes

  • isOnGrok() helper — checks window.location.href hostname to determine if the tab is already on grok.com, using new URL().hostname for precise matching (rejects fakegrok.com etc.)
  • runDefaultAsk — replaced unconditional page.goto(GROK_URL) with conditional navigation: only when newChat=true or tab is not on grok.com
  • runExplicitWebAsk — same conditional navigation logic
  • Dead code cleanup — the old if (newChat) block in runDefaultAsk (lines 62-73) was overridden by the unconditional goto on line 75; now newChat properly calls tryStartFreshChat()
  • Tests — 4 new unit tests for isOnGrok covering: grok.com URLs, subdomains, non-grok domains, and detached tab errors

Screenshots / Output

 Test Files  1 passed (1)
      Tests  8 passed (8)

…#330)

The adapter unconditionally navigated to grok.com/ on every invocation,
destroying the existing conversation URL even when --new was not passed.
Since the browser daemon already reuses the same Chrome tab, skipping
navigation lets the tab stay on the current chat thread.

- Only navigate to grok.com/ when --new is true or tab is not on grok.com
- Add tryStartFreshChat to the default path's --new branch (was dead code)
- Add isOnGrok helper with hostname-based domain matching
- Add unit tests for isOnGrok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant