Skip to content

improvement(url-state): shared sort/search url-state helpers + task and log selection deep links#5652

Merged
waleedlatif1 merged 7 commits into
stagingfrom
nuqs-url-state-helpers
Jul 14, 2026
Merged

improvement(url-state): shared sort/search url-state helpers + task and log selection deep links#5652
waleedlatif1 merged 7 commits into
stagingfrom
nuqs-url-state-helpers

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Stacked on #5648 — will retarget to staging once that merges.

Summary

  • Add shared URL-state primitives and migrate every consumer onto them (net −350 lines of duplication):
    • createSortParams (lib/url-state) + useUrlSort — one definition of the sort+dir convention with defaulted and nullable modes; migrates tables, knowledge, knowledge docs, recently-deleted, logs, files, and the chunk view
    • useDebouncedSearchSetter — the canonical debounced search-param setter; migrates 13 grouped/single sites and fixes a live bug where 5 surfaces wrote the trimmed value to a param controlling the input (typed trailing spaces were eaten, making multi-word search untypable)
    • useSettingsSearch — collapses the 7 identical settings search bindings
  • Scheduled tasks: selected task moves from a useState object to a ?taskId= occurrence-id param (derive the object; Back closes the modal; mutation-driven closes use history: 'replace')
  • Logs: row click / Enter / sidebar next-prev / close now keep ?executionId in sync (history: 'replace'), so the deep link no longer goes stale after the first click
  • Chunk view (knowledge document): search + sort migrated to the URL — the last un-migrated sortable list
  • .claude/rules/sim-url-state.md + the you-might-not-need-url-state command updated to prescribe the shared helpers

Type of Change

  • Improvement

Testing

Typecheck + biome clean; multi-angle adversarial review applied (folder-sort parity, deleted-export sweep, trim-on-read audit across every consumer, menu-id ⊆ columns verified per surface)

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jul 14, 2026 12:57am

Request Review

@cursor

cursor Bot commented Jul 13, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Broad refactor across many list and settings screens touches shareable URL semantics and search/sort behavior; logs and scheduled-task selection changes affect deep-linking and browser history, though changes are mostly mechanical migrations to shared hooks.

Overview
Introduces createSortParams + useUrlSort and useDebouncedSearchSetter (plus useSettingsSearch for settings lists), then migrates tables, knowledge, files, logs, settings, landing pages, and related surfaces off duplicated inline nuqs wiring.

Search behavior fix: URL params now store the raw input value; filtering and API calls trim on read, so trailing spaces stay typable during multi-word search.

Deep links: Scheduled tasks use ?taskId= (derive task from loaded occurrences; Back closes modal). Logs keep ?executionId in sync on row click, keyboard nav, and sidebar close via history: 'replace. Knowledge document chunk view adds URL-backed search and sort.

Docs and the you-might-not-need-url-state command now mandate the shared helpers and flag re-implemented sort/search as an anti-pattern.

Reviewed by Cursor Bugbot for commit 9cea09d. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR centralizes URL-backed search and sort behavior across the Sim app. The main changes are:

  • Shared helpers for debounced search params and sortable sort / dir params.
  • Migrated list, settings, files, logs, knowledge, tables, and chunk-view consumers.
  • URL-backed task selection for scheduled-task modal deep links.
  • URL-backed execution selection for log detail deep links.
  • Updated URL-state guidance and command docs.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
apps/sim/hooks/use-debounced-search-setter.ts Adds the shared debounced search-param setter used by migrated search fields.
apps/sim/hooks/use-url-sort.ts Adds shared URL sort wiring for defaulted and nullable sort modes.
apps/sim/lib/url-state/sort-params.ts Adds the shared sort and dir parser factory.
apps/sim/app/workspace/[workspaceId]/scheduled-tasks/hooks/use-scheduled-tasks.ts Moves selected scheduled-task occurrences into the taskId URL param.
apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx Moves chunk search and sort state into the URL and trims the query before search.

Reviews (7): Last reviewed commit: "fix(url-state): reset chunk page in the ..." | Re-trigger Greptile

Comment thread apps/sim/app/workspace/[workspaceId]/files/files.tsx
Comment thread apps/sim/app/workspace/[workspaceId]/knowledge/knowledge.tsx
Comment thread apps/sim/app/workspace/[workspaceId]/scheduled-tasks/hooks/use-scheduled-tasks.ts Outdated
Comment thread apps/sim/app/workspace/[workspaceId]/logs/search-params.ts
Comment thread apps/sim/app/workspace/[workspaceId]/logs/logs.tsx
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/app/workspace/[workspaceId]/scheduled-tasks/hooks/use-scheduled-tasks.ts Outdated
Comment thread apps/sim/app/workspace/[workspaceId]/scheduled-tasks/hooks/use-scheduled-tasks.ts Outdated
@waleedlatif1 waleedlatif1 force-pushed the nuqs-url-state-helpers branch from 70dce27 to 5ad9d26 Compare July 14, 2026 00:17
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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!

2 issues from previous reviews remain unresolved.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit e6e6e01. Configure here.

@waleedlatif1 waleedlatif1 force-pushed the nuqs-url-state-helpers branch from e6e6e01 to c69fedd Compare July 14, 2026 00:38
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 c69fedd. Configure here.

Base automatically changed from nuqs-url-state-fixes to staging July 14, 2026 00:46
@waleedlatif1 waleedlatif1 force-pushed the nuqs-url-state-helpers branch from c69fedd to 4810673 Compare July 14, 2026 00:48
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9cea09d. Configure here.

@waleedlatif1 waleedlatif1 merged commit 3d67b50 into staging Jul 14, 2026
18 checks passed
@waleedlatif1 waleedlatif1 deleted the nuqs-url-state-helpers branch July 14, 2026 01:08
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