Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion apps/server/src/client/pages/events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,17 @@ export default function EventsPage() {
const setStatus = (s: string) => updateParams({ status: s === "all" ? null : s, page: "1" })

const applyRepoFilter = () => {
// No-op when the committed value is unchanged so a plain focus/blur doesn't
// reset the page or push a duplicate history entry.
if (repoInput === repoFilter) return
updateParams({ repo: repoInput || null, page: "1" })
}

const clearRepoFilter = () => {
setRepoInput("")
updateParams({ repo: null, page: "1" })
// Only reset the page when a filter was actually active; clearing an empty
// input (e.g. Escape on a later page) should leave pagination untouched.
updateParams(repoFilter ? { repo: null, page: "1" } : { repo: null })
}

const handleRepoKeyDown = (e: React.KeyboardEvent) => {
Expand Down Expand Up @@ -177,6 +182,9 @@ export default function EventsPage() {
{repoInput && (
<button
type="button"
// Prevent the input's onBlur from firing applyRepoFilter before this
// click clears the filter, which would push an extra history entry.
onMouseDown={(e) => e.preventDefault()}
onClick={clearRepoFilter}
aria-label="Clear repo filter"
className="absolute right-2 text-muted-foreground hover:text-foreground"
Expand Down
42 changes: 36 additions & 6 deletions apps/server/src/client/pages/sessions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ type ClearMode = "all" | "idle"
export default function SessionsPage() {
const navigate = useNavigate()
const [searchParams, setSearchParams] = useSearchParams()
const [searchInput, setSearchInput] = useState("")
const [searchInput, setSearchInput] = useState(searchParams.get("search") ?? "")
const [clearMode, setClearMode] = useState<ClearMode | null>(null)
const clearSessions = useClearSessions()

Expand All @@ -140,6 +140,12 @@ export default function SessionsPage() {
const statusFilter: SessionStatusFilter = STATUS_FILTERS.some((sf) => sf.value === statusParam)
? (statusParam as SessionStatusFilter)
: "all"
const searchFilter = searchParams.get("search") ?? ""

// Sync input with URL param when navigating (back/forward)
useEffect(() => {
setSearchInput(searchParams.get("search") ?? "")
}, [searchParams])

const { data, isLoading, isError, dataUpdatedAt, isFetching, refetch } = useSessions({ page, limit })

Expand Down Expand Up @@ -171,11 +177,30 @@ export default function SessionsPage() {
statusCounts[sessionStatusBucket(session.status)]++
}

Comment thread
jared-outpost[bot] marked this conversation as resolved.
Resolved
const applySearchFilter = () => {
// No-op when the committed value is unchanged so a plain focus/blur doesn't
// reset the page or push a duplicate history entry.
if (searchInput === searchFilter) return
updateParams({ search: searchInput || null, page: "1" })
}

const clearSearchFilter = () => {
setSearchInput("")
// Only reset the page when a filter was actually active; clearing an empty
// input (e.g. Escape on a later page) should leave pagination untouched.
updateParams(searchFilter ? { search: null, page: "1" } : { search: null })
}
Comment thread
jared-outpost[bot] marked this conversation as resolved.
Resolved
Comment thread
jared-outpost[bot] marked this conversation as resolved.
Resolved

const handleSearchKeyDown = (e: React.KeyboardEvent) => {
if (e.key === "Enter") applySearchFilter()
Comment thread
jared-outpost[bot] marked this conversation as resolved.
Resolved
if (e.key === "Escape") clearSearchFilter()
}
Comment thread
jared-outpost[bot] marked this conversation as resolved.
Resolved

const filtered = sortSessionsByCreatedAt(
allSessions.filter((session: SessionListItem) => {
if (statusFilter !== "all" && sessionStatusBucket(session.status) !== statusFilter) return false
if (!searchInput) return true
const q = searchInput.toLowerCase()
if (!searchFilter) return true
const q = searchFilter.toLowerCase()
return (
session.entityKey.toLowerCase().includes(q) ||
(session.title ?? "").toLowerCase().includes(q) ||
Expand Down Expand Up @@ -313,12 +338,17 @@ export default function SessionsPage() {
aria-label="Search agent runs"
value={searchInput}
onChange={(e) => setSearchInput(e.target.value)}
onKeyDown={handleSearchKeyDown}
onBlur={applySearchFilter}
className="h-7 w-full pl-7 pr-7"
/>
{searchInput && (
<button
type="button"
onClick={() => setSearchInput("")}
// Prevent the input's onBlur from firing applySearchFilter before this
// click clears the filter, which would push an extra history entry.
onMouseDown={(e) => e.preventDefault()}
onClick={clearSearchFilter}
aria-label="Clear agent-run search"
className="absolute right-2 text-muted-foreground hover:text-foreground"
>
Expand Down Expand Up @@ -350,11 +380,11 @@ export default function SessionsPage() {
<div className="flex flex-col items-center gap-2 py-16">
<Robot className="size-8 text-muted-foreground/50" />
<p className="text-sm text-muted-foreground">
{searchInput || statusFilter !== "all"
{searchFilter || statusFilter !== "all"
? "No runs match your filters"
: "No agent runs yet. Runs start from a GitHub event — or you can start one yourself."}
</p>
{!searchInput && statusFilter === "all" && (
{!searchFilter && statusFilter === "all" && (
<NewChatDialog
trigger={
<Button variant="outline" size="sm">
Expand Down
Loading