Skip to content

Check context queries while they are typed - #45

Open
clillies wants to merge 2 commits into
intel:mainfrom
clillies:ctx-query
Open

clillies wants to merge 2 commits into
intel:mainfrom
clillies:ctx-query

Conversation

@clillies

@clillies clillies commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

A context query with a mistake was only refused by the agent once the session sent it. The user then saw an error, or a symbol file or breakpoint that applied to nothing, long after typing the query. Typical mistakes are IDs with '.' or '[' that are not in quotes, and HasState=True, which the agent takes as false without an error.

The context picker and the launch configurations editor now check the query. The checker follows the agent's parser, not only the grammar on the spec page, so it accepts what the agent accepts. It also knows the Simics IDList attribute. It rejects '"a"b', which the agent accepts but which can never match.

Problems show when the user stops typing for five seconds or tries to save the query, so a half-typed query is not marked at every key press. The input box of the picker cannot color text, so it names the column and the wrong part instead.

IDs in an IDList are not checked against the target, because the editor has no session to ask.

@clillies
clillies requested a review from a team as a code owner December 3, 2026 18:35
A context query with a mistake was only refused by the agent once the
session sent it. The user then saw an error, or a symbol file or
breakpoint that applied to nothing, long after typing the query.
Typical mistakes are IDs with '.' or '[' that are not in quotes, and
HasState=True, which the agent takes as false without an error.

The context picker and the launch configurations editor now check the
query. The checker follows the agent's parser, not only the grammar on
the spec page, so it accepts what the agent accepts. It also knows the
Simics IDList attribute. It rejects '"a"b', which the agent accepts but
which can never match.

Problems show when the user stops typing for five seconds or tries to
save the query, so a half-typed query is not marked at every key press.
The input box of the picker cannot color text, so it names the column
and the wrong part instead.

IDs in an IDList are not checked against the target, because the
editor has no session to ask.

Signed-off-by: Claes Lillieskold <claes.lillieskold@intel.com>
A context query can be valid and still not select the contexts the
user wants, for example when an ID has a typo. For a symbol file, a
query can also select only threads. Threads have no memory map of
their own, so the agent adds the file nowhere. The user only found
this out after the session started.

While a session to the agent runs, the query is now sent to
ContextQuery.query shortly after the user stops typing. The launch
configurations editor lists the contexts it selects, and for a symbol
file which of them get the file. The context picker tells how many. A
query the agent refuses is marked like the other problems, so the
mistakes the local checker misses are found too.

To type a query, the user also needs the attribute names and the
context IDs of the target. Suggestions now come from the agent
(ContextQuery.getAttrNames and the contexts of the session). Without
a session, only the wildcards and the common attributes are suggested.

In the editor, the query is typed in a box below the row, which has
room for the suggestions and the list of contexts. The screenshots in
docs/images/ are not made again yet.

Signed-off-by: Claes Lillieskold <claes.lillieskold@intel.com>
for `ID` and the IDs in an `IDList`. Names and IDs that need double quotes
get them. An `IDList` suggests the IDs of the contexts that can run and be
stopped, without quotes around them. It adds the `"[` when you type an ID
without it, as in `IDList="cpu`, and the `]"` when the list is not closed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IDList context query is not documented anywhere. I would say that it's an internal / tech preview type of context-query. Same for TreeID, although that is used internally by code-coverage.

We could remove any of these at any point. Should either be made official by documenting etc or not be exposed through this extension.

One thing I noticed with this is that we have missed to include some newer context query comparators from open source, ParentName, AncestorID and AncestorName from 61d5800f.

We should include those in base and include them here. AncestorID is rather close to TreeID, with the difference that TreeID includes the context with the provided id, while Ancestor excludes that.

Comment thread src/contextQuery.ts
}
const added = result.matches.filter((m) => m.ownMemoryMap).length;
if (added === 0) {
return `${selects}, but none has a memory map of its own, so the symbol file is added to none`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was rather confusing to me when I saw.
I tried to add a symbol file to "UEFI Firmware"/* and got this. Why would this not work. What does it mean that it's added to none? And that none has a memory map of its own, I am adding a memory map by adding a symbol file.

A strange thing around this is that this works perfectly fine when I add a symbol file with this context query in CLI, but when I add a symbol file like this in the extension I don't see the same stack trace. Shouldn't have anything to do with this PR I guess. Doesn't even work if I add to the specific context or all.

Comment thread src/contextQuery.ts
}

/** The names of `contexts` as completions, each once, with the ID of the context that has it. */
function contextNames(contexts: QueryContext[]): ContextQueryCompletion[] {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure from exact what part of the code it comes from, but the contexts shown in the view include the ISD specific contexts such as PLREG, CPUID etc. Likely contexts without state that exist under a context with state should be filtered out or something like that.

Comment thread src/contextQuery.ts
case "part":
items = [
{ label: "*", text: "*", detail: "Any context" },
{ label: "**", text: "**", detail: "Any number of contexts, also none" },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does ** clarify that it also applies to none but * does not. Both can apply to 0 or more contexts.

At top level (without any slashes included) then * and ** should be the same, but the explanation is rather different, can be confusing.

Comment thread src/contextQuery.ts
? "it"
: "all of them"
: added === 1
? "the one with a memory map of its own"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this rather confusing as well. What does it mean with "a memory map of its own" when I am adding a symbol file that adds a memory map?

@aragners
aragners self-requested a review December 4, 2026 09:21

@aragners aragners left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice in general, some output is confusing even to me.
And some queries and contexts are internal.

This branch has not been deployed

No deployments
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.

2 participants