Skip to content

fix: stabilize group chat and complete Agent mentions - #115

Merged
sanjey99 merged 5 commits into
mainfrom
fix/110-group-chat-scroll-mentions
Sep 1, 2026
Merged

sanjey99 merged 5 commits into
mainfrom
fix/110-group-chat-scroll-mentions

Conversation

@sanjey99

@sanjey99 sanjey99 commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Problem

Project Group polling replaced the message array every 1.1 seconds and unconditionally scrolled the bottom sentinel into view. Readers trying to inspect older messages were repeatedly dragged back down. The composer also exposed only persistent route chips; typing a leading @ had no Agent discovery or completion.

Closes #110.

Root cause

ProjectGroupPage tied every polling refresh to bottom scrolling, even for byte-equivalent snapshots, and did not distinguish a bottom-pinned reader from someone who had manually scrolled upward. Mention formatting existed for route chips, but no caret-aware leading-token query or suggestion interaction reused it.

Fix

  • Retain the existing React message reference for truly identical bounded snapshots.
  • Auto-follow only on initial load, a one-shot successful send, or when the reader was already near the bottom.
  • Preserve same-ID message enrichment such as a later Contract binding.
  • Add leading-@ suggestions from the existing callable Agent directory.
  • Filter partial mentions by visible Agent name; opaque IDs cannot create surprising matches.
  • Support Arrow Up/Down, Enter/Tab, Escape, and pointer selection using the existing parser-safe quoted mention formatter.
  • Reuse the frozen UI color/spacing language without redesigning the page.

Test plan

  • Observed causal Web tests fail before mention/query/refresh helpers existed.
  • Web unit suite: 26/26 passed.
  • Web and server production builds/typechecks passed.
  • Focused Project Group Playwright: 4/4 at 1280×800 and 1440×900.
  • Reproduced and fixed opaque-ID prefix leakage (@F showing an unrelated visible name).
  • git diff --check passed.
  • Full exact-main Playwright matrix after merge.

Out of scope

Backend leading-mention routing semantics, provider configuration, general UI redesign, documentation, and live verifier work in #111.

Add leading Agent mention suggestions that reuse the existing safe routing syntax and keep manually-scrolled group conversations stable across polling refreshes.
Compare complete Project Group message snapshots, consume send-follow intent after the next refresh, and cover keyboard and pointer mention selection.
Keep autocomplete suggestions aligned with visible Agent names so opaque generated IDs cannot produce unexpected matches.
Limit Project Group suggestions to idle auth-demo Agents, preserve drafts when a mention would exceed the composer limit, and keep overflowing suggestion options vertically scrollable and keyboard accessible.
@sanjey99
sanjey99 marked this pull request as ready for review September 1, 2026 03:58
Copilot AI lite review requested due to automatic review settings September 1, 2026 03:58
@sanjey99
sanjey99 merged commit 65b432a into main Sep 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new mention suggestion listbox has a confirmed keyboard edge case (Tab/Enter preventDefault with no active option) and needs a small accessibility fix to keep listbox options out of the tab order.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR improves the Project Group chat UX by preventing polling refreshes from forcibly scrolling readers to the bottom, and adds leading-@ Agent mention autocomplete (keyboard + pointer) backed by the existing callable Agent directory.

Changes:

  • Adds snapshot-based message refresh logic that preserves scroll position unless the reader is bottom-pinned, on initial load, or after a successful send.
  • Implements leading-@ mention query + replacement helpers and integrates a suggestions listbox into the composer (Arrow keys, Enter/Tab, Escape, click).
  • Extends unit and Playwright coverage to assert scroll anchoring and mention suggestion behavior/layout constraints.
File summaries
File Description
tests/e2e/ui-gate.spec.mjs Adds an assertion that manual upward scrolling remains stable across polling refreshes.
tests/e2e/project-group-contract-flow.spec.mjs Adds end-to-end coverage for mention suggestions, keyboard navigation, filtering, and overflow constraints.
apps/web/src/styles.css Introduces styling/positioning for the mention suggestions popup in the composer.
apps/web/src/pages/ProjectGroupPage.tsx Implements scroll-follow gating, message snapshot refresh preservation, and mention suggestions UI + interactions.
apps/web/src/pages/project-group-mention.ts Adds typed leading-@ query detection, candidate filtering, and query replacement helpers.
apps/web/src/pages/project-group-mention.test.tsx Adds unit tests for mention candidate logic and message refresh decision logic.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +356 to +361
if (event.key === "Enter" || event.key === "Tab") {
event.preventDefault();
const agent = mentionCandidates[mentionActiveIndex];
if (agent) selectMention(agent);
return;
}
Comment on lines +380 to +387
<button
id={`${MENTION_SUGGESTIONS_ID}-${index}`}
key={agent.id}
type="button"
role="option"
aria-selected={index === mentionActiveIndex}
onMouseDown={(event) => event.preventDefault()}
onClick={() => selectMention(agent)}
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.

Fix group chat scroll anchoring and add Agent mention autocomplete

2 participants