Skip to content

feat(ourlogs): only re-query truncated logs on significant viewport width increases#117014

Merged
JoshuaKGoldberg merged 1 commit into
masterfrom
feat/logs-no-requery-on-viewport-shrink
Jun 8, 2026
Merged

feat(ourlogs): only re-query truncated logs on significant viewport width increases#117014
JoshuaKGoldberg merged 1 commit into
masterfrom
feat/logs-no-requery-on-viewport-shrink

Conversation

@JoshuaKGoldberg

@JoshuaKGoldberg JoshuaKGoldberg commented Jun 5, 2026

Copy link
Copy Markdown
Member

Logs query with a truncate parameter derived from the viewport width. Previously the value tracked window.innerWidth directly, so shrinking the viewport lowered truncate, changed the query key, and triggered an unnecessary re-query even though the messages already fetched were long enough to display. 😬

This PR adds a monotonic, power-of-two truncation length. Meaning: truncation length is now rounded up to the next power of two and tracked as an increasing high-water mark (we never go down, only equal or up).

The truncation length steps up at these viewport widths:

truncate min innerWidth
256 2064px
512 4112px

This means we fetch a little bit more data for logs than we need. But it's not much more data and shouldn't change much.

Closes LOGS-839

Logs query with a `truncate` parameter derived from the viewport width.
Previously the value tracked `window.innerWidth` directly, so shrinking the
viewport lowered `truncate`, changed the query key, and triggered an
unnecessary re-query even though the already-fetched messages were long
enough to display.

Round the truncation length up to the next power of two and track it as a
monotonically increasing high-water mark. Shrinking the viewport never lowers
the value, and small growth stays within the same power-of-two bucket, so a
re-query only happens when the viewport grows past the next boundary.

Refs LOGS-839
Co-Authored-By: Claude <noreply@anthropic.com>
@linear-code

linear-code Bot commented Jun 5, 2026

Copy link
Copy Markdown

LOGS-839

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jun 5, 2026
@JoshuaKGoldberg

Copy link
Copy Markdown
Member Author

@cursor review

@JoshuaKGoldberg JoshuaKGoldberg changed the title feat(ourlogs): Don't re-query logs when the viewport shrinks feat(ourlogs): only re-query truncated logs on significant viewport width increases Jun 5, 2026

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2e2b9e4. Configure here.

Comment thread static/app/views/explore/logs/useLogsQueryTruncate.tsx
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review June 5, 2026 20:03
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team as a code owner June 5, 2026 20:03
@JoshuaKGoldberg JoshuaKGoldberg merged commit ec752cd into master Jun 8, 2026
74 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the feat/logs-no-requery-on-viewport-shrink branch June 8, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants