fix(core): hide the Ask AI affordance in plain search mode - #9
Merged
Conversation
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.
<loquix-search-dialog mode="plain">and<loquix-search-panel mode="plain">still rendered the "Ask AI" button, and clicking it dispatched aloquix-search-askevent the host never opted into — a plain search box silently offering a smart submit.Root cause
show-ask-affordancewon overmode. InLoquixSearchInput._shouldShowAsktheshowAskAffordanceearly-return sat above any mode check, and both wrapper components set that attribute on their inner input unconditionally (loquix-search-dialog.tsin_renderDialog,loquix-search-panel.tsinrender). So the flag they pass for the normal smart case leaked into plain mode.Changes
LoquixSearchInput._shouldShowAsknow returnsfalsewhenmode === 'plain', above theshowAskAffordancebranch. Fixing it in the input rather than in the two callers covers both surfaces at once, so the wrapper templates are untouched and any future host that forces the flag in plain mode is covered too.showAskAffordanceJSDoc, which promised unconditional visibility; regeneratedcustom-elements.json.@loquix/core(@loquix/reactfollows via thelinkedconfig), targeting0.4.1.Tests
Six tests, written before the fix and confirmed failing for the right reason first. Each surface gets both directions, so an over-correction that hides the button everywhere fails just as loudly as the original bug:
loquix-search-input— plain mode withshow-ask-affordanceand a conversational value renders no ask button.loquix-search-dialog/loquix-search-panel— reach into the inner input's shadow root and assert the button is present in the default mode and absent in plain mode.Note for future test authors
expect(someElement).to.equal(null)hangs Web Test Runner when the element is non-null. Chai tries to build a diff of a live DOM node and never finishes, so the browser never reports back and the run dies withBrowser tests did not finish within 120000msand no browser logs at all — no assertion error, no stack, nothing pointing at the assertion. Reproduced with a bare<div><span></span></div>fixture, no Loquix code involved.The negative assertions here use
expect(x === null, 'message').to.be.trueinstead, which fails cleanly with a readable diff.Test plan
pnpm test— 1161 tests pass, Chromium + WebKitpnpm build— green (@loquix/core+@loquix/react, includestsc --noEmit)pnpm lint— 0 errors (13 pre-existing warnings, none in touched files)pnpm format:check— cleanshow-ask-affordance(SearchInput.stories.ts,recipes/SmartSearch.stories.ts) — both passmode="auto", so neither changes. No story combines plain mode with the affordance, so no Storybook visual pass was run for this fix.