Skip to content

refactor(agent-shell): dedupe the duplicate useSessionRuntime(virtualMcpId) call - #6678

Merged
pedrofrxncx merged 1 commit into
mainfrom
refactor/dedupe-session-runtime-call-in-vm-events-bridge
Aug 28, 2026
Merged

refactor(agent-shell): dedupe the duplicate useSessionRuntime(virtualMcpId) call#6678
pedrofrxncx merged 1 commit into
mainfrom
refactor/dedupe-session-runtime-call-in-vm-events-bridge

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Follows #6639, which added the auto-fresh-branch staleness check to VmEventsBridge in apps/web/src/layouts/agent-shell-layout/index.tsx.

That PR's new code calls useSessionRuntime(virtualMcpId) for the CMS-runtime check, and the pre-existing code further down in the same component calls useSessionRuntime(virtualMcpId) again with the identical argument, to gate the sandbox-events subscription. Both calls resolve to the exact same SessionRuntime answer for the same render (same virtualMcpId, same underlying useVirtualMCP/useOptionalChatTask reads) — the second call is pure redundant recompute inside a component that already fires on every branch/task/session change.

Net: -5 / +3. Single call site, both usages now read from the same sessionState result — behavior is unchanged (verified the two derivations, cmsRuntime/cmsRuntimeResolved and sessionRuntime, are structurally identical reads off the same object).

A reviewer can confirm by diffing: both former call sites reduce to reads of one useSessionRuntime(virtualMcpId) result.

Locally ran: bun run fmt, bunx tsc --noEmit (apps/web — no new errors; one pre-existing, unrelated prosemirror-model version-skew error is present on main and untouched by this diff), bunx oxlint apps/web/src/layouts/agent-shell-layout/index.tsx (0 warnings/errors). No test file changes needed since this is a pure behavior-preserving call dedupe, not new logic. Full CI validates the rest.


Summary by cubic

Dedupes the duplicate useSessionRuntime(virtualMcpId) call in VmEventsBridge so the same session state is no longer recomputed twice per render. Behavior is unchanged: both the auto-fresh-branch staleness check and the sandbox-events gate now read from the single sessionState result.

Written for commit 0f32ee7. Summary will update on new commits.

Review in cubic

…McpId) call

VmEventsBridge called useSessionRuntime(virtualMcpId) twice with identical
args - once for the auto-fresh-branch staleness check (#6639), once further
down for the sandbox events gate. Both calls resolve to the same answer for
the same render; the second was pure recompute. Reuse the first result.
@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) August 28, 2026 13:07
@pedrofrxncx
pedrofrxncx merged commit 572b843 into main Aug 28, 2026
34 checks passed
@pedrofrxncx
pedrofrxncx deleted the refactor/dedupe-session-runtime-call-in-vm-events-bridge branch August 28, 2026 13:19
decocms Bot pushed a commit that referenced this pull request Aug 28, 2026
PR: #6678 refactor(agent-shell): dedupe the duplicate useSessionRuntime(virtualMcpId) call
Bump type: patch

- decocms (apps/api/package.json): 4.291.1 -> 4.291.2
- @decocms/native (apps/native/package.json): 4.291.1 -> 4.291.2

Deploy-Scope: web
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