fix(#496): keep the adopted thread anchor authoritative across DAP responses/events - #504
Merged
Merged
Conversation
…sponses/events
The functional-core state echo in handleProxyMessage copied
dapState.currentThreadId (written only by the stopped handler) back over
the imperative anchor on every DAP response, every event (even output),
and status messages. Any anchor adopted via setCurrentThreadId() — the
frameless-thread fallback and get_stack_trace {threadId} (#465) — was
reverted by the next proxy message: list_threads clobbered it, and each
inspection call consumed it via its own response.
The imperative currentThreadId is now authoritative (the stopped fast
path writes it; the echo is gone), and both adoption paths mirror into
the functional-core snapshot so the stores cannot disagree. A genuine
stopped event still re-anchors unconditionally.
Closes #496
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
Fixes #496 —
list_threads(and in fact any DAP response or event) reverted the thread anchor adopted byget_stack_trace's frameless-thread fallback or by an explicitget_stack_trace {threadId}(#465), making the anchor single-use and breaking the natural stack → threads → locals flow on any adapter whose stopped thread reports no frames (deterministic on .NET attach).Root cause
Two copies of the anchor exist: the imperative
ProxyManager.currentThreadIdand the functional-coredapState.currentThreadId(written only by thestoppedhandler, read by nothing in dap-core).setCurrentThreadId()wrote only the imperative field, whilehandleProxyMessagegot anewStateback from the pure core for every message and copied the stale core value (the old stopped thread) back over the imperative field. One restore, both reported symptoms:list_threads→ threads response →newState→ anchor reverted (the reported clobber);Fix
currentThreadIdrestore from the core-state sync (theisInitialized/adapterConfiguredsyncs stay — those are load-bearing). The imperative field is authoritative; the stopped fast path inhandleDapEventwrites it.setCurrentThreadId()and the ProxyManager clobbers currentThreadId with threads[0] on every 'threads' response #396 threads[0] adoption into the core snapshot viasetCurrentThreadId(state, tid)from dap-core, so the two stores cannot disagree again.stoppedevent still re-anchors unconditionally.Tests
New
adopted thread anchor persistence (issue #496)suite intests/unit/proxy/proxy-manager.start.test.ts— written first and confirmed red on main (each failingexpected 1 to be 2, the exact clobber):threadsresponse (thelist_threadscase) — red → greenoutputevent — red → greenstackTraceresponse (not single-use) — red → greenstoppedevent still re-anchors (overcorrection guard) — green before and afterRegression-checked green:
proxy-manager.start/proxy-manager-message-handling/proxy-manager.branch-coverage/dap-core handlers+state/session-manager-dapsuites, plus the full unit suite (229 files, 4184 tests).🤖 Generated with Claude Code