Skip to content

fix(settings): accurate View navigation after restore in recently deleted#4546

Merged
waleedlatif1 merged 3 commits intostagingfrom
waleedlatif1/restore-view-nav
May 10, 2026
Merged

fix(settings): accurate View navigation after restore in recently deleted#4546
waleedlatif1 merged 3 commits intostagingfrom
waleedlatif1/restore-view-nav

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

@waleedlatif1 waleedlatif1 commented May 10, 2026

Summary

In Settings → Recently Deleted, after restoring an item the View button rendered for every resource type but only navigated correctly for workflows/tables/knowledge bases. Files dropped users on the generic files list, and folders dropped users on the workflows root with nothing focused.

This change makes View land on the actual restored item:

  • Files/workspace/{id}/files/{fileId} (was /workspace/{id}/files). The [fileId] route already exists and files.tsx reads params.fileId to focus the file.
  • Folders → walks the restored folder's parent chain via the active useFolders query and calls useFolderStore.setExpanded(id, true) for the folder + all ancestors before pushing to /w. The folder store survives client-side navigation, so the sidebar opens with the restored folder expanded and visible.
  • Workflow / Table / Knowledge Base targets are unchanged — already correct.

Also small cleanups in the same component: toError(error).message instead of an instanceof Error ternary, dropped an unnecessary Fragment around config.renderTabIcon, and moved type ResourceType above its first use.

Test plan

  • Delete a workflow → restore from Recently Deleted → click View → lands on /w/{id} for that workflow
  • Delete a table → restore → View → lands on /tables/{id}
  • Delete a knowledge base → restore → View → lands on /knowledge/{id}
  • Delete a top-level file → restore → View → lands on /files/{id} with the file focused
  • Delete a top-level folder → restore → View → sidebar shows it expanded
  • Delete a nested folder (folder inside a folder) → restore → View → sidebar shows the nested folder expanded with all parents expanded too

…eted

Files now deep-link to /files/{id} (was /files), and folders expand
the restored folder + its parent chain in the sidebar before navigating
to /w so the user actually lands on the item they restored.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment May 10, 2026 8:14pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 10, 2026

PR Summary

Low Risk
Low risk UI/navigation change limited to the RecentlyDeleted settings component, with minor state updates to expand folder ancestors before routing.

Overview
Fixes the Recently Deleted “View” action so restored items navigate to the correct destination.

Files now route to .../files/{fileId} (instead of the files root), and folders expand the restored folder and its parent chain via useFolderStore.setExpanded(...) before routing to workflows. Also includes small cleanup tweaks (error normalization with toError, minor JSX/style simplifications).

Reviewed by Cursor Bugbot for commit 92cca40. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 10, 2026

Greptile Summary

Fixes the View button in Settings → Recently Deleted so it navigates to the actual restored item for all resource types. Files now route to /files/{fileId}, and folders walk the restored folder's full parent chain calling setExpanded before pushing to /w. The previously flagged race condition (restored folder not yet in the active query) is closed by merging archived-query data with active-query data so the parent walk resolves immediately.

  • Files: getResourceHref now returns /workspace/{id}/files/{fileId} instead of the generic /files list.
  • Folders: handleView builds a merged byId map (archived data as base, active data overwriting) and calls useFolderStore.getState().setExpanded for the folder and every ancestor before navigating.
  • Cleanups: toError(error).message replaces the instanceof Error ternary, unnecessary Fragment around renderTabIcon removed, type ResourceType hoisted above its first use.

Confidence Score: 5/5

The change is narrowly scoped to navigation logic triggered by a single user action — no data mutations, no store writes other than expand state, and no API surface is modified.

All changed paths are in event handlers isolated to this component. The merged-map approach for the folder parent walk correctly handles the post-restore refetch window. File routing is a straightforward URL fix. No regressions are expected for the unchanged workflow/table/knowledge routes.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/settings/components/recently-deleted/recently-deleted.tsx Fixes View navigation for files (now links to /files/{id}) and folders (expands parent chain in sidebar store before pushing to /w). Adds activeFoldersQuery as a merged fallback to resolve the post-restore race. Small cleanups: toError(), dropped Fragment, type hoisted.

Sequence Diagram

sequenceDiagram
    participant U as User
    participant RD as RecentlyDeleted
    participant API as Restore API
    participant FS as useFolderStore
    participant R as Router

    U->>RD: Click "Restore"
    RD->>API: mutate(restore)
    API-->>RD: onSuccess → restoredItems.set(id)
    RD-->>U: Show "Restored" + View button

    U->>RD: Click "View"
    alt "resource.type === 'folder'"
        RD->>RD: Merge foldersQuery.data (archived) + activeFoldersQuery.data (active)
        loop walk parent chain
            RD->>FS: setExpanded(folderId, true)
        end
        RD->>R: "router.push(/workspace/{id}/w)"
    else "resource.type === 'file'"
        RD->>R: "router.push(/workspace/{id}/files/{fileId})"
    else workflow / table / knowledge
        RD->>R: "router.push(/workspace/{id}/{type}/{id})"
    end
Loading

Reviews (2): Last reviewed commit: "fix: fall back to archived folders for p..." | Re-trigger Greptile

The restored folder may not be in the active folders cache yet when
View is clicked (the invalidation+refetch fires from onSettled, after
onSuccess surfaces the View button). Merge archived folder data — where
the restored item still lives — into the lookup map so the expansion
loop can always resolve the folder and walk its parent chain.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 92cca40. Configure here.

Document the size-* shorthand as the canonical pattern across CLAUDE.md,
AGENTS.md, .claude rules, .cursor + .agents commands, and the emcn
design-review skill. Default icon size is size-[14px]. Treat
h-[Npx] w-[Npx] and h-N w-N pairs as refactor targets.

Also migrate the remaining occurrences in recently-deleted.tsx.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@waleedlatif1 waleedlatif1 merged commit 10f7d36 into staging May 10, 2026
8 of 9 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/restore-view-nav branch May 10, 2026 20:12
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