Registry Mirror
Skip to content

Conversation

@bhushan4work

Copy link
Copy Markdown
Collaborator

What does this change?

Shows a "New reply ↓" pill button at the bottom of the log when a streaming reply or addMessage adds text while the visitor is scrolled up (nearBottom() is false). Clicking the pill smooth-scrolls to the bottom (jumping immediately if prefers-reduced-motion: reduce), manually scrolling to the bottom hides it, and it stays hidden when already at the bottom.

Closes #420

How I tested this

  • Added unit tests in packages/widget/tests/dom/stream.test.ts verifying pill visibility when text arrives while scrolled up, hiding when manually scrolling to bottom, smooth scrolling on click, and jumping on reduced motion.
  • Updated e2e/tests/stream-render.spec.ts asserting the pill is visible in new text doesn't pull the log down while the visitor reads above it.
  • Verified pnpm lint, pnpm size (within 19 kB budget for chatcops.panel.js), pnpm --filter @chatcops/widget test, pnpm test:coverage, and e2e Playwright tests.

AI assistance

None

Checklist

  • This PR targets dev
  • I was assigned the linked issue
  • pnpm -r build, pnpm test and pnpm -r typecheck pass locally
  • Tests added or updated where it makes sense
  • For a bug fix: the new test fails without my change
  • Changeset added (pnpm changeset) if this changes core, widget or server
  • pnpm api run and api/ committed if an exported type or option changed
  • Docs updated if behavior or options changed

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @bhushan4work, this mostly works. The pill shows when text arrives while you're scrolled up, hides on a click or a manual scroll to the bottom, and stays hidden at the bottom, and the tests cover each of those. All checks pass, including e2e. A few things need to change before it can go in:

  1. addMessage now checks nearBottom() after the new message is already in the log (packages/widget/src/dom/messages.ts:130), so the message's own height counts against the 48px. A reply whose first chunk is two lines or more (widget.ts:968), or an error reply (widget.ts:929 and :1014), arrives while the visitor is at the bottom, doesn't scroll into view, and shows the pill instead. dev works out follow before appending, so keep that order.

  2. Clicking or pressing Enter on the pill hides it while it has focus, so focus falls to document.body. In the popup that breaks Escape-to-close and the Tab trap, since both listen on the panel (packages/widget/src/dom/panel.ts:89-99). If the pill had focus, move it to the message input before hiding it, and add a test for where focus ends up.

  3. The label should be the newReply locale string from the issue. MessageActions.newReply (messages.ts:31) is never set, so add newReply: 'New reply' to the English strings in packages/widget/src/i18n.ts and pass it in actionLabels() (widget.ts:618). Keep the arrow out of the text, since screen readers say "New reply down arrow", and draw it in CSS instead, for example .cc-pill::after { content: " ↓" / ""; }.

  4. Some of the rewrites made to fit the size limit change behavior:

    • transition: 0.2s (widget.css:21, and the same in five other rules) animates every property, so the panel's size and position now animate too when the layout switches at 640px.
    • .cc-message-retry:hover (widget.css:359) lost color: var(--cc-danger), so Retry turns to the normal text color on hover.
    • font: 13px inherit (widget.css:569) is invalid, so the browser drops it and the pill gets its default button font. Use font-family: var(--cc-font); font-size: 13px; like .cc-consent-btn.

    Please put those back. The other rewrites can stay. I know they came from the budget (the first run was 51 B over the panel's 19 kB). If it's still over once these are back, say by how much here and I'll make room in a separate PR.

@bhushan4work

Copy link
Copy Markdown
Collaborator Author

@anurag629 lets get this one merged first followed by my other pr . lemme know if any followup fixes are needed . also do a rerun for ci , as its passing locally

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @bhushan4work, all four points are fixed. follow is worked out before the append again, focus moves to the input when the pill had it (with a test), the label comes from newReply with the arrow drawn in CSS, and the transitions, Retry's hover color and the pill's font match dev. That left the panel 35 B over, so I raised its budget to 19.2 kB in #596 and updated your branch. The e2e failure on the earlier run was the runner failing to download Playwright's system fonts, not your change. All checks pass, including e2e.

#594 still needs the two changes from my review there.

@anurag629
anurag629 merged commit a64c9fb into codercops:dev Nov 12, 2026
@anurag629

Copy link
Copy Markdown
Member

Merged, thanks @bhushan4work.

@github-actions github-actions Bot added the codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com) label Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Widget: a "New reply" button when the visitor has scrolled up

2 participants