Skip to content

fix(site/src/pages/AgentsPage): support archived URL query#24742

Merged
johnstcn merged 3 commits intomainfrom
cian/agents-archived-url-filter
Apr 28, 2026
Merged

fix(site/src/pages/AgentsPage): support archived URL query#24742
johnstcn merged 3 commits intomainfrom
cian/agents-archived-url-filter

Conversation

@johnstcn
Copy link
Copy Markdown
Member

@johnstcn johnstcn commented Apr 27, 2026

Persists the agents page archived filter in the URL via ?archived=archived,
so deep-linking to archived agents and restoring the filter from history work
as expected. Unknown values fall back to active. Toggling back to active
removes the param from the URL so the default state has one canonical form.

Also fixes a regression that surfaced once the filter became URL-derived:
clicking a chat in the sidebar previously navigated to /agents/:id with no
search params, silently resetting the filter. The sidebar's chat NavLink
now preserves location.search.

Coverage:

  • useArchivedFilterParam is unit-tested with renderHook, covering URL
    parsing variants and the deleteValue semantics for the default state.
  • Cross-route preservation is covered by a Storybook play story
    (PreservesArchivedFilterOnChatNavigation) that renders the real NavLink
    and asserts on a probe child route.
  • The pre-existing sidebar callback tests in AgentsSidebar.test.tsx cover
    wiring that exists on main; they're kept here for completeness rather
    than as new feature gates.

Generated by Coder Agent.

@johnstcn
Copy link
Copy Markdown
Member Author

/coder-agents-review

Copy link
Copy Markdown
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

Looks OK to me, although FE is not my expertise.

Comment thread site/src/pages/AgentsPage/AgentsPage.urlParams.test.tsx Outdated
Copy link
Copy Markdown

@coder-agents-review coder-agents-review Bot left a comment

Choose a reason for hiding this comment

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

Well-scoped change. Replaces useState with the established useSearchParamsKey hook in 12 lines of production code. The toArchivedFilter normalizer handles garbage inputs. The test suite covers four URL-parse variants, replace semantics via back-button, and history restoration.

"I tried to build a case against this change and could not." (Pariston)

1 P1, 3 P3, 2 Nit. The P1 is a functional regression: sidebar chat links use absolute paths that strip ?archived, so clicking any chat while viewing the archived list silently resets the filter to active. Before the PR, useState survived child-route navigation because component state persists in a mounted layout. After the PR, the filter is URL-derived, and child-route URLs carry no ?archived param.

Nit [DEREM-7] Commit subject "sync archived filter URL" does not name the problem or the consequence. A body sentence explaining the prior useState-only state would help future git blame readers. (Leorio)

PS. The PR description says "container URL parsing." In this codebase, "container" means Docker/dev containers. "Page-level URL param parsing" or "archived filter URL parsing" would avoid the ambiguity.

🤖 This review was automatically generated with Coder Agents.

Comment thread site/src/pages/AgentsPage/AgentsPage.tsx Outdated
Comment thread site/src/pages/AgentsPage/AgentsPage.tsx Outdated
Comment thread site/src/pages/AgentsPage/AgentsPage.tsx Outdated
Comment thread site/src/pages/AgentsPage/AgentsPage.urlParams.test.tsx Outdated
Comment thread site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.test.tsx
Comment thread site/src/pages/AgentsPage/AgentsPage.urlParams.test.tsx Outdated
@johnstcn
Copy link
Copy Markdown
Member Author

/coder-agents-review

Copy link
Copy Markdown

@coder-agents-review coder-agents-review Bot left a comment

Choose a reason for hiding this comment

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

Strong progress. 5 of 7 findings addressed in 7dc8f3c, including the P1 (sidebar links now preserve location.search) and the spy assertion issue (test file replaced with hook-level renderHook tests). The PR description is much improved.

DERM-6 (commit type fix vs feat) is contested by the maintainer; the panel will evaluate the defense in the next round.

One finding is blocking further review:

DEREM-7 (Nit, commit message): The commit subject "sync archived filter URL" does not name the problem or consequence. No response or change. The PR description body now explains the prior state well, which addresses part of the concern (the body will become the squash commit message body). If the subject is intentional, a brief acknowledgment unblocks the next round.

🤖 This review was automatically generated with Coder Agents.

@johnstcn johnstcn changed the title fix(site/src/pages/AgentsPage): sync archived filter URL fix(site/src/pages/AgentsPage): support archived URL query Apr 28, 2026
@johnstcn
Copy link
Copy Markdown
Member Author

DEREM-7 (Nit, commit message): The commit subject "sync archived filter URL" does not name the problem or consequence. No response or change. The PR description body now explains the prior state well, which addresses part of the concern (the body will become the squash commit message body). If the subject is intentional, a brief acknowledgment unblocks the next round.

Updated PR title.

@johnstcn
Copy link
Copy Markdown
Member Author

/coder-agents-review

@johnstcn johnstcn marked this pull request as ready for review April 28, 2026 10:21
Copy link
Copy Markdown

@coder-agents-review coder-agents-review Bot left a comment

Choose a reason for hiding this comment

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

All five R1 fixes verified by the full panel. The hook extraction is clean, the NavLink search propagation works, the test strategy is solid. The PreservesArchivedFilterOnChatNavigation story is well-constructed: a probe component at the target route reads real useLocation() search, proving the param survived navigation rather than just checking the NavLink's rendered href.

"The code held up. Clean hook extraction, correct URL semantics, appropriate test strategy. Nothing left to fight." (Hisoka)

DEREM-6 (commit type fix vs feat) closed by panel vote (5/5 accept the author's defense). A filter that resets on navigation is plausibly broken behavior; the consequence of either label is changelog placement only.

1 new P3 below. Otherwise this is ready.

🤖 This review was automatically generated with Coder Agents.

to={`/agents/${chat.id}`}
to={{
pathname: `/agents/${chat.id}`,
search: location.search,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3 [DEREM-17] Sibling navigation paths still drop ?archived, silently resetting the filter. (Kite)

"Every other navigation to /agents still drops search params. ChatTopBar.tsx:90 uses <Link to="/agents"> (mobile back button). AgentsSidebar.tsx:1108 stores state={{ from: location.pathname }} without search. The return link at line 1359 restores the pathname but loses ?archived=archived." (Kite)

The sidebar NavLink fix here is correct and complete. But the same root cause (bare /agents links dropping search params) exists in two siblings:

  1. ChatTopBar.tsx:90: <Link to="/agents"> (mobile back button, md:hidden). User views archived list, taps a chat, taps Back, filter resets.
  2. AgentsSidebar.tsx:1108/1359: Settings link stores location.pathname without search; return link restores it without ?archived.

Before this PR the filter was useState-only so these paths already lost it. Now that the filter is URL-derived, users have higher expectations that it will persist. The fix is the same pattern: pass { pathname, search: location.search } or store location.pathname + location.search in state.from.

Could we address these in this PR, or are they better as a follow-up?

🤖

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Will do as a follow-up.

@johnstcn johnstcn merged commit 68c8499 into main Apr 28, 2026
32 checks passed
@johnstcn johnstcn deleted the cian/agents-archived-url-filter branch April 28, 2026 10:41
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants