fix(frontend): Refresh playground triggers when an agent tool settles - #5863
Open
ashrafchowdury wants to merge 2 commits into
Open
fix(frontend): Refresh playground triggers when an agent tool settles#5863ashrafchowdury wants to merge 2 commits into
ashrafchowdury wants to merge 2 commits into
Conversation
Agent platform ops (create_schedule, remove_schedule, pause/resume_schedule and the four subscription equivalents) execute server-side — the runner POSTs the API endpoint directly — so the browser never learns the trigger lists changed. The playground config panel's Triggers section renders from a singleton TanStack query with a 30s staleTime and no window-focus refetch, so it kept showing the pre-call list until a full page reload. Detect the settled tool call by wire name in the chat stream and invalidate the matching trigger query keys, mirroring how useFileActivityDetector reacts to settled write-ish tools. The seen-set is seeded from a session's history at mount so reopening a session doesn't replay it as refetches. Also hoists the two module-private invalidate helpers in @agenta/entities into one shared gatewayTrigger/state/invalidate module (query keys now live in one place), and exports isToolPart from messageParts rather than adding another copy of that predicate. Fixes #5781 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughChangesTool cache invalidation
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 65ecd5f1-8128-479e-be5f-4f06aca2b328
📒 Files selected for processing (14)
web/oss/src/components/AgentChatSlice/assets/messageParts.tsweb/oss/src/components/AgentChatSlice/assets/toolCacheEffects.test.tsweb/oss/src/components/AgentChatSlice/assets/toolCacheEffects.tsweb/oss/src/components/AgentChatSlice/assets/toolDisplay.test.tsweb/oss/src/components/AgentChatSlice/assets/toolDisplay.tsweb/oss/src/components/AgentChatSlice/components/ApprovalDock.tsxweb/oss/src/components/AgentChatSlice/hooks/useAgentChatSession.tsweb/oss/src/components/AgentChatSlice/hooks/useFileActivityDetector.tsweb/oss/src/components/AgentChatSlice/hooks/useToolCacheInvalidation.tsweb/packages/agenta-entities/src/gatewayTrigger/hooks/useTriggerSchedule.tsweb/packages/agenta-entities/src/gatewayTrigger/hooks/useTriggerSubscription.tsweb/packages/agenta-entities/src/gatewayTrigger/index.tsweb/packages/agenta-entities/src/gatewayTrigger/state/index.tsweb/packages/agenta-entities/src/gatewayTrigger/state/invalidate.ts
Contributor
Railway Preview Environment
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Ask an agent in the playground to schedule something. It calls
create_schedule, tells you it worked, and the Triggers section of the config panel keeps showing the old list until you reload the page.Platform ops run server-side. The runner POSTs the API endpoint directly, so the browser never sees the request and never learns the trigger list changed. The Triggers section reads a TanStack query with a 30s
staleTimeand no refetch on window focus, so nothing invalidates it.Changes
A settled tool call in the chat stream is the only signal the client gets, so this PR reacts to it. A small registry maps the eight mutating trigger ops from
op_catalog.pyto the cache they stale, anduseToolCacheInvalidationscans the streaming assistant turn and invalidates the matching query keys.list_*,discover_triggers, andtest_subscriptionchange nothing, so they are absent from the registry. Onlyoutput-availablecounts, so a failed create does not invalidate.This mirrors
useFileActivityDetector, which already reacts to settled write-ish tools the same way. EachtoolCallIdacts once, and the first pass of a session only records its history, so reopening a session does not replay it as refetches.The registry keys on the canonical tool name, not the wire name. The same op arrives under three spellings depending on the harness, because Claude and Codex receive our platform tools through the runner's internal
agenta-toolsMCP server:canonicalToolNamealready unwrapped Claude's form. It now unwraps Codex's dot form too, matching the runner's ownbareToolNamestripper inclient-tools.ts. Only our server is unwrapped, so a third-partymcp__other__create_schedulestill resolves to nothing and cannot invalidate your cache. That extension also fixes a second surface: Codex-harness approval cards forcommit_revisionwere falling back to the generic raw-JSON renderer for the same reason.Two small cleanups came along. The two module-private invalidate helpers in
@agenta/entitiesmerge into onegatewayTrigger/state/invalidatemodule, so the trigger query keys live in one place. And the three inline copies of theisToolPartpredicate collapse onto the one exported frommessageParts.Tests
npx vitest run src/components/AgentChatSliceinweb/oss: 144 passing.tsc --noEmitandpnpm lint-fixclean.Worth a reviewer's eye: this is a client-side stand-in. The durable fix is a backend signal on the stream, such as a
data-committed-revisionframe, and the registry should go away when the runner can emit one.What to QA