Skip to content

feat: global search for projects, tasks and people (Cmd/Ctrl+K) - #830

Merged
pikann merged 6 commits into
Paca-AI:masterfrom
robertcoroianu:feat/global-search
Nov 26, 2026
Merged

pikann merged 6 commits into
Paca-AI:masterfrom
robertcoroianu:feat/global-search

Conversation

@robertcoroianu

@robertcoroianu robertcoroianu commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a search box to the app header. Click it or press Cmd/Ctrl+K to search projects, tasks and people across the workspace. Results only include what the caller is allowed to see.

API: GET /search?q=&limit=

Any authenticated caller can call the route. The handler decides what to return, starting from the same set of projects as workspace-stats: every project for a holder of platform projects:read, otherwise the caller's own projects.

Kind Who sees what
Projects Projects the caller holds projects:read on
Tasks Tasks the caller may read in each project. The per-project tasks:read scope is applied in SQL (ListScopes + WithProjectScopes), so a role limited to one sprint only finds that sprint's tasks.
People Live users who are members of a project whose member list the caller may read (project.members:read), i.e. their teammates. Only a user admin (users:write) finds people outside their teams. Agents and service accounts are not included.
  • The per-project checks are one AuthorizeMany call. If the authorizer fails, the request returns a 500; results never widen.
  • Tasks match on title or task key. ABC-12 finds exactly that task; #12 or 12 matches that number in any project, and those matches come first.
  • Each task carries its type's name, icon and color.
  • limit is 1–20 (default 5); q is at most 200 characters; an empty q returns empty lists.
  • New code: SearchRepository (postgres), ProjectHandler.Search behind the WithProjectSearch option, and DTOs.
  • Why users:write and not users:read for finding anyone: the built-in default role (USER) gives every user users:read, so the team limit would apply to nobody.
  • Migration 000098 adds GIN trigram indexes (pg_trgm, installed since 000091) on tasks.title, projects.name, accounts.name and users.username, so ILIKE '%q%' doesn't read the whole table for queries of 3+ characters. The task title index also serves the in-project task search.
  • The route is added to openRouteGroups, next to the other handler-scoped endpoints.
  • docs/architecture/authorization.md describes the scoping.

Web

  • The header search opens a cmdk dialog with Tasks, Projects and People groups.
  • Tasks show the type icon in the project's color (Epic, Story, Bug, …), the key, the title, and project · status.
  • The first result is highlighted, so Enter opens it.
  • A person opens the team page of a project you share. Someone outside your teams (found only by user admins) opens /admin/users.
  • Cmd/Ctrl+K works from anywhere, including text fields, and is listed in the shortcuts help.
    • The keymap's header comment said Mod+K could not be used. In practice a page that calls preventDefault() gets it, and it's the search key users expect, so I updated the comment.
  • New TaskTypeMark component: the type's icon in its color, or a tinted name pill when the type has no icon.
  • Strings added in all 9 locales.
  • CommandDialog (shadcn) rendered its sr-only title outside the dialog, so the closed search left a stray "Search" heading on every page. The title is now inside the dialog, which also labels it.

Screenshots

Mixed task types, dark and light:

Search results in dark theme: purple Epic icons and blue Task icons next to task keys

The same results in light theme

People:

People result for 'adm'

Header:

Header search box with the Cmd K hint

Test plan

  • Postgres tests for SearchRepository:
    • project match and ordering
    • task title and key match
    • deleted tasks and projects skipped
    • per-project scope, including deny-all
    • task type fields
    • people restricted to teams, everyone for a user admin, left or deleted members and agents excluded
  • Handler tests: each kind gets the right project set and task scope; users:write finds everyone while users:read alone does not; key formatting; parameter validation; empty query.
  • Router authorization and route-coverage tests.
  • Web: global-search.test.tsx (grouping, type colors, Enter opens the first result, navigation targets, disabled people) and the keymap tests. Full suite: 1898 passed; Biome and tsc clean.
  • New e2e spec tests/ui/global-search.spec.ts (6 scenarios, real roles on the e2e stack): sprint-scoped member, member without project.members:read, user with no projects, admin, task-key lookup, and Cmd/Ctrl+K → Enter opens the task.
  • Full e2e suite (Chromium): 1419 passed.
    • Fixed here, caused by the header search: the changelog headings spec (stray heading, see above) and two interaction-views specs (their search-button locator now also matched the header button; they find it by name).
    • Still failing, and failing the same way on a master build, so not caused by this PR:
      • docs.spec.ts:640 "User can edit their own comment"
      • interaction-views.spec.ts:1035 "Clearing the filter restores all tasks"
      • management.spec.ts:963 "Toggling a permission off during edit persists after save"
      • timeline.spec.ts:94 "Timeline appears in the sidebar above Product Backlog"
  • Checked by hand on the dev stack: Cmd+K opens the search, and typing uiga-3 then Enter opens the task. EXPLAIN confirms the planner can use the trigram indexes.

🤖 Generated with Claude Code

robertcoroianu and others added 2 commits November 25, 2026 19:38
GET /search?q=&limit= returns matching projects, tasks and people for the
header search. The route is open to any authenticated caller and decides
what it returns in the handler, from the same project set as the workspace
counters:

- projects the caller holds projects:read on;
- tasks they may read in each project (the per-project tasks:read scope),
  matched by title or by task key ("ABC-12", "Paca-AI#12"), with the task's type
  (name, icon, color) so clients can draw it;
- people who are live members of a project whose member list the caller
  may read (project.members:read), i.e. their teams; every user for a
  holder of users:read.

The per-project checks use one AuthorizeMany call. The route is listed in
openRouteGroups next to the other handler-scoped endpoints.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A search box in the header (and Cmd/Ctrl+K, from anywhere) opens a command
dialog that searches projects, tasks and people through GET /search.

- Tasks show their key, project and status, with the task type's icon in
  the project's color (Epic, Story, Bug, ...).
- Typing a task key ("ABC-12") puts that task first; the first result is
  highlighted so Enter opens it.
- A person opens the team page of a project you share; someone outside
  your teams (only found with users:read) opens the admin Users page.
- Mod+K replaces the note in the keymap that called it unusable: a page
  that calls preventDefault() gets it, and it is the expected search key.
- Strings in all 9 locales; the shortcut is listed in the help dialog.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

Workspace admins, and anyone holding the workspace-wide projects:read, get an empty Projects group: the handler lists every project for them and then filters them all out on a per-project project/<id> check.

Approach: sound — one handler-scoped route reusing the existing project-set and per-project task-scope machinery, with row filtering in SQL and a batched AuthorizeMany. The only divergence is that the project filter ignores the collection-level grant the same code path relies on to build the project set.

Reviewed changes

  • GET /search route and handler — added next to the other handler-scoped endpoints in openRouteGroups; ProjectHandler.Search validates q/limit, returns empty lists for an empty query, runs projects/people/tasks concurrently, maps to dto.SearchResponse, and fails closed on authorizer errors.
  • searchAccessFor — one AuthorizeMany for projects:read + project.members:read per project plus platform users:read.
  • SearchRepository — SearchProjects (name/description ILIKE, exact task-key prefix, exact-then-prefix ordering), SearchTasks (title ILIKE plus PRJ-12/#12/12 number match sorted first, per-project scope via projectScopesSQL), SearchPeople (live human members of readable member lists, users:read widens, agents/service accounts and the bot excluded). All patterns escaped with escapeLikePattern and bound as parameters.
  • Scope plumbing and docs — task scope via ListScopes + iam.WithProjectScopes, matching workspace-stats; authorization.md and the route-coverage comment updated; bootstrap wiring added.
  • Web — cmdk dialog in the header with debounced queries, manual first-result highlight, TaskTypeMark, person navigation and disabled state; Mod+K bound in keymap.ts and dispatched ahead of the typing-target guard; new strings in all 9 locales.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

robertcoroianu and others added 4 commits November 25, 2026 20:32
GET /search matches with ILIKE '%…%' on task titles, project names, account
names and usernames, which a B-tree cannot serve. Add GIN trigram indexes
(pg_trgm, installed since 000091) so a query of three or more characters
no longer reads the whole table. The task title index also serves the
in-project task search, which matches the same way.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nage users

The built-in default role (USER) gives every user users:read, so using it
to lift the team limit meant every user found every user. Finding people
outside one's teams now takes users:write (managing users); everyone else
finds only members of projects whose member list they may read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CommandDialog put its sr-only DialogHeader outside DialogContent, so the
title stayed in the page while the dialog was closed: the header search
added a stray "Search" heading to every page (caught by the changelog e2e
spec, which lists the page's h2 headings). Inside the popup, it also
labels the dialog.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
New spec (features/ui/global-search.feature) against real roles:

- a member limited to one sprint finds their project, only that sprint's
  task and only their teammates;
- a member without project.members:read finds tasks but no people;
- a user in no project finds nothing; the admin finds everything;
- a task key ("PRJ-12") puts that task first;
- Cmd/Ctrl+K opens the dialog and Enter opens the highlighted task.

The interaction-views search tests found the view's search button by its
magnifier icon, which now also matches the header search; they find it by
name instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No new issues in the changes since the last review — one minor test-coverage suggestion inline.

Approach: sound — the users:write gate makes the API and web agree on who may find people outside their teams, and the trigram indexes address the ILIKE '%q%' cost without changing query semantics.

Reviewed changes — commits since a0194e2.

  • People scoping switched to users:write — the handler, authorization.md, and the web disabled-state now key off user management, with TestSearch_UsersReadAloneKeepsPeopleToTeams pinning that the default role's users:read keeps people scoped to the caller's teams.
  • Trigram indexes (000098) — GIN pg_trgm indexes on tasks.title, projects.name, accounts.name and users.username so the new ILIKE '%q%' searches stop reading whole tables for 3+ character queries.
  • Command dialog title fix — the sr-only title and description moved inside DialogContent, so a closed dialog no longer leaves a stray heading on the page.
  • End-to-end coverage — new global-search feature/spec covering a sprint-scoped member, a member without project.members:read, a user with no projects, the admin, a task-key lookup and Cmd/Ctrl+K → Enter, plus the backlog search-button locators moved to an accessible name.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

});
});

it("only lets a user admin open someone outside their teams", async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This test passes with the previous users:read gate too: mocks.permissions is left empty in beforeEach, so it only exercises the disabled path and never the permission name this PR switched. Setting mocks.permissions = ["users:read"] and asserting Lois stays disabled, plus a ["users:write"] case that opens /admin/users, would fail on a silent revert to the old gate.

@pikann pikann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thank you for the contribution! 🚀

@pikann
pikann merged commit cad42bc into Paca-AI:master Nov 26, 2026
8 checks passed
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