Skip to content

Create views on the views page, and stop workspace views landing in a random team - #133

Merged
imshashank merged 5 commits into
mainfrom
views/create-and-navigate
Aug 7, 2026
Merged

imshashank merged 5 commits into
mainfrom
views/create-and-navigate

Conversation

@imshashank

@imshashank imshashank commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Three problems reported from /views: no way to create a view, "All issues" landing in an arbitrary team, and a built-in set that read oddly. All three are fixed here.

1. A workspace wide view no longer lands in a random team

views-page.tsx resolved a view's team with

workspace.teams.find((entry) => entry.id === filterTeamId) ?? workspace.teams[0] ?? null

A built-in such as "All issues" carries no filter.teamId, so find() missed and the fallback sent you to whichever team sorted first. The href builder is now a pure, tested function (features/views/view-href.ts) that routes to a team only when the view names one that still exists, and sends everything else to /views/<id>.

/views/<id> is a new route. It loads the view server side, hydrates the views query, and renders the issues the view describes across the whole workspace, honouring the view's own filter, ordering, grouping, layout and display options. A project scoped view narrows to that project; the scope is shown in the header. The page reuses the same FilterBar and DisplayMenu as the team list, so tweaking and saving behaves exactly as it does there.

useAllIssues (previously unused) now takes an optional scope, so one hook serves the workspace, a team or a project.

2. A real "New view" affordance

A primary New view button sits in the page header, and Alt+V opens the same dialog so the old keystroke still means what it meant. The dialog names the view, picks its scope (workspace, a team, or a project), its layout, and then reuses the existing filter builder, grouping, ordering and display property controls rather than reimplementing them. Visibility and sharing go through the existing createView service; nothing new was added server side, and the private-view scoping introduced recently is untouched.

3. The built-in set

Two additions, chosen because a new workspace has nothing saved and both answer a question people ask on day one:

  • Unassigned, open issues nobody owns
  • Overdue, open issues past their due date, ordered by due date

Both hide finished work so they stay actionable. Every built-in now carries a one-line description, shown in the list, so a built-in row is legible without the Owner and Visibility columns (which are hidden on narrow screens).

The Visibility column said "Only me" for built-ins, which was never true of a view every member gets. It now says "Everyone" for built-ins and keeps the stored label for saved views.

4. A team view is now a real thing, not a label on a workspace view

Greptile caught a P1 on the first round and it was right. The dialog offered "My teams", but a
saved view could only record shared: true or false, so choosing it published the view to the
whole workspace: listViews, the realtime scopes and the reconnect backfill all authorised any
non-private view at organization scope. The same option was already live in the older
save-view-dialog, so this was not new to this branch.

The model can express it now. view carries visibility (private, team, workspace) and
team_id, the team a team view belongs to. shared stays and is derived from visibility in one
place so the two cannot drift, but nothing authorises on it any more.

  • viewScopes publishes a team view to team:<id> and the owner, never to the org.
  • listViews and the /api/ws catch up backfill share one viewReadFilter: mine, or workspace
    wide, or a team view whose team is one of principal.teamIds.
  • getView and setViewFavorite go through canReadView in packages/shared/src/policy.
  • Creating or updating a team view asserts the team exists here and that the author is on it, so
    nobody publishes into a team they are not on, and team with no team is rejected rather than
    quietly widened.
  • Narrowing an audience deletes on exactly the scopes that lost access, so moving a view from team
    A to team B tells team A it is gone. Widening to the workspace deletes nothing.

In the dialogs the option is bound to the team the view covers and reads "Everyone on Engineering".
It only appears when a team is in scope, and if the scope moves off that team the audience falls
back to private, never to the workspace.

Schema change, applied by hand before this ships

packages/db/catchup/view-team-visibility.sql adds the two columns, the foreign key and the index,
and backfills them from shared and the stored filter. Apply it to production before this code
ships
, otherwise every saved view query fails on the missing column. It is idempotent, and it was
run twice against a database seeded with legacy rows to prove it. A stored team visibility naming
a team that no longer exists, or a team in another workspace, lands on private rather than
workspace: the narrower reading is the safe one.

Page layout

The page had a "BUILT IN" header with the saved-views empty state floating in blank space far below it. Each section now carries a one-line description, and the empty state for your own views sits inside that section with its own button.

Tests

Every test below was watched fail first, then the production code was deliberately broken to confirm it bites.

Test Mutation that turned it red
view-href.test.ts, four cases under "a view that covers the whole workspace" restore ?? teams[0] in viewHref
views-page.test.tsx "sends a workspace wide built-in to a workspace destination" same
views-page.test.tsx "does not tell people a built-in view is visible only to them" drop the view.virtual branch from visibilityLabel
views-page.test.tsx "creates a view from the dialog and lists it straight away" make submit() return before create.mutate
views-page.test.tsx "opens the same dialog from Alt+V" rebind the hotkey to alt+shift+n
create-view-dialog.test.tsx filter, layout, grouping and visibility cases post defaultViewConfig('list') instead of the dialog's own config
create-view-dialog.test.tsx scope cases make parseViewScope always return the workspace scope
saved-view-page.test.tsx "asks the server for exactly the issues the view describes" pass an empty filter and manual ordering to useAllIssues
saved-view-page.test.tsx team and project scope cases make scopeRecord return {}
saved-view-page.test.tsx "honours the display options it stored" force showCompleted: 'all'
view-service.test.ts "keeps only issues whose due date has passed" change the overdue filter to due is set
view-service.test.ts "publishes a team view to that team alone", "never carries the filter of a team view in a delta another team receives", "keeps every later delta of a team view off the workspace scope" restore the old viewScopes, which returned the org scope for anything shared
view-service.test.ts "lists a team view for the team and hides it from everyone else" restore or(ownerId = me, shared = 'true') in listViews
view-service.test.ts "refuses to open a team view from another team" restore the old view.shared !== 'true' check in loadReadableView
view-service.test.ts "refuses to publish a view to a team the author is not on", "refuses a team view that names no team" drop assertAudienceReachable from createView
view-service.test.ts "tells the workspace a view is gone when its owner narrows it to one team", "drops the old team when a view moves to another one" restore the old unshare rule, which only ever deleted on the org scope
view-service.test.ts "takes nothing away when a team view opens up to the whole workspace" drop the workspace guard from droppedScopes
backfill.test.ts "never replays a team view to somebody on another team" restore or(ownerId = me, shared = 'true') in the view loader
backfill.test.ts "still replays a workspace view to everyone" point the workspace clause of viewReadFilter at a visibility nothing uses
create-view-dialog.test.tsx "offers a team audience only once the view covers a team" stop filtering the team option out of visibilityChoices
create-view-dialog.test.tsx "keeps a team view on the team that owns it" post visibility: 'workspace' instead of the chosen audience
create-view-dialog.test.tsx "never leaves a team audience on a view that stopped covering a team" make allowedVisibility return whatever was chosen
filter-bar.test.tsx "names the team a view on a team page would go to", "offers no team audience where no team is in scope" pass a team to the save dialog even when the page has none
views-page.test.tsx "names the team a team view is shared with" drop the team branch from visibilityLabel

The team scoping tests build two teams and three people against real Postgres, then assert what each of them can list, open, favourite and receive, so the invariant is proven against the database rather than against a mock.

The saved view page tests drive the real query layer through a stubbed fetch, so the request the page builds is asserted rather than assumed. The core tests run the built-in filters through listIssues against Postgres, so "the built-ins work" is proven end to end rather than by inspecting a literal.

bun run verify is green, and bun run build in apps/web registers /views/[id] as a dynamic node route.

Greptile Summary

This PR adds workspace-wide saved-view pages and view creation while introducing explicit private, team, and workspace visibility throughout persistence, policy checks, listing, and realtime delivery.

  • Routes workspace views without an existing team to /views/<id> and renders their stored filters, scope, layout, grouping, ordering, and display settings.
  • Adds view creation from the Views page and updates built-in views and visibility labels.
  • Adds persisted team visibility, shared read-policy enforcement, audience-aware realtime scopes and backfill filtering, plus migration and regression coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/core/src/work/view-service.ts Centralizes view audience persistence, read filtering, policy enforcement, realtime scopes, and deletion notifications when access narrows.
packages/shared/src/policy/index.ts Adds organization-aware private, team, and workspace read authorization for saved views.
packages/core/src/realtime/backfill.ts Applies the shared view-read filter and audience scopes during reconnect catch-up.
packages/db/catchup/view-team-visibility.sql Idempotently adds and safely backfills explicit visibility and team ownership for legacy view rows.
apps/web/src/features/views/create-view-dialog.tsx Adds view creation with configurable scope, layout, filters, grouping, ordering, display properties, and audience.
apps/web/src/features/views/saved-view-page.tsx Renders saved workspace, team, or project views using their persisted issue-query and display configuration.
apps/web/src/features/views/view-href.ts Routes only valid team-scoped views to team pages and sends workspace or orphaned-team views to the saved-view route.
apps/web/tests/features/views/create-view-dialog.test.tsx Uses the required application alias and covers scope, audience, configuration, and submission behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  UI[Create or update view] --> V[Validate visibility and team]
  V --> DB[(Persist visibility and team_id)]
  DB --> P{Audience}
  P -->|Private| U[Owner scope]
  P -->|Team| T[Team and owner scopes]
  P -->|Workspace| O[Organization and owner scopes]
  DB --> R[Shared read policy]
  R --> L[List and direct reads]
  R --> B[Realtime catch-up]
Loading

Reviews (3): Last reviewed commit: "fix(views): decode the route segment, so..." | Re-trigger Greptile

A new workspace now starts with two triage views alongside the four it
already had: Unassigned finds open issues nobody owns, Overdue finds
open issues whose due date has passed, ordered by due date. Both hide
finished work so they stay actionable. Every built-in also carries a
one-line description now, so the views list can say what each one does.

The named date vocabulary moves to @orbit/shared so the predicate
compiler and the filter UI share one list instead of two copies.
A view with no team filter used to fall through find() and land on
workspace.teams[0], so clicking All issues dropped you into whichever
team sorted first. viewHref now only routes to a team when the view
names one that still exists, and sends everything else to /views/<id>.

That route is new. It reads the view server side, hydrates the views
query, and renders the issues the view describes across the whole
workspace, honouring its filter, ordering, grouping, layout and display
options. A view scoped to a project narrows to that project, and the
scope shows in the header so nobody has to guess what they are looking
at. The saved view page reuses the same filter bar and display menu as
the team list, so tweaking and saving works exactly as it does there.

useAllIssues takes an optional scope so the same hook can serve the
whole workspace, one team or one project.
The page had no way to make a view. The empty state pointed at Alt+V on
another screen, and it sat in a blank area far below the built in
section header. Both are fixed here.

A New view button in the page header opens a dialog that names the view,
picks its scope (the workspace, a team or a project), its layout, and
then reuses the existing filter builder and display menu for the
filters, grouping, ordering and display properties. Alt+V opens the same
dialog, so the old keystroke still means what it meant.

The sections now carry a line each saying what they hold, and the empty
state for your own views sits inside that section with its own button
rather than floating below everything. Built in rows say their
visibility is Everyone instead of Only me, which was never true of a
view every member gets, and each one describes what it collects.
@vercel

vercel Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
orbit Ready Ready Preview Aug 7, 2026 8:43am

Request Review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@imshashank, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 32 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 23307686-fdfc-42c0-8e29-0d349382f1b3

📥 Commits

Reviewing files that changed from the base of the PR and between f957388 and 56258b3.

📒 Files selected for processing (30)
  • apps/web/src/app/(app)/views/[id]/loading.tsx
  • apps/web/src/app/(app)/views/[id]/page.tsx
  • apps/web/src/features/filters/filter-bar.tsx
  • apps/web/src/features/filters/filter-fields.tsx
  • apps/web/src/features/filters/save-view-dialog.tsx
  • apps/web/src/features/filters/view-visibility.ts
  • apps/web/src/features/views/create-view-dialog.tsx
  • apps/web/src/features/views/saved-view-page.tsx
  • apps/web/src/features/views/view-href.ts
  • apps/web/src/features/views/views-page.tsx
  • apps/web/src/features/views/views-skeleton.tsx
  • apps/web/src/lib/query/issue-search.ts
  • apps/web/src/lib/query/use-issues.ts
  • apps/web/tests/app/views/view-id-round-trip.test.ts
  • apps/web/tests/features/filters/filter-bar.test.tsx
  • apps/web/tests/features/views/create-view-dialog.test.tsx
  • apps/web/tests/features/views/saved-view-page.test.tsx
  • apps/web/tests/features/views/view-href.test.ts
  • apps/web/tests/features/views/views-page.test.tsx
  • apps/web/tests/features/views/views-skeleton.test.tsx
  • packages/core/src/realtime/backfill.ts
  • packages/core/src/work/issue-predicates.ts
  • packages/core/src/work/view-service.ts
  • packages/core/tests/realtime/backfill.test.ts
  • packages/core/tests/work/view-service.test.ts
  • packages/db/catchup/view-team-visibility.sql
  • packages/db/src/schema/work.ts
  • packages/shared/src/filters/index.ts
  • packages/shared/src/policy/index.ts
  • packages/shared/tests/filters/filters.test.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

A saved view could only record shared true or false, so the "My teams"
option in both view dialogs published the view at organization scope:
listViews, the realtime scopes and the reconnect backfill all authorised
any non private view for the whole workspace.

The view table now carries visibility and team_id. viewScopes publishes a
team view to that team alone, listViews and the catch up backfill share
one viewReadFilter, and getView and setViewFavorite go through canReadView
in the shared policy. Creating or updating a team view asserts the team is
in this workspace and that the author belongs to it. Narrowing an audience
deletes on exactly the scopes that lost access.

Both dialogs bind the team option to the team the view covers, name it,
and fall back to private when the scope moves off that team.

packages/db/catchup/view-team-visibility.sql must be applied to the target
database before this ships.
@github-actions github-actions Bot added tests Test coverage and test infrastructure area: web The Next.js app and its UI area: database Schema, migrations, queries, seed area: policy Roles, permissions and authorization labels Aug 7, 2026
savedViewPath encodes the id, so virtual:all becomes /views/virtual%3Aall,
and Next hands the page component the raw segment while giving
generateMetadata the decoded one. The lookup therefore missed on every
built in view and all six rendered "No such view", while the tab title
read the right name from the decoded copy. Dropping the encoding does not
help: Next re-encodes a colon in a path segment either way, so the fix
belongs on the read side.

The suite missed it because saved-view-page.test.tsx renders the
component directly with a literal id, and view-href.test.ts asserts only
the encoding. Nothing crossed the route boundary. The new test asserts
the round trip, so encoding and decoding can no longer disagree, and it
covers a segment that is not valid percent encoding.
@imshashank
imshashank merged commit d3bda0c into main Aug 7, 2026
11 checks passed
@imshashank
imshashank deleted the views/create-and-navigate branch August 7, 2026 09:10
imshashank added a commit that referenced this pull request Aug 7, 2026
WorkspaceData gained a required role on this branch while #133 added
these three fixtures on main. Neither side is wrong on its own; the
merge is where they meet.
imshashank added a commit that referenced this pull request Aug 7, 2026
* fix(issues): announce the children a deleted parent frees

deleteIssue already re-parented sub issues to the top level, but it did it
silently: no sync id bump and no action, so every other tab kept a cached
child pointing at a row that no longer exists. Each freed child now gets
the transaction's sync id and its own update action alongside the delete.

The DELETE route resolves the issue first, so it accepts an identifier
like the GET and PATCH beside it, validates the path with a shared Zod
schema, and answers with the id and identifier that went. The MCP tool
now parses its issue reference with the same schema.

* feat(issues): remove a deleted issue from every cache, here and in other tabs

useDeleteIssues replaces the unused single issue hook. It snapshots every
issues query, drops the rows optimistically, and restores the snapshot
verbatim when the server refuses. A bulk delete that fails half way keeps
the issues that really went rather than resurrecting them.

The delta bridge dropped a deleted row from lists but left the detail
cache alone, so a tab sitting on the deleted issue kept painting it. It
now forgets that detail and trims the row out of any parent's sub issue
list. Deleting a parent also clears parentId on cached children so
nothing points at a row that is gone.

* feat(keyboard): let a surface hotkey stand down while a layer owns the key

ownsKeyboardLayer reports whether the focused element sits inside an open
menu, dialog or listbox, so a destructive surface shortcut can refuse to
fire while one of those is holding the keyboard.

revealOnCardHover is a named group variant of revealOnHover, for a
control that must appear on its own card rather than on every card in
the column that wraps it.

* feat(issues): delete an issue from every surface that shows one

Deleting was reachable from the core service, the REST route and the MCP
tool, and from nowhere in the product. It is now on the row overflow menu
in every list, the board card menu, the issue detail header, the peek,
the multi select bar, and mod+shift+backspace.

Every path confirms first through the shared dialog. A single delete
names the issue by identifier and title, a bulk delete names the count,
and the copy says the loss is permanent instead of leaving people to
guess. The shortcut stands down while a menu or the peek holds the
keyboard, and it is listed in the shortcuts sheet.

The affordance reads the same policy the server enforces, through
permissionsFor, so a contributor or guest never sees it and is still
refused if they reach the endpoint another way.

* refactor(issues): read the delete permission through one optional chain

Biome wanted an optional chain at each site that asked whether deletion
is both provided and allowed. The route test also resets the database
once rather than before every case, which keeps a truncate off the
critical path of five tests that only need their own workspace.

* fix(issues): stop a tab painting an issue somebody else deleted

Both purge paths used removeQueries, which empties the cache entry but
leaves a mounted observer holding its last result, so a tab sitting on
the deleted issue kept rendering it in full, interactive, and never
refetched. Only a manual reload showed it was gone. resetQueries clears
the observer too.

The two tests that claimed to cover this called setQueryData with no
observer mounted, so getQueryData returning undefined passed whether the
feature worked or not. The new test mounts a real useQuery, and its
second case pins the distinction directly: after removeQueries the
component still paints the old row, which is the bug.

* refactor(web): keep hover state in the shared interaction tokens

The bulk edit bar hand rolled hover:text-danger at the call site, which
puts a hover colour change outside the one module the project audits for
motion and interaction. Add dangerAction and dangerMenuAction there and
spend them instead.

Every transition token now also carries motion-reduce:transition-none.
The global reduced motion block in globals.css already collapses every
transition-duration to 0.01ms with !important, so no viewer was actually
receiving the fade, but the tokens are the auditable set and every other
motion site in the app states the guard for itself.

The new test walks the module's exports rather than restating a literal,
so a token added later without the guard, off the duration scale, or
transitioning a property that reflows fails by name.

* fix(issues): finish a delete only once the server has agreed

confirm called onDeleted immediately after remove.mutate, which returns
before the request does. A refused delete still navigated the detail page
away, still closed the peek, and still cleared the list selection, so the
person was told work was destroyed that in fact still existed, or lost
their place for nothing. Moving the callback into the mutation's success
path also leaves a partly failed bulk delete with its selection intact,
which is what the surviving issues need.

The optimistic cache already rolled back on error, so this is purely the
callback ordering.

The tests make the server refuse and assert the caller stayed put: the
detail does not navigate, the peek does not close, the selection bar
still counts two. They wait on the mutation reaching an error state on
the client the test owns, not on the error toast, because other suites
leave @/components/ui/toast.tsx mocked process wide and that made the
same assertions pass alone and fail in a full run.

* fix(issues): let the delete shortcut stand down when it cannot act

The detail surface bound the shortcut without asking whether another
keyboard layer owned the key, so a menu or dialog holding focus could
still raise the delete confirmation behind it. The list already checked
ownsKeyboardLayer; the detail now matches it.

The list binding also stayed registered when it had nothing to delete.
HotkeyProvider calls preventDefault on a match before it runs the
handler, so an empty list swallowed the keystroke to reach a handler
that could only return. Requiring a target in enabled hands the key back
and drops the entry from the shortcuts sheet while the action is out of
reach, which is how the peek already gates the same binding.

* test(web): import through the @ alias in the tests this branch adds

CLAUDE.md asks for @/ inside apps/web, and the new files reached into
../../../src instead. mock.module keys on the resolved path, so the
alias intercepts the relative import a component makes of its own
neighbour just as the relative specifier did.

* test(views): give the views workspace fixtures the role they now need

WorkspaceData gained a required role on this branch while #133 added
these three fixtures on main. Neither side is wrong on its own; the
merge is where they meet.

This branch was successfully deployed

1 active deployment
Preview — 56258b38 Deployed Aug 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: database Schema, migrations, queries, seed area: policy Roles, permissions and authorization area: web The Next.js app and its UI tests Test coverage and test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant