Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dashboard/src/views/ConsolePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default {
},
data() {
return {
autoScrollEnabled: true,
autoScrollEnabled: localStorage.getItem('console_auto_scroll') !== 'false',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Accessing localStorage can throw an error if it is disabled or restricted in the user's browser. It is safer to wrap this call in a try-catch block to prevent the component from failing to mount.

autoScrollEnabled: (() => {
  try {
    return localStorage.getItem('console_auto_scroll') !== 'false';
  } catch (e) {
    return true;
  }
})(),

pipDialog: false,
pipInstallPayload: {
package: '',
Expand All @@ -75,6 +75,7 @@ export default {
},
watch: {
autoScrollEnabled(val) {
localStorage.setItem('console_auto_scroll', val);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Accessing localStorage can throw an error if it is disabled or restricted. Wrap the setItem call in a try-catch block to handle potential errors gracefully.

try {
  localStorage.setItem('console_auto_scroll', val);
} catch (e) {
  console.error('Failed to save auto-scroll state:', e);
}

if (this.$refs.consoleDisplayer) {
this.$refs.consoleDisplayer.autoScroll = val;
}
Comment on lines 77 to 81
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The autoScrollEnabled state is not synchronized with the ConsoleDisplayer component on initial load. ConsoleDisplayer defaults to true, so it will ignore the persisted false state until the user toggles the switch. Consider adding a mounted hook to ConsolePage.vue to set this.$refs.consoleDisplayer.autoScroll = this.autoScrollEnabled;.

Expand Down
Loading