Skip to content

fix: keep new messages visible after sending (follow-state sync) - #715

Merged
pikann merged 4 commits into
masterfrom
feature/improve-viewport-tracking-logic
Nov 8, 2026
Merged

pikann merged 4 commits into
masterfrom
feature/improve-viewport-tracking-logic

Conversation

@pikann

@pikann pikann commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem

After sending a message in a conversation, the new user message and the agent's reply sometimes stayed hidden until the page was reloaded.

Cause

useConversationEventWindow withholds newly arrived events while following is false. TailFollowIndicator mirrored the thread viewport's isAtBottom into following in an effect that also depended on following. When sending a message calls jumpToLatest() while the viewport is not yet at the bottom, following flipped to true and the effect set it straight back to false. The sender's message and the reply were then withheld, and the optimistic copy of the message expired after 60s.

Changes

  • event-window-controls.tsx: sync following only when isAtBottom actually changes (tracked with a ref), so a programmatic jumpToLatest() is no longer undone.
  • Remove the now-unused following prop from TailFollowIndicator and its call site in conversation-view.tsx.

Testing

  • tsc -b is clean.
  • vitest run src/components/projects passes (442 tests).
  • Not reproduced in a browser, and no new test was added for this case.

@pikann pikann changed the title feat: remove following prop from TailFollowIndicator and improve view… fix: keep new messages visible after sending (follow-state sync) Nov 8, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ Minor suggestions only — the diagnosis is sound and removing following from the deps is the right minimal fix; a couple of rough edges inline.

Reviewed changes

Reviewed the single commit aa0fbfdf across both changed files, focused on the viewport-to-following sync and the prop removal.

  • following no longer re-synced from its own changes — the effect in event-window-controls.tsx now keys off isAtBottom transitions only, so a programmatic jumpToLatest() is no longer reverted while the viewport is off-bottom.
  • following prop removed from TailFollowIndicator — the conversation-view.tsx call site no longer destructures or passes it; following is still returned by useConversationEventWindow and used to gate live-buffer merging and newBelow.

ℹ️ No regression test for the follow-state revert

The send-while-scrolled-up case isn't covered anywhere. use-conversation-event-window.test.tsx drives setFollowing directly and never renders TailFollowIndicator, so it can't catch an effect reverting jumpToLatest(). Because the failure is a silent withhold rather than an error, a small component test that stubs useThreadViewport with a mutable isAtBottom would pin the behavior.

Technical details
# Add a TailFollowIndicator regression test

## Affected sites
- `apps/web/src/components/projects/agents/event-window-controls.tsx:160-164` — the effect that regressed.
- `apps/web/src/components/projects/agents/use-conversation-event-window.test.tsx` — exercises the hook only, not the viewport-to-`following` mirror.

## Required outcome
- A test that starts with `isAtBottom: false`, calls `setFollowing(true)` (what `onNew` does), and asserts `following` stays `true` until `isAtBottom` actually changes.

## Suggested approach (optional)
- Mock `useThreadViewport` from `@assistant-ui/react` to read a mutable store value, render `TailFollowIndicator` with a spy `setFollowing`, and assert the spy is not called with `false` after the jump.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

Reviewed the delta since the prior pullfrog review (aa0fbfdf) — the single new commit 3569e8b across the three PR files — focused on the new jump-driven scroll path.

  • jumpToLatest() now signals the view — useConversationEventWindow exposes a jumpCount that increments on every jumpToLatest(), threaded through conversation-view.tsx into TailFollowIndicator.
  • Sends now scroll to the tail — an effect in TailFollowIndicator calls scrollToBottom({ behavior: "auto" }) whenever jumpCount changes, and the pill's inline scroll moved into that same effect, so the onNew send path no longer leaves the viewport behind. A ref seeded with the initial count keeps the mount from scrolling.
  • Redundant guard dropped — the lastAtBottomRef check was removed from the isAtBottom mirror effect, leaving the one-line dependency fix.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

The new e2e regression spec cannot pass as written: it seeds follow-up messages into a conversation that is still queued/running, which the API rejects with CONVERSATION_BUSY.

Reviewed changes

Reviewed the delta since the prior pullfrog review (3569e8b) — the single new commit 8a46def across six files.

  • Added a new e2e scenario for send-while-scrolled-up — conversation-follow.spec.ts plus its feature file exercise the regression through the UI against a fake ACP bridge.
  • Extracted FakeBridge into a shared helper — moved verbatim from acp-agent-conversations.spec.ts to tests/helpers/fake-bridge.ts; the original spec now imports it, with no behavior change.
  • Added component tests for TailFollowIndicator — mount-no-scroll, jump-keeps-following while off-bottom, viewport→following mirror, and click-scrolls-once, directly pinning the regression.
  • Clarified the mirror/jump comments — comment-only edit in event-window-controls.tsx, no logic change.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

Reviewed the delta since the prior pullfrog review (8a46def) — the single commit 6226150 across two e2e files — focused on whether the seeding still races the ACP busy guard.

  • Added FakeBridge.sendEvent — streams a { type: "event", payload: { content: { type: "text", text } } } message so the spec can play the daemon's own user_message / agent_message_chunk events.
  • Completed each seeded turn before continuing — the loop now consumes start_turn, streams the user message and reply, reports finished, and polls the conversation out of running before the next POST, which clears the prior CONVERSATION_BUSY blocker. The final composer send also lands on a terminal conversation, and SendChatMessage resumes ACP conversations in place, so the bridge still receives start_turn for the seeded id.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pikann
pikann merged commit 0fc95a6 into master Nov 8, 2026
3 checks passed
@pikann
pikann deleted the feature/improve-viewport-tracking-logic branch November 8, 2026 17:00
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