Skip to content

fix: persist workflow step across browser sessions via localStorage#16

Open
savinay1986 wants to merge 1 commit intonikmcfly:mainfrom
savinay1986:fix/step-state-persistence
Open

fix: persist workflow step across browser sessions via localStorage#16
savinay1986 wants to merge 1 commit intonikmcfly:mainfrom
savinay1986:fix/step-state-persistence

Conversation

@savinay1986
Copy link
Copy Markdown

Bug

Closing and reopening the browser tab resets the 5-step workflow back to Step 1, losing all visible progress — even though the project data (graph, ontology, etc.) is safely persisted on the backend.

Steps to reproduce:

  1. Upload a document and start a simulation project
  2. Wait for graph build to complete (Step 1 → Step 2)
  3. Close the browser tab
  4. Reopen http://localhost:3000/process/<project_id>
  5. You land back on Step 1 even though the graph is already built

Root Cause

currentStep in MainView.vue is a plain in-memory Vue ref(1). When loadProject() runs on mount, it correctly restores currentPhase from the backend project status — but never restores currentStep. The two values are independently tracked and only currentPhase was wired to the backend.

Fix

Three targeted changes to MainView.vue:

  1. Watcherwatch(currentStep) writes to localStorage under key mirofish_step_{projectId} on every change
  2. Restore on loadloadProject() reads back from localStorage after calling updatePhaseByStatus(), restoring the exact step the user left on
  3. Status fallbackupdatePhaseByStatus() advances currentStep to 2 when status is graph_completed, so even a first-time reload with no localStorage entry correctly skips Step 1

Test Plan

  • Upload doc → complete graph build → close browser → reopen URL → lands on Step 2 (Env Setup), not Step 1
  • User manually at Step 3/4/5 → close browser → reopen → resumes at correct step
  • Brand new project (/process/new) — watcher does not write until real project ID is assigned
  • No regressions to existing step navigation or backend polling logic

🤖 Generated with Claude Code

Closing and reopening the browser tab reset the 5-step workflow to
Step 1, losing the user's progress even though all project data was
safely persisted on the backend.

Root cause: `currentStep` in MainView.vue was a plain in-memory Vue
ref (ref(1)) with no persistence layer. loadProject() correctly
restored currentPhase from the backend project status but never
restored currentStep.

Fix:
- Add a watch() on currentStep that writes to localStorage under
  key `mirofish_step_{projectId}` on every change
- In loadProject(), read back from localStorage after restoring
  phase — so the user returns to exactly the step they left
- In updatePhaseByStatus(), advance currentStep to 2 when status
  is graph_completed (fallback for first-time reload with no
  localStorage entry, avoids landing on Step 1 with a built graph)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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