Skip to content

fix: Clear LS after the app closes#6049

Merged
camiloHimura merged 4 commits intodevelopfrom
ccolora11/6029-import-error
Apr 17, 2026
Merged

fix: Clear LS after the app closes#6049
camiloHimura merged 4 commits intodevelopfrom
ccolora11/6029-import-error

Conversation

@camiloHimura
Copy link
Copy Markdown
Contributor

@camiloHimura camiloHimura commented Apr 7, 2026

Summary

Fixes #6029.

This PR adds a new Tauri handler that clears the local storage import/export information when the app closes, so no invalid IDs are refetched the next time it opens.

How to test

Checklist

  • The PR title and description are clear and descriptive
  • I have manually tested the changes
  • All changes are covered by automated tests
  • All related issues are linked to this PR (if applicable)
  • Documentation has been updated (if applicable)

@camiloHimura camiloHimura requested a review from a team as a code owner April 7, 2026 12:11
@camiloHimura camiloHimura added the Geti UI Issues related to Geti application frontend label Apr 7, 2026
Copilot AI review requested due to automatic review settings April 7, 2026 12:11
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

🐳 Docker image sizes

Device Size
cpu 3604.1 MB (3.52 GB)
xpu 10572.7 MB (10.32 GB)
cuda 10219.1 MB (9.98 GB)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Addresses #6029 by preventing stale dataset-import job state from persisting across app restarts.

Changes:

  • Added a session-storage JSON parsing helper and switched dataset-import storage from localStorage to sessionStorage.
  • Invalidated the dataset items query after a successful dataset import to refresh dependent UI.
  • Set the primary button to autofocus in the delete project dialog.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
application/ui/src/hooks/localStorage/utils.ts Adds getParsedSessionStorage helper for safe JSON parsing/removal on failure.
application/ui/src/hooks/localStorage/use-dataset-import-storage.hook.ts Migrates dataset import persistence from useLocalStorage to useSessionStorage.
application/ui/src/features/dataset/import-export/import-jobs-list/import-jobs-list.component.tsx Invalidates /dataset/items queries after import success to refresh the dataset view.
application/ui/src/components/project-dialogs/delete-project-dialog.component.tsx Ensures destructive action gets focus by default via autoFocusButton='primary'.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread application/ui/src/hooks/storage/utils.ts Outdated
Comment thread application/ui/src/hooks/storage/use-dataset-import-storage.hook.ts Outdated
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

📊 Test coverage report

Metric Coverage
Lines 57.5%
Functions 79.2%
Branches 88.0%
Statements 57.5%


export const useDatasetImportStorage = <TStep, TEntry extends DatasetImportState<TStep>>(storageKey: string) => {
const [importEntries, setImportEntries] = useLocalStorage<TEntry[] | null>(
const [importEntries, setImportEntries] = useSessionStorage<TEntry[] | null>(
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.

Why this change? IMO that was a nice feature that user could open different tabs with the app and still see the progress of the import.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Local Storage doesn’t work well for the desktop version. When the user closes and reopens the app, all jobs are cleared, which leads to this error: #6029

Using session storage instead ensures that all job-related information is cleared automatically.

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.

IMO with this change we hide the problem instead of solving that properly. If I understand correctly, the issue right now is that when user opened the desktop app again the local storage might contain the outdated job that was removed automatically when closing the desktop app previously. What about clearing job state in the local storage when closing the app?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I disagree. We need the storage to be cleared when the app closes, and session storage already gives us that behavior. Your approach adds more code to achieve the same result, so to me it doesn’t feel like the right solution.

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.

If we still need to keep the progress between tabs when using a browser, then the approach suggested by @dwesolow would be more preferable. It comes with some extra code, indeed, but the feature is nice :-)

@camiloHimura camiloHimura force-pushed the ccolora11/6029-import-error branch 2 times, most recently from c4de0fe to af1a238 Compare April 9, 2026 15:10
@camiloHimura camiloHimura requested review from dwesolow and itallix April 9, 2026 15:10
"description": "enables the default permissions",
"windows": ["main"],
"permissions": ["core:default"]
"permissions": ["core:default", "core:window:allow-on-close-requested"]
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.

what does this do?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it grants permission to handle window close events, so we can clear the LS

{ params: { path: { project_id: projectId } } },
]),
});
queryClient.invalidateQueries({
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.

why didnt we need this before?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was actually missing, this ticket was created because of it: #6078. However, it has its own dedicated PR, so I’ll remove that code from this PR.

.forEach((key) => localStorage.removeItem(key));
};

const isTauri = (): boolean => '__TAURI_INTERNALS__' in window;
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.

Can we extract Tauri-related code to another folder? We are mixing storage and tauri here

Copy link
Copy Markdown
Contributor

@jpggvilaca jpggvilaca left a comment

Choose a reason for hiding this comment

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

PR title says we're replacing local with session storage but i dont see sessionStorage being used anywhere?

@camiloHimura
Copy link
Copy Markdown
Contributor Author

PR title says we're replacing local with session storage but i dont see sessionStorage being used anywhere?

it was the original intention but we move to a different approach, so I'll update the title

@camiloHimura camiloHimura changed the title fix: replace local storage with session storage fix: Clear LS after the app closes Apr 15, 2026
@camiloHimura camiloHimura force-pushed the ccolora11/6029-import-error branch from af1a238 to ba1a65f Compare April 15, 2026 14:50
@camiloHimura camiloHimura added this pull request to the merge queue Apr 17, 2026
Merged via the queue into develop with commit 5b7051c Apr 17, 2026
33 checks passed
@camiloHimura camiloHimura deleted the ccolora11/6029-import-error branch April 17, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Geti UI Issues related to Geti application frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dataset import: An error occurred during import. Job not found (after dataset import and app restart)

5 participants