Skip to content

Add organization pagination, sorting, and design review fixtures - #68

Closed
rocco-zhang wants to merge 14 commits into
stagingfrom
rocco_11-07_TIG-308-org-seed
Closed

rocco-zhang wants to merge 14 commits into
stagingfrom
rocco_11-07_TIG-308-org-seed

Conversation

@rocco-zhang

Copy link
Copy Markdown

Summary

Adds organization directory pagination and sorting, design review fixtures, and local development improvements.

  • Load 10 organizations per page with First/Previous/Next controls and result counts.
  • Sort by name, imported member count, or creation date in either direction.
  • Preserve search, category, sorting, and pagination cursors in the URL.
  • Add keyset pagination queries, six supporting database indexes, and Postgres integration tests.
  • Add repeatable local review fixtures: 312 organizations, 24 demo users, 12 events, and varied logos, descriptions, and follower counts.
  • Centralize environment configuration in the root .env and improve database startup, pgvector setup, Docker container naming, and Turbopack configuration.

Scope

Related to TIG-308 (https://linear.app/tigerapps/issue/TIG-308/tig-308-organizations-page-redesign). This PR does not complete or close TIG-308. The Figma redesign, suggestion cards, remaining visual states, and design review remain outstanding.

Apply the new database migration or push the schema before using the updated directory. The review guide currently describes 15-row pages; the implementation uses 10.

Validation

  • Passed organization review seed dry run.
  • Passed git diff --check.
  • Postgres pagination tests skipped because ORG_TEST_DATABASE_URL was unset.
  • Full build and browser checks were not run during PR preparation.

@linear

linear Bot commented Nov 9, 2026

Copy link
Copy Markdown

TIG-308

@yubimamiya

Copy link
Copy Markdown

Review: fix before merge

Thanks for this. The keyset pagination is solid: all 6 sort/direction round-trip tests pass against Postgres. I tested this branch merged with current staging against a local DB seeded with db:seed:org-review. These need fixing before merge:

1. bun test will fail on staging after merge

Staging added apps/web/src/actions/org-boundaries.test.ts after this branch was cut. Its runIsolated helper rebuilds the @the-forum/database mock from only schema + drizzle-orm. That mock doesn't include the new loadOrganizationPage export, so importing ~/actions/orgs throws:

SyntaxError: Export named 'loadOrganizationPage' not found in module '.../apps/database/src/index.ts'

It passes on each branch alone, so the PR's green CI (which ran before that test existed) won't catch it, and GitHub shows no conflict.
Fix: merge staging into this branch and add loadOrganizationPage to the mock, e.g. loadOrganizationPage: async () => { throw new Error("unexpected") }. Then re-run bun test.

2. Postgres pagination tests: 3 of 12 fail when run

With ORG_TEST_DATABASE_URL set against a migrated local DB:

  • "deleting the boundary row preserves the next page" reads first.items[14] (line 172), which assumes 15-row pages. ORGANIZATION_PAGE_SIZE is 10, so this crashes.
  • "category/search remain applied…" expects toHaveLength(9), which is also based on 15-row pages.
  • "all sorts can seek through their matching index without a Sort node": for name, the planner picks the existing organizations_name_unique index plus an Incremental Sort, not organizations_name_id_idx. That's a reasonable plan on a tiny table, so the assertion is too strict. Accept either index, or drop the name case.

Please derive the counts from ORGANIZATION_PAGE_SIZE so they don't go stale again. Also update the review guide (org-review.md), which still says 15.

Bugs in the UI

3. Switching sort keeps the previous direction

navigate() in orgs-client.tsx defaults order = initialOrder and always writes order to the URL. The sort <Select> (around line 286) doesn't pass a new order. So going from the default Name (asc) to Member count requests sort=members&order=asc. The first page is then all orgs with memberCount = null, because the coalesce sentinel sorts them first ascending. Expected is largest first (1197, 1194, …). Date created shows oldest first for the same reason.
Fix: when the sort changes, reset order to that sort's default (name → asc, others → desc). Or only write order to the URL when it differs from the default.

4. Stale or shared cursor links show a dead end

If the cursor is beyond the remaining results (e.g., rows were deleted), loadOrganizationPage returns 0 items with previousCursor: null, nextCursor: null and hasCursor: true. The UI then shows "0–0 of 312", the "Be the first to create one!" empty state, and First/Previous/Next all disabled. Repro: loadOrganizationPage({ sort: "name", cursor: { direction: "next", id: "ffffffff-ffff-ffff-ffff-ffffffffffff", value: "zzzz" } }).
hasCursor was added for this case but the client never reads it.
Fix: enable First when initialOrgs.hasCursor is true (not only when previousCursor exists). Ideally also show a "Back to first page" action in the empty state when hasCursor && total > 0.

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.

2 participants