Skip to content

fix(model): clear SinceTime when switching log time windows#3980

Open
SebTardif wants to merge 1 commit into
derailed:masterfrom
SebTardif:fix/log-filter-since-ux
Open

fix(model): clear SinceTime when switching log time windows#3980
SebTardif wants to merge 1 commit into
derailed:masterfrom
SebTardif:fix/log-filter-since-ux

Conversation

@SebTardif
Copy link
Copy Markdown
Contributor

Summary

When a user switches between time-based log views (pressing 06 for tail/head/1m/5m/etc), the stale SinceTime from the previous stream was preserved in LogOptions. This could cause the log stream to silently resume from an unexpected timestamp instead of showing the correct time window.

Changes

Model fix (internal/model/log.go)

  • SetSinceSeconds(): clear SinceTime before restarting the stream
  • Head(): clear SinceTime before restarting the stream

Tests (internal/model/log_test.go)

  • TestLogSetSinceSecondsClearsSinceTime — verifies SetSinceSeconds clears the stale timestamp
  • TestLogHeadClearsSinceTime — verifies Head clears the stale timestamp

Root Cause

Every log line appended via model.Log.Append() updates logOptions.SinceTime to the line's timestamp (used for stream resume on reconnect). When the user switches time windows, SetSinceSeconds and Head correctly set their respective fields but never cleared SinceTime. While ToPodLogOptions() prioritizes SinceSeconds > 0 over SinceTime, edge cases during reconnection when SinceSeconds resets to 0 could cause the API to resume from the stale timestamp.

References

When a user switches between time-based views (pressing 0-6 for
tail/head/1m/5m/etc), the stale SinceTime from the previous stream
was preserved in LogOptions. Although ToPodLogOptions correctly
prioritizes SinceSeconds over SinceTime, the lingering timestamp
could cause issues on stream reconnection when SinceSeconds is
reset to 0 (default) — the API would resume from the stale
timestamp instead of showing the full tail.

Clear SinceTime in both SetSinceSeconds and Head to ensure clean
state when the user explicitly changes the time window. This
prevents log streams from silently resuming at an unexpected point
after a reconnect or mode switch.

Add tests verifying that SetSinceSeconds and Head both clear
SinceTime.

Ref derailed#3051 — part of broader log viewer reliability improvements
Ref derailed#1846 — logs missing or appearing at wrong offset
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