Repository navigation
Conversation
The agent can read what a browser panel shares (mobile_read_panel_context) but not clear it, so notes it already acted on stay in the panel and are read again. Add mobile_clear_panel_context: the server forgets the tabs' context and counts the clear per tab; the page polls that count (the server keeps no idle stream to push on) and reports it to the panel in the host context, where PanelContext drops the notes it still shows.
|
@budet-b is attempting to deploy a commit to the Margelo Team on Vercel. A member of the Team first needs to authorize it. |
mobile_clear_panel_context destroyed notes the agent never saw and left the device selection unreadable until the user changed it: - The server forgets a tab's context only when it was read since its last store; newer notes are kept and the result says so. A clear with no connected tab or no shared content says there is nothing to clear instead of reusing the read tool's guidance. - Storing context returns the count it was stored under; the page polls only while its tab has stored content and ignores counts its content was stored under, so a clear racing a fresh note no longer drops it. - The panel republishes after dropping cleared notes, so the device selection survives the clear, and host context updates wait for the bridge to connect. - The tool no longer advertises idempotence, the server counts cleared context updates and the panel counts ui.context.agent_clear. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
budet-b
marked this pull request as ready for review
November 9, 2026 17:43
This branch has not been deployed
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.
Problem
The agent can read what a browser panel shares (
mobile_read_panel_context), but has no way to clear it. Notes the user adds to the panel stay in the shared context after the agent has acted on them, so every later read returns the same already-handled notes again.Solution
A new MCP tool,
mobile_clear_panel_context, in three pieces:packages/core/src/browser-panel.ts): the tool forgets each browser-panel tab's stored context and increments a per-tabclearscounter. It only forgets what the agent has read: each store bumps a per-tab revision, reading stamps it, and a tab whose content was stored or changed since the last read keeps it (the result says so, and tells the agent to read again). A clear with no connected tab, or no shared content, says there is nothing to clear.GET <base>contextreturns{ clears }(it previously answered 405), and storing context now returns the count it was stored under.packages/mcp-app/src/browser-panel.ts): while its tab has stored content, the page polls the clears count from its own session'scontextendpoint every 2 seconds and hands it to the panel in the host context under themobile-dev/contextClearskey (CONTEXT_CLEARSinpackages/shared/src/panel-target.ts). It ignores counts its current content was stored under, so a clear that raced a fresh note cannot drop that note. A tab that never shared anything does not poll.packages/ui/src/model-context.ts):PanelContext.hostChanged()drops the notes the panel still displays when the counter increases, then republishes, so the user's device selection survives the clear and stays readable. The value seen on open is treated as a baseline, not as a clear.Details that came out of self-review:
idempotentHint: false(each call moves the counter, and a blind retry could drop notes added in between) alongsidedestructiveHint: true.browser_panel.context_updatewith outcomecleared) and the panel countsui.context.agent_clear.Why polling?
The browser-panel transport deliberately keeps no idle stream (tool and resource responses use per-request SSE only), so the server has nothing to push the clear notification on. A 2-second poll of the existing
contextendpoint seemed like the smallest change consistent with that design; it only runs while the tab has stored content, and the page already pings every 30 seconds regardless.Tests
packages/core/test/browser-panel.test.ts: the clear flow end to end over HTTP — unread notes are kept, read notes clear, a changed note survives a stale clear, a tab with nothing stored is not told to drop anything, the kept/cleared mixed case across two tabs, the store response carries the count, and the idempotence annotation.packages/ui/test/context-clears.test.ts: 5 tests for the panel-side behavior (drop on increment, baseline on open, republish after a drop, republish with no notes so the devices survive).tooling/hosts/browser-panel.spec.ts: a new Playwright test drives the real page through read → clear → 2-second poll → republish and checks the device context stays readable.CONTRIBUTING.mdandapps/claude/skills/mobile-dev/SKILL.md.Verified
npm test: 1259 pass, 0 fail, 1 skipped — twice in a row), as do the targeted files (node --test packages/core/test/browser-panel.test.ts packages/ui/test/context-clears.test.ts packages/ui/test/log-context.test.ts: 42 pass, 0 fail).browserhost project passes (playwright test -c tooling/hosts browser-panel.spec.ts --project=browser: 7 passed), including the new end-to-end clear test.tsc --noEmitreports no new errors against the repository's current baseline.npm run build+npm run package:claude), installed it in Claude Code, and confirmed the agent can clear the panel's notes and the open panel drops them. Not repeated after the second commit.Not verified / known noise
test:visual:docker) was not run; this change adds no visual difference I'm aware of, but I have not confirmed that with screenshots.Open questions for maintainers
contextendpoint acceptable while a tab has stored content, or would you prefer a longer interval (or piggybacking on the existing 30-second ping)?🤖 Generated with Claude Code