Skip to content

fix(core): hide the Ask AI affordance in plain search mode - #9

Merged
loookashow merged 1 commit into
mainfrom
fix/plain-mode-ask-affordance
Jul 27, 2026
Merged

fix(core): hide the Ask AI affordance in plain search mode#9
loookashow merged 1 commit into
mainfrom
fix/plain-mode-ask-affordance

Conversation

@loookashow

Copy link
Copy Markdown
Contributor

<loquix-search-dialog mode="plain"> and <loquix-search-panel mode="plain"> still rendered the "Ask AI" button, and clicking it dispatched a loquix-search-ask event the host never opted into — a plain search box silently offering a smart submit.

Root cause

show-ask-affordance won over mode. In LoquixSearchInput._shouldShowAsk the showAskAffordance early-return sat above any mode check, and both wrapper components set that attribute on their inner input unconditionally (loquix-search-dialog.ts in _renderDialog, loquix-search-panel.ts in render). So the flag they pass for the normal smart case leaked into plain mode.

Changes

  • LoquixSearchInput._shouldShowAsk now returns false when mode === 'plain', above the showAskAffordance branch. 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.
  • Corrected the showAskAffordance JSDoc, which promised unconditional visibility; regenerated custom-elements.json.
  • Changeset: patch bump for @loquix/core (@loquix/react follows via the linked config), targeting 0.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 with show-ask-affordance and 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 with Browser tests did not finish within 120000ms and 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.true instead, which fails cleanly with a readable diff.

Test plan

  • pnpm test — 1161 tests pass, Chromium + WebKit
  • pnpm build — green (@loquix/core + @loquix/react, includes tsc --noEmit)
  • pnpm lint — 0 errors (13 pre-existing warnings, none in touched files)
  • pnpm format:check — clean
  • Checked both Storybook stories that use show-ask-affordance (SearchInput.stories.ts, recipes/SmartSearch.stories.ts) — both pass mode="auto", so neither changes. No story combines plain mode with the affordance, so no Storybook visual pass was run for this fix.

@loookashow
loookashow merged commit 5b466d6 into main Jul 27, 2026
5 checks passed
@loookashow
loookashow deleted the fix/plain-mode-ask-affordance branch July 27, 2026 16:41
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.

1 participant