Skip to content

fix(client): stabilize jump anchoring and idle PWA resume#115

Merged
Just-Insane merged 5 commits into
integrationfrom
codex/fix-jump-and-idle-followups
Jun 16, 2026
Merged

fix(client): stabilize jump anchoring and idle PWA resume#115
Just-Insane merged 5 commits into
integrationfrom
codex/fix-jump-and-idle-followups

Conversation

@Just-Insane

Copy link
Copy Markdown
Collaborator

Description

Follow-up fixes after merged PRs #112 and #114.

This PR does two things:

  • keeps jump-to-message targets anchored while surrounding history, media, and preview heights settle, so repeated clicks are not required just to keep the target in view
  • narrows the Safari/PWA foreground service-worker recovery path so a missing controller on ordinary visibilitychange -> visible no longer triggers an aggressive claim attempt on every resume

Implementation details:

  • the jump flow now re-resolves the target event by current row/event ID during delayed re-centers, extends those bounded re-centers while context settles, and keeps the highlight alive until pagination has finished and for longer afterward
  • the idle-resume change keeps telemetry for missing-controller foreground resumes but limits active CLAIM_CLIENTS recovery back to the existing pageshow[persisted] path

Related repo history checked before opening this PR:

Related to #103
Related to #109

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

AI disclosure:

  • Partially AI assisted (clarify which code was AI assisted and briefly explain what it does).
  • Fully AI generated (explain what all the generated code does in moderate detail).
    This PR updates RoomTimeline.tsx so a successful jump does not rely on one early row lookup and a short timeout. The jump logic now resolves the target row from the current focusItem event ID when it performs delayed re-centers, schedules several bounded re-centers while media/previews/history continue changing layout, and avoids clearing the highlight while jump-related pagination is still loading. It also adjusts useAppVisibility.ts so a normal foreground resume without a controller records telemetry but does not immediately send CLAIM_CLIENTS; the active claim path remains the pageshow[persisted] recovery case that was originally added for stale Safari PWA restores.

@github-code-quality

github-code-quality Bot commented Jun 16, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: JavaScript

JavaScript / code-coverage/vitest

The overall coverage in the branch remains at 22%, unchanged from the branch.

Show a code coverage summary of the most impacted files.
File 17893a9 14d86e6 +/-
src/app/hooks/u...ppVisibility.ts 76% 75% -1%

Updated June 16, 2026 18:27 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f805840f2f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/app/features/room/RoomTimeline.tsx Outdated
Comment thread src/app/features/room/RoomTimeline.tsx
@github-actions

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

Status Preview URL Commit Alias Updated (UTC)
✅ Deployment successful! https://pr-115-charm.justin-tech.workers.dev 14d86e6 pr-115 Tue, 16 Jun 2026 18:26:30 GMT

@Just-Insane Just-Insane merged commit 892f35c into integration Jun 16, 2026
13 of 14 checks passed
@Just-Insane Just-Insane deleted the codex/fix-jump-and-idle-followups branch June 16, 2026 18:27

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 14d86e6e7a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +546 to 553
let nextProcessedIndex = getRawIndexToProcessedIndex(currentFocusItem.index);
if (nextProcessedIndex === undefined && currentFocusItem.eventId) {
const found = processedEventsRef.current.findIndex(
(e) => e.mEvent.getId() === timelineSync.focusItem!.eventId
(e) => e.mEvent.getId() === currentFocusItem.eventId
);
if (found >= 0) {
processedIndex = found;
log.log(
`[PermalinkJump] Found event by ID search: eventId=${timelineSync.focusItem.eventId}, processedIndex=${found}`
);
} else {
log.log(
`[PermalinkJump] Event not found in processedEvents yet: eventId=${timelineSync.focusItem.eventId}, processedEvents.length=${processedEventsRef.current.length}`
);
nextProcessedIndex = found;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve jump anchors by event id before stale indices

When post-jump pagination loads history above the target, the target's absolute itemIndex shifts, but the old raw index can still resolve to a different row. Because this resolver accepts getRawIndexToProcessedIndex(currentFocusItem.index) before checking currentFocusItem.eventId, the delayed 600/1500/3000 ms re-centers can scroll to whatever event now occupies the stale index instead of the jumped message. Prefer validating the matched row's event id or searching by eventId first whenever it is available.

Useful? React with 👍 / 👎.

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