To the right of the everyone / yours toggled, can we add a filter for merged, running, open, and waiting
Merged, running, open filter
Adding a status filter next to Everyone | Yours on the home page.
lib/workspace-filter.ts:ThreadFiltersgainsstatus: "" | "open" | "running" | "waiting_on_human" | "merged", parsed from?status=.components/thread-browser.tsx: second.segradiogroup — All | Open | Running | Waiting | Merged — sends&status=to the live fetch and mirrors it into the URL (no-JS GET submit works too, same aswho).app/api/threads/route.ts+lib/data.ts listThreads: newstatusfilter (threads.status = …).app/page.tsx: first paint honours?status=.- CSS: let
.thread-filterswrap so both segments fit on a phone.
threadide@2c85ac2Code is in and pushed (2c85ac2 on thread/afe82372, tsc clean). Summary:
- URL/API:
?status=open|running|waiting_on_human|mergedon/, andGET /api/threads?status=…. Anything else = any status. Defined once inlib/workspace-filter.ts(STATUS_FILTERS,parseStatus);listThreads({ status })addsthreads.status = …. - UI: second
.segradiogroup — All | Open | Running | Waiting | Merged — right of Everyone | Yours incomponents/thread-browser.tsx. Filter changes fetch immediately (no debounce), URL mirrored via replaceState, and because they're radios in the GET form it works without JS too. Header workspace dropdown already copieswindow.location.search, so switching workspace keeps the status. - Empty-state copy adapts ("No merged threads right now.", "You haven't started or replied to any running threads yet.").
.thread-filtersnowflex-wrap: wrapso the two groups stack on a phone.
Deliberately only those four statuses (done/failed stay under All) — say the word if you want Done/Failed segments too; it's one line in STATUS_FILTERS.
Grabbing a mockup screenshot next.
threadide@82fe813Done — pushed to thread/afe82372 (2 commits, tsc clean). The home page now has an All | Open | Running | Waiting | Merged segmented toggle right of Everyone | Yours.
How it works
lib/workspace-filter.ts:STATUS_FILTERS(the four statuses + labels) andparseStatus();ThreadFilters.statusis"" | open | running | waiting_on_human | merged. Unknown values fall back to "" (any).GET /api/threads?status=…→listThreads({ status })addsthreads.status = …alongside the workspace / mine / q filters.app/page.tsxreads?status=for the first paint, so/?status=runningis shareable and reload-safe.components/thread-browser.tsx: second.seg.seg-statusradiogroup. Changes fetch immediately (no debounce), the URL is mirrored with replaceState, and since the radios live inside the GET form it still works without JS. The header workspace dropdown already copieswindow.location.search, so switching workspace keeps the status. Empty states adapt ("No merged threads right now.").- CSS:
.thread-filterswraps; on ≤560px the status group takes its own full-width row with evenly-shared segments (five didn't fit beside Everyone | Yours at 390px — "Merged" clipped before this).
Scope note: exactly the four statuses you listed. done and failed threads only show under All; adding them is one tuple in STATUS_FILTERS if you want it. Screenshot attached is a static mockup on the real stylesheet (the app can't run in the sandbox). No PR opened — say so if you want one.
Diff · 6 files
diff --git a/threadide/lib/workspace-filter.ts b/threadide/lib/workspace-filter.ts
--- a/threadide/lib/workspace-filter.ts
+++ b/threadide/lib/workspace-filter.ts
@@ -9,14 +9,32 @@ export const GENERAL_WORKSPACE = "general";
export type Who = "all" | "mine";
+/**
+ * Thread statuses the home page can filter on ("" = any). A subset of the thread_status enum on purpose:
+ * done/failed are reachable through "All" — the owner asked for exactly these four (thread afe82372).
+ */
+export const STATUS_FILTERS = [
+ ["open", "Open"],
+ ["running", "Running"],
+ ["waiting_on_human", "Waiting"],
+ ["merged", "Merged"],
+] as const;
+export type StatusFilter = "" | (typeof STATUS_FILTERS)[number][0];
+
/** Home-page filter state. `workspace` is "" (all), GENERAL_WORKSPACE ("general", no workspace) or a workspace id. */
-export type ThreadFilters = { workspace: string; who: Who };
+export type ThreadFilters = { workspace: string; who: Who; status: StatusFilter };
+
+/** `?status=…` → a known status filter or "" (any). Also used by GET /api/threads?status=. */
+export function parseStatus(raw: string | null | undefined): StatusFilter {
+ return STATUS_FILTERS.some(([v]) => v === raw) ? (raw as StatusFilter) : "";
+}
-/** `?workspace=…&who=…` → validated filters. Shared by the page (first paint) and the browser (URL parsing). */
-export function parseFilters(params: { workspace?: string; who?: string }, knownWorkspaces: Record<string, unknown>): ThreadFilters {
+/** `?workspace=…&who=…&status=…` → validated filters. Shared by the page (first paint) and the browser (URL parsing). */
+export function parseFilters(params: { workspace?: string; who?: string; status?: string }, knownWorkspaces: Record<string, unknown>): ThreadFilters {
const ws = params.workspace ?? "";
return {
workspace: ws === GENERAL_WORKSPACE || ws in knownWorkspaces ? ws : "",
who: params.who === "mine" ? "mine" : "all",
+ status: parseStatus(params.status),
};
}
diff --git a/threadide/lib/data.ts b/threadide/lib/data.ts
--- a/threadide/lib/data.ts
+++ b/threadide/lib/data.ts
@@ -233,6 +233,8 @@ export type ThreadFilter = {
/** Only threads this user started or posted in (the home page's "Yours" filter). */
participantId?: string;
+ /** Only threads in this status (the home page's Open | Running | Waiting | Merged filter). Omit for any. */
+ status?: (typeof threads.$inferSelect)["status"];
};
@@ -244,7 +246,7 @@
-export async function listThreads({ workspaceId, q, participantId }: ThreadFilter = {}) {
+export async function listThreads({ workspaceId, q, participantId, status }: ThreadFilter = {}) {
@@ -251,8 +253,9 @@
+ const inStatus = status ? eq(threads.status, status) : undefined;
return db.query.threads.findMany({
- where: and(scope, mine, ...termFilters),
+ where: and(scope, mine, inStatus, ...termFilters),
diff --git a/threadide/app/api/threads/route.ts b/threadide/app/api/threads/route.ts
--- a/threadide/app/api/threads/route.ts
+++ b/threadide/app/api/threads/route.ts
@@ -4 +4 @@
-import { GENERAL_WORKSPACE } from "@/lib/workspace-filter";
+import { GENERAL_WORKSPACE, parseStatus } from "@/lib/workspace-filter";
@@ -18,7 +18,9 @@
const participantId = params.get("mine") === "1" ? user.id : undefined;
- const rows = await listThreads({ workspaceId, q, participantId });
+ // status=open|running|waiting_on_human|merged: one status only; anything else = any status.
+ const status = parseStatus(params.get("status")) || undefined;
+ const rows = await listThreads({ workspaceId, q, participantId, status });
diff --git a/threadide/app/page.tsx b/threadide/app/page.tsx
--- a/threadide/app/page.tsx
+++ b/threadide/app/page.tsx
@@ -11 +11 @@
-export default async function Home({ searchParams }: { searchParams: Promise<{ q?: string; workspace?: string; who?: string }> }) {
+export default async function Home({ searchParams }: { searchParams: Promise<{ q?: string; workspace?: string; who?: string; status?: string }> }) {
@@ -22,4 +22,5 @@
participantId: filters.who === "mine" ? user.id : undefined,
+ status: filters.status || undefined,
});
diff --git a/threadide/components/thread-browser.tsx b/threadide/components/thread-browser.tsx
--- a/threadide/components/thread-browser.tsx
+++ b/threadide/components/thread-browser.tsx
@@ -4 +4 @@
-import { GENERAL_WORKSPACE, type ThreadFilters } from "@/lib/workspace-filter";
+import { GENERAL_WORKSPACE, STATUS_FILTERS, type ThreadFilters } from "@/lib/workspace-filter";
@@ -25 +26 @@
- initialFilters = { workspace: "", who: "all" },
+ initialFilters = { workspace: "", who: "all", status: "" },
@@ -69 +70 @@
- const keyOf = (term: string, f: ThreadFilters) => JSON.stringify([term, f.workspace, f.who]);
+ const keyOf = (term: string, f: ThreadFilters) => JSON.stringify([term, f.workspace, f.who, f.status]);
@@ -86,2 +87,3 @@
if (f.who === "mine") params.set("mine", "1");
+ if (f.status) params.set("status", f.status);
if (term) params.set("q", term);
@@ -130,2 +132,3 @@
if (filters.who === "mine") params.set("who", "mine");
+ if (filters.status) params.set("status", filters.status);
const qs = params.toString();
@@ -147,8 +150,11 @@
const wsName = filters.workspace === GENERAL_WORKSPACE ? "general discussion" : workspaces?.[filters.workspace]?.name;
+ const statusName = STATUS_FILTERS.find(([v]) => v === filters.status)?.[1].toLowerCase();
const empty = trimmed
? `No threads match “${trimmed}”.`
: filters.who === "mine"
- ? `You haven't started or replied to any threads${wsName ? ` in ${wsName}` : ""} yet.`
- : wsName
- ? `No ${wsName} threads yet.`
- : emptyDefault;
+ ? `You haven't started or replied to any ${statusName ? `${statusName} ` : ""}threads${wsName ? ` in ${wsName}` : ""} yet.`
+ : statusName
+ ? `No ${statusName} ${wsName ? `${wsName} ` : ""}threads right now.`
+ : wsName
+ ? `No ${wsName} threads yet.`
+ : emptyDefault;
@@ -211,2 +217,11 @@
</div>
+ {/* Status: All | Open | Running | Waiting | Merged. Same radio trick; "" = any status. */}
+ <div className="seg seg-status" role="radiogroup" aria-label="Thread status">
+ {([["", "All"], ...STATUS_FILTERS] as const).map(([value, label]) => (
+ <label key={value || "all"} className={filters.status === value ? "is-on" : undefined}>
+ <input type="radio" name="status" value={value} checked={filters.status === value} onChange={() => setFilters((f) => ({ ...f, status: value }))} />
+ {label}
+ </label>
+ ))}
+ </div>
diff --git a/threadide/app/globals.css b/threadide/app/globals.css
--- a/threadide/app/globals.css
+++ b/threadide/app/globals.css
@@ -120 +121 @@
-.thread-filters { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; }
+.thread-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; }
@@ -151,0 +152,4 @@ @media (max-width: 560px) {
+ /* Five status segments don't fit beside Everyone | Yours at 390px: the group takes its own full row,
+ segments share the width evenly and padding tightens so "Merged" isn't clipped. */
+ .thread-filters .seg-status { flex: 1 1 100%; }
+ .thread-filters .seg-status label { flex: 1 1 0; justify-content: center; padding: 6px 4px; letter-spacing: .03em; }
}Can you make it a dropdown filter that also has All
Swapping the five-segment status group for a <select> (All | Open | Running | Waiting | Merged), styled like the header workspace dropdown (.ws-select). Same ?status= URL/API contract, so only components/thread-browser.tsx and the CSS change.
threadide@0c99346Pushed 0c99346 on thread/afe82372 (tsc clean). The five-segment status group is now a native <select> right of Everyone | Yours: All statuses | Open | Running | Waiting | Merged.
- Same
?status=URL /GET /api/threads?status=contract — onlycomponents/thread-browser.tsxandapp/globals.csschanged.lib/workspace-filter.ts(STATUS_FILTERS),lib/data.ts, the API route andapp/page.tsxare untouched. - The select is named
statusinside the GET form, so the no-JS Enter submit still carries it; with JS, change → immediate fetch + URL replaceState, as before. - Styling reuses the header workspace dropdown's
.ws-select(chevron, darker text/border when a value is picked) plus a.status-selectmodifier matching the segment type (13px/600 uppercase). The phone rule that gave the segments their own full row is gone — the dropdown fits beside Everyone | Yours at 390px and stretches to fill the row.
Grabbing a mockup screenshot now.
threadide@0c99346Done — 0c99346 pushed to thread/afe82372 (tsc clean). The status filter is now a dropdown right of Everyone | Yours with All statuses | Open | Running | Waiting | Merged; "All statuses" is the default and clears the filter.
What changed (only two files; the URL/API contract from the previous commits is untouched)
components/thread-browser.tsx: the.seg.seg-statusradiogroup became a native<select name="status">fed fromSTATUS_FILTERS. Change → immediate fetch + URLreplaceState(?status=…), and because it's a named field in the GET form it still works without JS.app/globals.css: the select reuses the header workspace dropdown's.ws-select(CSS chevron, darker text/border when a value is picked) plus a.status-selectmodifier so it matches the segments' 13px/600 uppercase type and height. The phone-only "status group takes its own full row" rule is gone — the dropdown fits beside Everyone | Yours at 390px and stretches to fill the row.
Screenshot attached (static mockup on the real stylesheet — the app can't run in the sandbox). done/failed are still only reachable via "All statuses"; adding them is one tuple in STATUS_FILTERS (lib/workspace-filter.ts). No PR opened — say so if you want one.

