Skip to content
This repository was archived by the owner on Oct 17, 2026. It is now read-only.

Remount the reaction view when the reaction ID changes - #222

Merged
skearnes merged 3 commits into
mainfrom
agent/reaction-view-remount
Oct 3, 2026
Merged

skearnes merged 3 commits into
mainfrom
agent/reaction-view-remount

Conversation

@skearnes

@skearnes skearnes commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Summary

  • MainReactionView kept its state across a change of /id/:reactionId:
    • The previous reaction stayed on screen under the new URL until the new record loaded.
    • With the second of two inputs selected, routing to a reaction with one input indexed past the end of inputsMap and crashed the render (Cannot read properties of undefined (reading '1')).
    • A response for the previous reaction that arrived after the new one had rendered replaced it, so /id/ord-2 showed ord-1's inputs.
  • The route now keys the view by reaction ID, so each reaction gets a fresh instance and a late response updates one that is already unmounted.

Changes

  • App.tsx: ReactionRoute reads reactionId and renders <MainReactionView key={reactionId} />.
  • App.test.tsx: one test per symptom above, each routing between reactions via popstate.

Testing

  • npx tsc -b, npm run lint, npm run format:check, npm test (420 passed).
  • All three new tests fail against main's App.tsx: ord-1's input tab still rendered, the TypeError above, and ord-1's input tabs where ord-2's belong.

Notes

🤖 Generated with Claude Code

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no outstanding findings remain.

Summary

The route now keys MainReactionView by reaction ID, giving each reaction fresh view state. The added tests cover tab reset, the loading state, and a late response from the previous reaction.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Route to reaction ID"] --> B["Key MainReactionView by ID"]
  B --> C["Unmount previous view"]
  B --> D["Mount fresh view with loading state"]
  D --> E["Render new reaction"]
Loading

Reviews (3) · Last reviewed commit: "Test that the previous reaction gives wa..."

MainReactionView keeps its record, tab selections, and pending fetches in
component state, so a route change from one reaction to another reused
them. A selected input tab past the new reaction's input count indexed
off the end of the inputs and crashed the render. Keying the view by
reaction ID gives each reaction a fresh instance.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread app/src/App.test.tsx Resolved
skearnes and others added 2 commits October 2, 2026 23:58
Holds the first reaction's response until after the route has moved to a
second reaction and that one has rendered. Without the keyed remount, the
late response replaces the second reaction's inputs with the first's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Holds the next reaction's response and checks that the previous
reaction's inputs are gone once the route changes. The first routing
test asserts only the input tab, so its name now says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@skearnes
skearnes merged commit a8ee11a into main Oct 3, 2026
16 checks passed
@skearnes
skearnes deleted the agent/reaction-view-remount branch October 3, 2026 04:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant