Skip to content

frontend: logs: Persist showTimestamps toggle in localStorage #3595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

blazethunderstorm
Copy link

Summary

This PR adds a reconnect fallback for the logs view by setting a cancelLogsStream callback in PodLogViewer, improving resilience when the logs stream is disconnected.

Related Issue

Fixes #3572

Changes

  • AAdded cancelLogsStream state to manage log stream cancellation.

  • Implemented handleReconnect to restart logs stream if it gets disconnected.

  • Ensured stream is properly cleaned up when reconnecting

Steps to Test

  1. Open the logs view for a Pod.

  2. Simulate network disconnect or close the stream.

  3. Click on the "Reconnect" button to reattach the logs stream.

  4. Confirm logs resume without page reload.

Screenshots (if applicable)

Screencast.from.2025-07-08.19-55-01.mp4

Notes for the Reviewer

  • [e.g., This touches the i18n layer, so please check language consistency.]

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: blazethunderstorm
Once this PR has been reviewed and has the lgtm label, please assign illume for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 8, 2025
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 8, 2025
@blazethunderstorm
Copy link
Author

@illume @sniok @joaquimrocha pls review i have also added the localstorage feaure

@@ -61,7 +61,12 @@ export function PodLogViewer(props: PodLogViewerProps) {
const { item, onClose, open, ...other } = props;
const [container, setContainer] = React.useState(getDefaultContainer());
const [showPrevious, setShowPrevious] = React.useState<boolean>(false);
const [showTimestamps, setShowTimestamps] = React.useState<boolean>(true);
const TIMESTAMP_SETTING_KEY = 'headlamp.logs.showTimestamps';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use existing useLocalStorageState hook for this

@blazethunderstorm
Copy link
Author

@sniok alright would do that

@blazethunderstorm
Copy link
Author

@sniok i have made req changes pls review

@blazethunderstorm blazethunderstorm requested a review from sniok July 8, 2025 15:19
Copy link
Contributor

@skoeva skoeva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this, to be clear: I would suggest looking into issues without (recent) open PRs addressing them. This avoids multiple people doing the same work twice

For this PR, as per our contribution guidelines:

  • Would you be able to squash your changes into a single atomic commit?
  • Could you change the PR and commit titles in the format to the following format?
    <area>: <description of changes>

@blazethunderstorm blazethunderstorm changed the title feat(logs): persist showTimestamps toggle frontend: logs: Persist showTimestamps toggle in localStorage Jul 10, 2025
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 10, 2025
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 10, 2025
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 10, 2025
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 10, 2025
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 10, 2025
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 10, 2025
@blazethunderstorm
Copy link
Author

@skoeva cant the commits be sqaushed while merging ?

@blazethunderstorm blazethunderstorm requested a review from skoeva July 10, 2025 16:59
@blazethunderstorm
Copy link
Author

i am facing a bit of probelm from my end

@blazethunderstorm
Copy link
Author

@skoeva can it be done pls tell ?

@sniok
Copy link
Contributor

sniok commented Jul 11, 2025

@blazethunderstorm
hi, you can fix this by running an interactive rebase git rebase -i main, then you can drop all the merge commits because they're not neccessary, leave only the "refactor(pod-logs): use useLocalStorageState hook for timestamp setting" commit but reword it so it follows our commit guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add general default setting for log timestamps being displayed.
4 participants