-
Notifications
You must be signed in to change notification settings - Fork 431
Improve message path autocomplete logic #3190
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused about how this interacts with the code that does getExamplePrimitive
:
studio/packages/studio-base/src/components/MessagePathSyntax/MessagePathInput.tsx
Line 331 in 974954b
items.push(`${name}==${getExamplePrimitive(item.primitiveType)}`); |
I guess only one of these code paths is taken, based on whether a full recognized topic has been typed already? Anyway, it seems like we should at least try to use the same getExamplePrimitive
function here if it makes sense... maybe there's something I am missing though.
Yeah this entire code path only runs if studio/packages/studio-base/src/components/MessagePathSyntax/isTypicalFilterName.ts Lines 16 to 18 in ac261c6
Basically it's trying to find something that looks like an integer id and complete on it, which doesn't make sense for floats, whereas |
It could be a string id too though (like |
Yeah the point of the followup logic there is to not try to autocomplete on a string |
I guess I meant instead of adding the |
Because this code doesn't have any knowledge of the contents of messages we've seen yet so it doesn't know what kind of string ids it could suggest. |
One could also make a strong case for just getting rid of this logic that tries to do a special case autocomplete on an array of items with a field like |
I think suggesting an empty string I don't feel too strongly about keeping this logic but I do think it will become harder to discover the filter syntax if it never shows up in the autocomplete. |
At least in the case of arrays, which this code is special cased for, maybe it's better to just suggest |
And I think suggesting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving it up to you whether to make any changes based on above discussion or keep the PR as-is.
ac261c6
to
033ebb3
Compare
**User-Facing Changes** Improved autocomplete suggestions when typing message path syntax. **Description** The logic that generated the initial combined (topics+paths) list of suggestions was bespoke and did not account for array fields. This PR changes it to use the existing `messagePathsForStructure` function (with some additional info returned). It also updates `messagePathsForStructure` to extend the typicalFilterName logic to strings, and fix a bug where quotes in string filters (`...{field=="value"}`) were being deleted. Follow-up to #1971 & #3190 Before | After --- | --- I am not sure why the header sub-fields were not shown: <br><img width="274" alt="image" src="https://github.com/foxglove/studio/assets/14237/bb610276-8653-4338-b70a-44ae3e5d50a2"> | <img width="291" alt="image" src="https://github.com/foxglove/studio/assets/14237/e3c1c551-ad48-4a17-9cba-00a1dc30b324"> <img width="219" alt="image" src="https://github.com/foxglove/studio/assets/14237/be154462-f800-43ac-a1db-9b74d2ab2b44"> | Filter and array indexing suggestions are now shown:<br> <img width="299" alt="image" src="https://github.com/foxglove/studio/assets/14237/f724e7cb-1da2-47bd-bc2f-7399b9cc1de0">
User-Facing Changes
This improves message path autocomplete suggestions.
Description
Currently we offer unhelpful message path autocomplete suggestions across arrays of message objects when they contain fields that we mistakenly identify as numeric ids. For example trying to treat the
child_frame_id
field of a transform as a numeric id. The solution in this PR is to check the datatype of that*_id
field and only offer autocomplete values of*_id==0
if*_id
is a primitive integer type.Fixes #2997