Skip to content

[OPIK-5479] [FE] fix: clear cached pair code on runner connection#6035

Merged
ldaugusto merged 4 commits intomainfrom
daniela/opik-5479-pairing-code-expiration
Apr 1, 2026
Merged

[OPIK-5479] [FE] fix: clear cached pair code on runner connection#6035
ldaugusto merged 4 commits intomainfrom
daniela/opik-5479-pairing-code-expiration

Conversation

@ldaugusto
Copy link
Copy Markdown
Contributor

@ldaugusto ldaugusto commented Apr 1, 2026

Details

When using opik connect --pair <CODE>, the pairing succeeds on both sides but if the runner later disconnects under the code TTL, the FE re-displays the same (already consumed) pairing code. Since codes are single-use, reconnection always fails with "Invalid or expired pairing code".

Root cause: The backend deletes the pairing code from Redis on connection (getAndDelete), but the frontend keeps it in React Query cache. On a quick disconnection, the empty state renders with the stale cached code.

Fix: Call queryClient.removeQueries() to evict the pair code cache as soon as isConnected becomes true. When the runner later disconnects, React Query sees no cached data and fetches a fresh code on demand — no wasted TTL ticking while connected.

Change checklist

  • User facing
  • Documentation update

Issues

  • OPIK-5479

AI-WATERMARK

AI-WATERMARK: yes

  • Tools: Claude Code
  • Model(s): Claude Opus 4.6 (1M context)
  • Scope: full implementation
  • Human verification: code review + manual testing

Testing

  • FE build passes (npm run build)
  • Manual testing: connect agent via opik connect --pair, verify pair code is evicted from cache on connection, verify fresh code is fetched on disconnection

Documentation

N/A

When a runner connects, the backend immediately consumes the pairing
code (Redis getAndDelete). However the frontend kept the stale code
in React Query cache. If the runner later disconnected, the empty
state re-displayed the expired code, causing users to attempt
reconnection with a code that would always fail.

Fix: use queryClient.removeQueries() to evict the pair code cache
as soon as isConnected becomes true. On subsequent disconnection
React Query sees no cached data and fetches a fresh code on demand.
@ldaugusto ldaugusto requested a review from a team as a code owner April 1, 2026 14:09
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

📋 PR Linter Failed

Missing Section. The description is missing the ## Testing section.


Missing Section. The description is missing the ## Documentation section.

miguelgrc
miguelgrc previously approved these changes Apr 1, 2026
Copy link
Copy Markdown
Contributor

@miguelgrc miguelgrc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of it, LGTM! 🚀

@ldaugusto ldaugusto added the test-environment Deploy Opik adhoc environment label Apr 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

🔄 Test environment deployment process has started

Phase 1: Deploying base version 1.10.58-4771 (from main branch) if environment doesn't exist
Phase 2: Building new images from PR branch daniela/opik-5479-pairing-code-expiration
Phase 3: Will deploy newly built version after build completes

You can monitor the progress here.

Tests verify that:
- Empty state shows pair code when disconnected
- Connected state renders when runner is connected
- Pair code cache is cleared (removeQueries) on connection
- Pair code cache is NOT cleared when disconnected
@CometActions
Copy link
Copy Markdown
Collaborator

Test environment is now available!

To configure additional Environment variables for your environment, run [Deploy Opik AdHoc Environment workflow] (https://github.com/comet-ml/comet-deployment/actions/workflows/deploy_opik_adhoc_env.yaml)

Access Information

The deployment has completed successfully and the version has been verified.

@ldaugusto ldaugusto added test-environment Deploy Opik adhoc environment and removed test-environment Deploy Opik adhoc environment labels Apr 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

🔄 Test environment deployment process has started

Phase 1: Deploying base version 1.10.58-4771 (from main branch) if environment doesn't exist
Phase 2: Building new images from PR branch daniela/opik-5479-pairing-code-expiration
Phase 3: Will deploy newly built version after build completes

You can monitor the progress here.

@ldaugusto ldaugusto removed the test-environment Deploy Opik adhoc environment label Apr 1, 2026
@ldaugusto ldaugusto merged commit 50220cd into main Apr 1, 2026
10 checks passed
@ldaugusto ldaugusto deleted the daniela/opik-5479-pairing-code-expiration branch April 1, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants