Skip to content

fix: preserve elapsed time for streaming requests - #8796

Merged
sanish-bruno merged 1 commit into
usebruno:bugfix/streaming-elapsed-time-internalfrom
Sudemc:bugfix/streaming-elapsed-time
Aug 14, 2026
Merged

sanish-bruno merged 1 commit into
usebruno:bugfix/streaming-elapsed-time-internalfrom
Sudemc:bugfix/streaming-elapsed-time

Conversation

@Sudemc

@Sudemc Sudemc commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Internal - [BRU-4095]

Description

Preserves the elapsed-time counter for active streaming HTTP responses when navigating away from and back to the request.

Problem

ResponseStopWatch kept elapsed time only in component-local state. Switching requests unmounted the component, so returning to a still-running stream initialized the counter from the original response duration and appeared to reset it.

Fixes #8792.

Fix

  • Derive elapsed time from the stable requestSent.timestamp when available.
  • Keep the existing duration-based ticking as a compatibility fallback.
  • Synchronize immediately when the request-sent event arrives after the initial render.
  • Clamp future timestamps to zero.
  • Add focused regression coverage for navigation/remounting and event ordering.

Screenshots

Not applicable; this changes timer continuity rather than layout or styling.

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Testing

  • ResponseStopWatch: 5/5 tests passed
  • ResponsePane scope: 48/48 tests passed
  • ESLint on all three changed files
  • git diff --check

Summary by CodeRabbit

  • Bug Fixes

    • Improved response timing display accuracy when requests are actively running.
    • Preserved elapsed time across component updates and remounts.
    • Prevented future timestamps from showing negative durations.
    • Updated timing when request start information becomes available after rendering.
  • Tests

    • Added coverage for elapsed-time calculation, fallback timing, timer progression, and future timestamps.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

ResponseStopWatch now derives elapsed time from startTime with a startMillis fallback, updates when timing props change, and clamps future timestamps. ResponsePane supplies both values for running streams, with deterministic tests covering the timing behavior.

Changes

Response stopwatch timing

Layer / File(s) Summary
Elapsed-time calculation and coverage
packages/bruno-app/src/components/ResponsePane/ResponseStopWatch/*
ResponseStopWatch calculates elapsed time from startTime or startMillis, updates at fixed intervals, responds to prop changes, and is covered by fake-timer tests.
Running response integration
packages/bruno-app/src/components/ResponsePane/index.js
Running response streams pass both the request timestamp and response duration to ResponseStopWatch.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ResponsePane
  participant ResponseStopWatch
  participant SystemClock
  participant IntervalScheduler
  ResponsePane->>ResponseStopWatch: pass startTime and startMillis
  ResponseStopWatch->>SystemClock: read Date.now()
  ResponseStopWatch->>IntervalScheduler: schedule TICK_INTERVAL updates
  IntervalScheduler-->>ResponseStopWatch: timer tick
  ResponseStopWatch->>SystemClock: recompute elapsed time
Loading

Suggested reviewers: bijin-bruno

Poem

A stopwatch remembers where moments began,
With fallback milliseconds ticking in hand.
Future times rest at zero, calm and bright,
Streams keep their rhythm through day and night,
While tests make each second land just right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes retain the original request start time, continue ticking on remount, and cover the reset scenario described in #8792.
Out of Scope Changes check ✅ Passed The fallback logic and regression tests are directly related to the elapsed-time reset fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: preserving elapsed time for active streaming requests.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sreelakshmi-bruno

Copy link
Copy Markdown
Collaborator

Hi, we're dedicating bandwidth to review this PR and get it merged for release v4.2.0, which is planned to go out in September. Thank you for your contribution!

@sanish-bruno
sanish-bruno changed the base branch from main to bugfix/streaming-elapsed-time-internal August 14, 2026 10:32
@sanish-bruno
sanish-bruno merged commit 4f319b5 into usebruno:bugfix/streaming-elapsed-time-internal Aug 14, 2026
@sanish-bruno sanish-bruno added the adopted-by-maintainers PR needs additional work and is now being worked on by the maintainers label Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adopted-by-maintainers PR needs additional work and is now being worked on by the maintainers size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Elapsed-time counter resets after switching away from a running request

3 participants