Fix #502 follow-up: the advice reads the captured query too - #512
Merged
Conversation
#504 recovered the captured query for Copy Query Text and Open in Query Editor but left Human Advice, Robot Advice, and the MCP tools analyzing the plan's 4,000-character stub - the surface the reporter actually screenshotted, so the nightly read as no fix at all. ResultMapper.Map now takes the captured query text and substitutes it for a single-statement plan whose text hit the showplan cap, under the same guard as the viewer's PlanOrCapturedStatementText. The model is untouched: Rule 39 and the properties panel keep reporting what the plan records; only the mapped output carries the recovery, and its truncation warning then says the text was recovered instead of contradicting the complete query beside it. Every caller that holds the text passes it: query-editor advice (selected tab and fallback, which also regains the server metadata it was silently dropping), file-mode advice, both compare dialogs, the MCP plan and Query Store tools, PlanOperations session analysis, and the CLI analyze (SQL input) and query-store commands. File/stream paths pass nothing - a .sqlplan alone has nothing to recover from. Verified end to end against SQL Server 2022: a 10,692-character single-statement query whose plan records 3,999 characters now shows the full query in the advice output. Six new tests; full suite 531 passed, 1 pre-existing skip, 0 failed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013tW5wVxgbtcCegPuC6Zbqe
|
Reviewed the diff ( Notes from the review, for the record:
Nothing to flag. |
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.
Fixes #502, for the surface the reporter actually screenshotted. Follow-up to #504.
What #504 missed
#504 recovered the captured query for Copy Query Text and Open in Query Editor, and its "Not covered" section deliberately left Human Advice and Robot Advice analyzing the plan's short copy. The reporter's screenshot is the Human Advice pane, so the nightly read as "cutting same as before" — his words on the issue.
The premise checks out against a real server: a 10,692-character single-statement query captured on SQL Server 2022 comes back with
StatementTextat exactly 3,999 characters, cut mid-token.The fix
ResultMapper.Maptakes the captured query text and substitutes it for a single-statement plan whose text hit the cap — the same guard as the viewer'sPlanOrCapturedStatementText, for the same reason: the captured text is the whole batch, showplan records no statement offsets, and with more than one statement there is no way to say which slice belongs to which row. A confidently wrong query is worse than a short one.The model is untouched. Rule 39 and the properties panel keep reporting what the plan records; only the mapped output carries the recovery. When it happened, the mapped truncation warning says the text was recovered instead of describing a shortened statement right next to the complete query. Rule 39's base message also stops claiming Copy/Open work from the shortened version — #504 already made that false.
Who passes the text now
Every caller that holds it:
_serverMetadatait was silently dropping, so its advice keeps the Server Context sectionsession.QueryText) and MCP Query Store capture (fullquery_sql_text)PlanOperationssession analysisanalyzewith SQL input (it executed the query itself) and CLIquery-storeFile/stream paths pass nothing — a .sqlplan alone has nothing to recover from, and Rule 39 explains why the text is short.
Verified end to end
The real SQL Server 2022 plan above, run through the pipeline: advice statement text goes from 3,999 characters to the full 10,692,
TextFormatteroutput contains the whole query, and the warning explains the recovery.Tests
Six new in
TruncatedStatementTextTests(single-statement recovery through to the Human Advice text, warning message swap with the model's warning untouched, multi-statement and uncaptured and untruncated all unchanged, parameter substitution over the recovered text with theParameterizedStatementTextpairing intact). Full suite 531 passed, 1 pre-existing skip, 0 failed.🤖 Generated with Claude Code
https://claude.ai/code/session_013tW5wVxgbtcCegPuC6Zbqe