Skip to content

fix(editormcp): send a tool call's change notices when it ends - #2716

Merged
houko merged 2 commits into
mainfrom
fix/flaky-editormcp-tests
Dec 1, 2026
Merged

houko merged 2 commits into
mainfrom
fix/flaky-editormcp-tests

Conversation

@houko

@houko houko commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the one test in pkg/editor/editormcp that is still flaky on main, and records why the other editormcp failures CI showed over the last two days need no change here.

TestChangeStream: flaky, fixed here

Failed on Linux CI after the merge train repairs (7323027) on unrelated branches, for example runs 46347725233 and 46492636674: notice &{Meta:map[nsgo.dev/by:agent nsgo.dev/revision:15] URI:editor://selection}, want editor://selection by person.

Root cause. A tool call is not one editor call. scene_edit reaches the editor through Server.Editor for its permission and live step checks, its checkpoint turn, its edit, its reply and the save warning, and each of those runs ended by waking the change notice sender. Those repairs made an agent's notices wait for the outermost agent call on the editor's goroutine, so when the sender drained the queue between two runs of the same tool call, the subscriber got the selection twice from one scene_edit, the second at a later revision.

Fix. callWithSessionManaged marks the context of the outermost tool call with a toolCall. asAgent keeps the notices of a run whose context belongs to a tool call still running, and endToolCall wakes the sender when the call returns. A tool another tool calls shares the outer call's mark, so only the outermost call sends. Work a call starts that outlives it, with the call's context, sees the call as ended and wakes the sender itself; a tool call nested in an agent run on the editor's goroutine leaves its notices to that run, as nested agent runs already did. The person's changes still wake the sender at once.

TestChangeStreamSendsOneNoticePerToolCall holds a tool between two editor runs and fails if a notice arrives in between.

Verification. On a Mac Studio, the new test fails without the fix (notice ... editor://selection sent while the call was still running, 10 of 10 runs); with it, go tool nsgo test ./pkg/editor/editormcp -- -run '^TestChangeStream' -count=50 -race -cpu=1,2,8 passed 300 of 300, and the whole package passes under -race. Linux and Windows CI on this PR run both tests in the test and race detector jobs.

Other editormcp failures: already fixed on main, no change here

  • TestPhoneWebBuildPlayModeBridgeHeadlessBrowserIntegration (Windows only, 10 runs incl. main): two causes, both fixed on main on 2026-11-30. go tool nsgo build -target web failed when Depot's external Go cache could not rename its own entries (Access is denied), fixed by 8debaf1 (the nested build uses the native Go cache); and TempDir RemoveAll hit Chrome's cache files still held by its child processes after the browser was killed, fixed by a15e376 (the profile lives outside t.TempDir and its removal waits for the sharing locks to clear). The test stops the browser itself (stopAndWait in a cleanup). No failure since.
  • TestProxyBindsSessionToTaskIDFromEnv (one Linux race run, 46336317708): the race detector blamed it for a race the previous test left behind, TestMCPTasksSubmitRunsDefaultRunnerAndAdvancesQueue closing the server off the editor's goroutine while the headless drain finished a task. Fixed by cf7ec00, which closes it inside RunHeadless.
  • TestServerOpenFollowsTheProject (Linux race runs 46312333478 and 46355661365): Server.Close closed SDK sessions still being bound by Connect, a data race and a nil dereference. Fixed by 8db9183 (close endpoint sockets and only fully bound direct sessions).
  • TestProxyBindsSessionToTaskIDFromEnv and TestServerOpenFollowsTheProject on Windows (every Windows run, 2026-11-29 04:06 to 07:30 UTC, incl. main): genuine, not flaky. The endpoint socket path under the Windows temp directory was longer than the 103 bytes a socket path may have; fixed by f4df555, which keeps the test endpoint directory short on Windows.
  • TestServerListsToolsAndResources, TestProxyFindsTheEditor, TestSceneEditReportsOverrideLocationAndNoOpHistory, TestBuiltInAgentEndToEndWithNSGoTestSecretsAndMCPTools, and TestChangeStream before 2026-11-30 01:30 UTC: genuine, not flaky. They failed on every platform on every run, main included, while main was broken by merged branches that added tools without updating the tool lists, fused scene version tests, and changed notice and instanced object handling. The repairs on 2026-11-30 (30e4250, 7323027 and the commits around them) fixed them.

@houko
houko force-pushed the fix/flaky-editormcp-tests branch from a27ac7f to 8b4edce Compare December 1, 2026 00:26
@github-actions github-actions Bot added documentation Improvements or additions to documentation pkg/editor area/agents bug Something isn't working size/M labels Dec 1, 2026
@houko
houko force-pushed the fix/flaky-editormcp-tests branch from 9d4d2f5 to c5117ee Compare December 1, 2026 01:24
@houko
houko merged commit 209f5d5 into main Dec 1, 2026
105 checks passed
@houko
houko deleted the fix/flaky-editormcp-tests branch December 1, 2026 02:34
@houko

houko commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

The Build the coop2d template (linux_x64) failure on 8b4edce (job 142294332478) is unrelated to this PR: GitHub answered the AppImage runtime download (AppImage/type2-runtime 20251108 runtime-x86_64) with HTTP 618, a transient download failure; this PR only touches pkg/editor/editormcp. A rerun of that job (job 142358432479) passed, and the job also passed on the PR's final head. The missing retry in NSGo's pinned downloads is tracked in nsgo-dev/nsgo#2815.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agents bug Something isn't working documentation Improvements or additions to documentation pkg/editor size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant