Skip to content

Widget: OSAChatWidget.seed, smooth open and dock, bottom-right Move to corner icon - #732

Merged
neuromechanist merged 10 commits into
developfrom
feature/issue-730-widget-seed-motion
Nov 11, 2026
Merged

neuromechanist merged 10 commits into
developfrom
feature/issue-730-widget-seed-motion

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Summary

Three changes to frontend/osa-chat-widget.js for the NEMAR website (nemarOrg/website#525), which will call OSAChatWidget.seed(text, {mode: 'center'}) and feature-detect it.

  • OSAChatWidget.seed(text, {mode}?): puts the text at the head of the chat as the assistant's first message (seeded: true, replacing the greeting) and opens the window in mode. It sends nothing: no request, no send event, no Turnstile token. Validated like ask() (non-empty string, at most RESEED_TURN_MAX_CHARS, modeOption), queued before init(), refused while a reply loads. A chat with no reader message is reused; one with a reader message stays in History and a new chat opens.
    • selectReseedTurns keeps a seeded message (still pure), so the reader's first send carries prior_turns: [{role: "assistant", text}] with no expect_session.
    • New chatIsEmpty() replaces every messages.length <= 1 empty-chat test (start screen, reset button, suggestions, setConfig's greeting, resetChat).
    • hasUserMessage, trimConversations and retireActiveConversation count a seeded chat as content, conversationTitle falls back to the seeded text, normalizePersistedMessage keeps the mark across a reload, and the seeded reply has no thumbs row.
  • Motion: 120 ms CSS keyframes on the opened state (scrim fade-in, window fade and scale from 0.98) and after a dock (corner window fade-in, scrim fade-out under a closing class). State changes stay immediate; the cosmetic classes are removed by a 150 ms setTimeout, nothing listens for animationend or transitionend; all off in the one reduced-motion block.
  • Icon: ICONS.dock is an arrow to the bottom right (M7 7l10 10, M17 7v10H7); label and title stay "Move to corner".

Server: no src/ change. TestASeededOpeningReply in tests/test_api/test_reseed.py shows an assistant-only prior_turns for an unknown session is accepted and reaches the model as one user message.

The two Chrome harnesses that measure the dialog (center-stage-check.mjs, privacy-choices-check.mjs) now wait for finite animations before each read, since the open scales the window from 98%.

After merge the maintainer checks it on test.nemar.org; the issue stays open until then.

Refs #730

Commands run

  • bun frontend/test-widget-seed.js: 129 passed, 0 failed (new, wired into the frontend-tests job)
  • bun frontend/test-widget-host-api.js: 243 passed, 0 failed (unchanged)
  • bun frontend/test-widget-reseed.js: 67 passed, 0 failed (extended)
  • bun frontend/test-widget-session-lost.js: 79 passed; test-widget-host-styles.js: 39 passed; test-widget-history-panel.js: 200 passed
  • every other frontend/test-widget-*.js, test-markdown.js, test-citation-markers.js, test-streaming.js: pass
  • bun scripts/build-runtime-bundle.js --check: bundle is current
  • uv run pytest tests/test_api/test_reseed.py tests/test_frontend/ --no-cov: all passed (57 in test_reseed.py, 174 in test_frontend)
  • uv run ruff check . and uv run ruff format --check .: clean
  • bun frontend/browser-harness/center-stage-check.mjs and privacy-choices-check.mjs in Chrome: pass

… chat

seed(text, {mode}?) sends nothing: the text is the assistant's first message
(marked seeded), the window opens in the mode, and the reader's first send
carries it as prior_turns. A seeded chat counts as a chat with content in
History, trimming, retiring and the empty-chat checks; the reply gets no
thumbs row. Tested in happy-dom (new test-widget-seed.js, wired into CI;
test-widget-reseed.js extended).
… model (#730)

Server side of OSAChatWidget.seed: prior_turns of one assistant turn for an unknown
session returns 200, the model sees one user message with the text and the
researcher message, and the stored history is [human, ai]. No src/ change needed.
Tested: tests/test_api/test_reseed.py passes.
Keyframe animations on the opened state (scrim fade-in, window fade and scale from 0.98) and after a dock (corner window fade-in, scrim fade-out under a class a 150 ms timer removes). State changes (inert, scroll lock, focus, events) are immediate and nothing waits for an animation event. All off in the reduced-motion block. Tested: test-widget-seed.js (durations, reduced motion, no animationend or transitionend, timer cleanup); the host-api tests pass unchanged.
ICONS.dock is now an arrow to the bottom right (M7 7l10 10, M17 7v10H7) in the same 24x24 stroke svg, drawn at the header icons' 18 px. Label and title stay 'Move to corner'. Tested: test-widget-seed.js checks the paths, view box, size, aria-label and title.
)

Host API table row and a seed subsection in docs/community-widget.md, the reseed note that a seeded reply is carried, and a CHANGELOG entry under Unreleased. Docs-only; the frontend and Python docs tests pass.
The 120 ms open scales the window from 98%, so a size read in the first frames was 2% short (60 px field read 58.8). center-stage-check.mjs and privacy-choices-check.mjs now wait for finite animations before each read, and not on a call that carries a user gesture. Tested in Chrome: both harnesses pass.
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Preview Deployment

Name Link
Preview URL https://feature-issue-730-widget-see-demo.osc.earth
Branch feature/issue-730-widget-seed-motion
Commit a5d519f

This preview will be updated automatically when you push new commits.

…eck the dock fade starts in real Chrome (tested: center-stage and privacy-choices checks pass)
…pen; count a seeded chat as content on context switch and return; trim before the seed length limit; pop-out and context tests; docs tidy (tested: widget suites, hygiene tests)
@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 1, outcomes (fix commits 7095b39 and 80d85b3 on this branch):

  • Dock fade never plays after a settled open (important): fixed. The dock rule now uses its own @keyframes osa-dock-in (same frames as osa-center-in). test-widget-seed.js lists osa-dock-in in NEW_ANIMATIONS and asserts the center-open and dock rules have different animation names, with a comment saying why. center-stage-check.mjs now checks in real Chrome, right after a dock that follows a settled open, that document.getAnimations() holds osa-dock-in (laptop and phone). I confirmed that check fails with the old shared name and passes with the fix.
  • Seeded chat not counted as content in context switch and return (suggestion): fixed. Intended behaviour: a seeded chat is content everywhere. hasUserMessage is renamed hasContent, evaluateContextSwitch and startFreshChatOnReturn/isFreshReturn use it (the shadowing local is gone), and the hostSeed reuse branch sets activeConversation.context = pageContext() explicitly. A page move after a seed now shows the "next message starts a new chat" notice and keeps the seeded chat in History; a return in a new browser session starts a new chat. Three new test cases cover these, and the docs "The chat" bullet says so.
  • Pop-out branch and trimmed limit untested (suggestion): fixed. New test loads the widget as a pop-out and asserts seed warns with the [OSA] seed: prefix, changes nothing, fires no event and sends nothing. The 2000 limit now counts the trimmed text (the stored and sent text); a test covers a padded text that trims to exactly the limit, and the docs say "once trimmed".
  • Duplicated ANIMATIONS_SETTLED / evaluate (suggestion): fixed. Both now live in frontend/browser-harness/chrome.js (the existing shared harness module) and are imported by center-stage-check.mjs and privacy-choices-check.mjs.
  • Extra blank line in docs and the overlong thumbs comment (suggestion): fixed. Blank line removed; the comment is re-wrapped.

Tests run: all frontend/test-widget-*.js suites pass (test-widget-seed.js: 147 passed, 0 failed), center-stage-check.mjs and privacy-choices-check.mjs pass in headless Chrome, and tests/test_frontend/test_embed_snippet_hygiene.py plus test_privacy_page.py pass (19 passed).

@neuromechanist

Copy link
Copy Markdown
Member Author

Review round 2 outcomes:

  • docs/community-widget.md lines 957, 985, 1059 (important): fixed. All three bullets now say "no question from the reader and no reply the page seeded"; the line 1059 bullet also notes a seeded chat shows the notice and points to the seed subsection.
  • pendingSwitch comment (suggestion): fixed. It now reads "a chat that holds the reader's questions or a reply the page seeded".
  • isFreshReturn comment width (suggestion): fixed. Re-wrapped to about 90 characters.
  • Branch behind develop (process): fixed. Merged origin/develop (clean, no CHANGELOG conflict, Unreleased entry still on top). bun scripts/build-runtime-bundle.js --check reports the bundle current. All frontend/test-widget-*.js and test-runtime-bundle.js pass; tests/test_frontend and tests/test_api/test_reseed.py pass (231); ruff check clean. Merge once Frontend Tests and Test (3.12) are green on the new head.

@neuromechanist
neuromechanist merged commit 1108fc6 into develop Nov 11, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-730-widget-seed-motion branch November 11, 2026 22:59
@neuromechanist

Copy link
Copy Markdown
Member Author

Verdict: ready and merged. Every acceptance criterion is covered by the diff and tests (seed tests wired into frontend-tests, reseed test extended, motion and icon tests, TestASeededOpeningReply, docs and changelog), both review rounds have outcomes, and all checks passed on the head (Lint, Test 3.11 and 3.12, Frontend Tests). The PR says Refs #730, so #730 stays open for the check on test.nemar.org.

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