Skip to content

Commit cf4aecc

Browse files
committed
docs(url-state): convert inline comments to TSDoc
1 parent 5ef4f6b commit cf4aecc

11 files changed

Lines changed: 84 additions & 50 deletions

File tree

apps/sim/app/workspace/[workspaceId]/home/home.tsx

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,30 @@ export function Home({ chatId, userName, userId }: HomeProps) {
6969
useOAuthReturnRouter()
7070
const { workspaceId } = useParams<{ workspaceId: string }>()
7171
const router = useRouter()
72-
// URL is the single source of truth for the selected resource. `Home` renders
73-
// client-side, so nuqs reads `?resource=` from the URL on mount — the same
74-
// value the page previously threaded through `initialResourceId` — and writes
75-
// it back with `history: 'replace'`, the previous behavior, minus the banned
76-
// `window.history.replaceState` param-mutation effect. The page wraps `Home`
77-
// in Suspense for the `useSearchParams` requirement.
72+
/**
73+
* URL is the single source of truth for the selected resource. `Home` renders
74+
* client-side, so nuqs reads `?resource=` from the URL on mount — the same
75+
* value the page previously threaded through `initialResourceId` — and writes
76+
* it back with `history: 'replace'`, the previous behavior, minus the banned
77+
* `window.history.replaceState` param-mutation effect. The page wraps `Home`
78+
* in Suspense for the `useSearchParams` requirement.
79+
*/
7880
const [activeResourceParam, setResourceParam] = useQueryState(resourceParam.key, {
7981
...resourceParam.parser,
8082
...resourceUrlKeys,
8183
})
82-
// Strips any leftover URL fragment on selection change, preserving the old
83-
// effect's `url.hash = ''` (the only hash usage on this surface) without a
84-
// separate effect-sync mirror. This rewrites the fragment only — it never
85-
// mutates a query param via the History API.
84+
/**
85+
* Strips any leftover URL fragment on selection change, preserving the old
86+
* effect's `url.hash = ''` (the only hash usage on this surface) without a
87+
* separate effect-sync mirror. This rewrites the fragment only — it never
88+
* mutates a query param via the History API.
89+
*
90+
* Order matters: the fragment is stripped synchronously BEFORE the nuqs write,
91+
* because nuqs re-appends `location.hash` on its (deferred) flush — clearing the
92+
* hash first ensures the param write doesn't carry the stale fragment back.
93+
*/
8694
const setActiveResourceUrl = useCallback<Dispatch<SetStateAction<string | null>>>(
8795
(action) => {
88-
// Order matters: strip the fragment synchronously BEFORE the nuqs write.
89-
// nuqs re-appends `location.hash` on its (deferred) flush, so clearing the
90-
// hash first ensures the param write doesn't carry the stale fragment back.
9196
if (typeof window !== 'undefined' && window.location.hash) {
9297
const { pathname, search } = window.location
9398
window.history.replaceState(window.history.state, '', `${pathname}${search}`)
@@ -96,8 +101,10 @@ export function Home({ chatId, userName, userId }: HomeProps) {
96101
},
97102
[setResourceParam]
98103
)
99-
// Controlled binding handed to `useChat` so the URL is the sole owner of the
100-
// selection with no dual source.
104+
/**
105+
* Controlled binding handed to `useChat` so the URL is the sole owner of the
106+
* selection with no dual source.
107+
*/
101108
const activeResourceState = useMemo<[string | null, Dispatch<SetStateAction<string | null>>]>(
102109
() => [activeResourceParam, setActiveResourceUrl],
103110
[activeResourceParam, setActiveResourceUrl]

apps/sim/app/workspace/[workspaceId]/home/hooks/use-chat.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,9 +1070,11 @@ export function useChat(
10701070
const internalActiveResourceState = useState<string | null>(
10711071
options?.initialActiveResourceId ?? null
10721072
)
1073-
// Prefer a caller-supplied controlled binding (URL-backed nuqs on the home/Chat
1074-
// surface) so the URL is the single source of truth; fall back to internal state
1075-
// for the workflow editor copilot, which keeps resource selection out of the URL.
1073+
/**
1074+
* Prefer a caller-supplied controlled binding (URL-backed nuqs on the home/Chat
1075+
* surface) so the URL is the single source of truth; fall back to internal state
1076+
* for the workflow editor copilot, which keeps resource selection out of the URL.
1077+
*/
10761078
const [activeResourceId, setActiveResourceId] =
10771079
options?.activeResourceState ?? internalActiveResourceState
10781080
const [genericResourceData, setGenericResourceData] = useState<GenericResourceData | null>(null)

apps/sim/app/workspace/[workspaceId]/integrations/integrations.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@ export function Integrations() {
141141
const [{ category: selectedCategory, search: urlSearchTerm }, setIntegrationFilters] =
142142
useQueryStates(integrationsParsers, integrationsUrlKeys)
143143

144-
// The input is controlled directly by the instant nuqs value; only the URL
145-
// write is debounced. Filtering below is cheap in-memory over a static list,
146-
// so it reads the instant value too.
144+
/**
145+
* The input is controlled directly by the instant nuqs value; only the URL
146+
* write is debounced. Filtering below is cheap in-memory over a static list,
147+
* so it reads the instant value too.
148+
*/
147149
const setSearchTerm = useCallback(
148150
(value: string) => {
149151
const trimmed = value.trim()

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/document.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,15 @@ export function Document({
188188

189189
const [selectedChunks, setSelectedChunks] = useState<Set<string>>(() => new Set())
190190

191-
// Inline editor state. The open chunk is sourced directly from the URL `chunk`
192-
// param (single source of truth) so back/forward, deep links, and external
193-
// navigation drive the editor; opening/closing a chunk writes the param.
191+
/**
192+
* Inline editor state. The open chunk is sourced directly from the URL `chunk`
193+
* param (single source of truth) so back/forward, deep links, and external
194+
* navigation drive the editor; opening/closing a chunk writes the param.
195+
*/
194196
const selectedChunkId = chunkFromURL
197+
/** Opening a chunk is a destination (back closes it); clearing replaces. */
195198
const setSelectedChunkId = useCallback(
196199
(chunkId: string | null) => {
197-
// Opening a chunk is a destination (back closes it); clearing replaces.
198200
void setDocumentParams({ chunk: chunkId }, chunkId !== null ? { history: 'push' } : undefined)
199201
},
200202
[setDocumentParams]

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/base.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,11 @@ export function KnowledgeBase({
293293
setDocumentFilters,
294294
] = useQueryStates(documentFiltersParsers, documentFiltersUrlKeys)
295295

296-
// The input is controlled directly by the instant nuqs value; only the URL
297-
// write is debounced. The document query below reads a debounced value so it
298-
// doesn't refetch on every keystroke. Changing the search resets pagination.
296+
/**
297+
* The input is controlled directly by the instant nuqs value; only the URL
298+
* write is debounced. The document query below reads a debounced value so it
299+
* doesn't refetch on every keystroke. Changing the search resets pagination.
300+
*/
299301
const handleSearchChange = useCallback(
300302
(newQuery: string) => {
301303
const trimmed = newQuery.trim()
@@ -898,8 +900,10 @@ export function KnowledgeBase({
898900
setDocumentFilters({ sort: column as KbSortColumn, dir: direction })
899901
setCurrentPage(1)
900902
},
901-
// Clearing writes the defaults back (stripped by clearOnDefault), so the
902-
// sort menu reads "no active sort" again and the URL stays clean.
903+
/**
904+
* Clearing writes the defaults back (stripped by clearOnDefault), so the
905+
* sort menu reads "no active sort" again and the URL stays clean.
906+
*/
903907
onClear: () => {
904908
setDocumentFilters({ sort: DEFAULT_KB_SORT_COLUMN, dir: DEFAULT_KB_SORT_DIRECTION })
905909
setCurrentPage(1)

apps/sim/app/workspace/[workspaceId]/logs/components/log-details/log-details.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,11 @@ export function LogDetailsContent({ log, onActiveTabChange }: LogDetailsContentP
278278
const { config: permissionConfig } = usePermissionConfig()
279279

280280
const isInitialTabMountRef = useRef(true)
281+
/**
282+
* Honors a deep-linked tab on first mount; resets to overview only when
283+
* switching to a different log.
284+
*/
281285
useEffect(() => {
282-
// Honor a deep-linked tab on first mount; reset to overview only when switching to a different log.
283286
if (isInitialTabMountRef.current) {
284287
isInitialTabMountRef.current = false
285288
} else {

apps/sim/app/workspace/[workspaceId]/logs/hooks/use-log-filters.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,15 @@ export function useLogFilters(): UseLogFilters {
115115
[setFilters]
116116
)
117117

118+
/**
119+
* Debounces only the search param's URL write; the returned `filters.search`
120+
* value still updates instantly so the controlled input stays responsive.
121+
* Clearing flushes immediately so the param drops out without lingering.
122+
*/
118123
const setSearchQuery = useCallback(
119124
(query: string) => {
120125
const trimmed = query.trim()
121126
const next = trimmed.length > 0 ? trimmed : null
122-
// Debounce only the search param's URL write; the returned `filters.search`
123-
// value still updates instantly so the controlled input stays responsive.
124-
// Clearing flushes immediately so the param drops out without lingering.
125127
setFilters(
126128
{ search: next },
127129
next === null ? undefined : { limitUrlUpdates: debounce(SEARCH_DEBOUNCE_MS) }

apps/sim/app/workspace/[workspaceId]/logs/logs.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,17 +237,21 @@ export default function Logs() {
237237
const [executionId] = useQueryState(executionIdParam.key, executionIdParam.parser)
238238
const [pendingExecutionId, setPendingExecutionId] = useState<string | null>(() => executionId)
239239

240-
// The log-details `tab` param is owned/written by the details panel, but the
241-
// orchestrator must clear it when the panel closes so a lingering `?tab=trace`
242-
// never carries over to the next log opened from the list.
240+
/**
241+
* The log-details `tab` param is owned/written by the details panel, but the
242+
* orchestrator must clear it when the panel closes so a lingering `?tab=trace`
243+
* never carries over to the next log opened from the list.
244+
*/
243245
const [, setLogDetailsTab] = useQueryState(logDetailsTabParam.key, {
244246
...logDetailsTabParam.parser,
245247
...logDetailsTabUrlKeys,
246248
})
247249

248-
// `urlSearchQuery` is the instant nuqs value (its URL write is debounced inside
249-
// `useLogFilters`); the query/filtering still debounce off it to avoid per-keystroke
250-
// fetches.
250+
/**
251+
* `urlSearchQuery` is the instant nuqs value (its URL write is debounced inside
252+
* `useLogFilters`); the query/filtering still debounce off it to avoid
253+
* per-keystroke fetches.
254+
*/
251255
const debouncedSearchQuery = useDebounce(urlSearchQuery, 300)
252256

253257
const isLive = true
@@ -487,9 +491,11 @@ export default function Logs() {
487491
}
488492
}, [contextMenuLog, workflowIds, setWorkflowIds])
489493

494+
/**
495+
* `resetFilters()` already clears `search` (sets it to null), so no separate
496+
* search reset is needed here.
497+
*/
490498
const handleClearAllFilters = useCallback(() => {
491-
// `resetFilters()` already clears `search` (sets it to null), so no separate
492-
// search reset is needed here.
493499
resetFilters()
494500
}, [resetFilters])
495501

apps/sim/app/workspace/[workspaceId]/settings/components/recently-deleted/recently-deleted.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,11 @@ export function RecentlyDeleted() {
157157
setRecentlyDeletedFilters,
158158
] = useQueryStates(recentlyDeletedParsers, recentlyDeletedUrlKeys)
159159

160-
// The input is controlled directly by the instant nuqs value; only the URL
161-
// write is debounced. Filtering below is cheap in-memory over a small list, so
162-
// it reads the instant value too.
160+
/**
161+
* The input is controlled directly by the instant nuqs value; only the URL
162+
* write is debounced. Filtering below is cheap in-memory over a small list, so
163+
* it reads the instant value too.
164+
*/
163165
const setSearchTerm = useCallback(
164166
(value: string) => {
165167
const trimmed = value.trim()

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,10 @@ export function Table({
504504
options: columnOptions,
505505
active: sortColumn ? { column: sortColumn, direction: sortDirection } : null,
506506
onSort: (column, direction) => setSortParams({ sort: column, dir: direction }),
507-
// Clearing writes the default direction (stripped by clearOnDefault) and
508-
// drops the column, leaving a clean URL with no active sort.
507+
/**
508+
* Clearing writes the default direction (stripped by clearOnDefault) and
509+
* drops the column, leaving a clean URL with no active sort.
510+
*/
509511
onClear: () => setSortParams({ sort: null, dir: DEFAULT_TABLE_DETAIL_SORT_DIRECTION }),
510512
}),
511513
[columnOptions, sortColumn, sortDirection, setSortParams]

0 commit comments

Comments
 (0)