Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Problem

The WithBashToolWaiting story was flaky because the elapsed time display changed every run.

The BashToolCall component calculates elapsed time using Date.now() for the current time, but stories use a fixed timestamp (NOW = 1700000000000, Nov 2023) for message timestamps. This meant the elapsed time showed something like 33000000s (the difference between real Date.now() and the fixed timestamp), which changed every second.

Solution

Mock Date.now() globally in Storybook preview to return the same stable NOW timestamp used by all test fixtures. Now the elapsed time calculation is deterministic.

Generated with mux

The BashToolCall component calculates elapsed time using Date.now(),
but stories use a fixed timestamp (NOW) from the past. This caused
the elapsed time display to be flaky, showing different values each
run (the real time minus the fixed timestamp).

Mock Date.now() globally in Storybook preview to return the same
stable NOW timestamp used by all test fixtures.

_Generated with mux_
@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@ammario ammario merged commit 70c7ee2 into main Dec 9, 2025
19 checks passed
@ammario ammario deleted the bash-tool-timing-flaky branch December 9, 2025 15:30
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.

2 participants