Skip to content

fix(cli): render rule-history timestamps as dates, not a day count - #4125

Open
udsy19 wants to merge 1 commit into
NVIDIA:mainfrom
udsy19:fix/rule-history-timestamp
Open

udsy19 wants to merge 1 commit into
NVIDIA:mainfrom
udsy19:fix/rule-history-timestamp

Conversation

@udsy19

@udsy19 udsy19 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Summary

In the sandbox Rule History view, each entry's time renders as a days-since-1970 count (e.g. 19675d 22:13) instead of a wall-clock date.

Root cause

sandbox_draft_history formats event_time with format_timestamp_ms (crates/openshell-cli/src/commands/common.rs), which computes days = secs / 86400 and prints {days}d {hours:02}:{mins:02}. But event_time is an absolute google.protobuf.Timestamp (epoch ms), not an elapsed duration, so days is ~19,675. format_timestamp_ms was the only helper treating an absolute timestamp as a duration; the TUI's format_timestamp and the CLI's format_epoch_ms/format_optional_epoch_ms all render epoch-ms as YYYY-MM-DD HH:MM[:SS], and this was its sole caller.

Fix

Render with the existing format_optional_epoch_ms (as provider.rs does for event times), preserving the - placeholder for a missing/zero timestamp. The mis-implemented format_timestamp_ms helper is removed (no remaining references).

Tests

Regression test in common.rs: format_optional_epoch_ms(1_700_000_000_000) == "2023-11-14 22:13:20" and format_optional_epoch_ms(0) == "-". cargo test -p openshell-cli: 88 passed.

The sandbox rule-history view rendered each entry's event_time with
format_timestamp_ms, which divided the epoch milliseconds by 86_400_000
to produce a days component. Because event_time is an absolute
google.protobuf.Timestamp, that days component was days-since-1970, so
every entry printed a nonsensical count such as "19675d 22:13" instead
of a wall-clock date.

Drop the buggy helper and format the timestamp with the existing
format_optional_epoch_ms, matching how provider history and other
absolute-time columns are rendered (and preserving the "-" placeholder
for a missing/zero timestamp).

Signed-off-by: Udaya Tejas <udayatejas2004@gmail.com>
@udsy19
udsy19 requested review from a team, derekwaynecarr, mrunalp and sjenning as code owners October 2, 2026 15:15
@copy-pr-bot

copy-pr-bot Bot commented Oct 2, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

All contributors have signed the DCO ✍️ ✅
Posted by the DCO Assistant Lite bot.

@udsy19

udsy19 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

I have read the DCO document and I hereby sign the DCO.

This branch has not been deployed

No deployments
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