Skip to content

feat(base): open a saved view by default via settings.defaultViewSlug - #93

Closed
nicklaunches wants to merge 1 commit into
busabase:mainfrom
nicklaunches:feat/base-default-view
Closed

nicklaunches wants to merge 1 commit into
busabase:mainfrom
nicklaunches:feat/base-default-view

Conversation

@nicklaunches

Copy link
Copy Markdown

What changed

Closes #92

A Base that is really a kanban board (a Tasks base with a Board view) had to be reached through /base/<slug>/board every time: the sidebar entry, breadcrumbs and search results all land on the bare route, and that route always opened the unsaved all-records grid.

This adds a per-Base default view, stored as the node setting defaultViewSlug, as proposed in the issue:

  • nodeSettingsSchema (and the NodeSettings, NodeVO.settings and DB column types) gain defaultViewSlug: z.string().nullish(). The schema stays a strictObject.
  • PATCH /nodes/{nodeId}/settings (and therefore the nodes_update_settings MCP tool and the CLI command, both generated from the contract) accept the key. A non-null slug is validated on write: the node must be a Base and the slug must name one of its active views, otherwise the PATCH is a 400 / 404 instead of a silently ignored setting. The route's description now lists both keys.
  • Dashboard: when the route is the bare /base/<slug> and the Base node's settings name an active view, the dashboard replaces the location with /base/<slug>/<defaultViewSlug>. The URL stays canonical and the pagination scope logic is untouched. An explicit childId always wins, so deep links keep working.
  • The view switcher's "All" tab now links to /base/<slug>/all. all is a reserved child id that resolves to the grid and is never redirected, so the all-records grid stays reachable when a default view is set. It has its own route entry ahead of /base/:slug/:viewId.
  • Base settings dialog (NodeSettingsDialog, General tab, same place as the AirApp engine picker): a "Default view" select with "All records" plus the Base's active views. Saved through the existing nodes.updateSettings mutation; null clears the key. Labels added to every locale.
  • Merging a view_delete clears the Base's defaultViewSlug when it named the archived view. Restoring the view does not bring the setting back.

Validation

  • pnpm typecheck (busabase app) and pnpm --filter busabase-core typecheck: clean.
  • pnpm lint (busabase app) plus pnpm exec biome check --write over every changed file: clean.
  • pnpm test (busabase app).
  • pnpm --filter busabase-core exec vitest run tests/node-default-view-setting.test.ts src/domains/dashboard/helpers/default-view.test.ts: 10 new tests. The PGLite test covers the schema accepting the key and still rejecting unknown ones, storing a valid slug, clearing it when that view is deleted, leaving it alone when another view is deleted, rejecting a slug that names no active view, and rejecting the key on a non-Base node.
  • pnpm --filter busabase-core exec vitest run src/domains/dashboard tests/base-lifecycle.test.ts tests/openapi-record-get-routes.test.ts tests/anonymous-allowlist.test.ts tests/node-metadata-update.test.ts: all passing.
  • Not run: the Playwright e2e suite. view-control-toolbar.spec.ts opens /base/blog, which has no default view, so its expectations are unchanged.

Screenshots

Not captured: the only visual addition is a labelled select in the existing Base settings dialog, between the description field and the submit buttons.

Checklist

  • The change is focused and does not include unrelated refactors.
  • Tests cover new or changed behavior.
  • Typecheck and lint pass for the affected packages.
  • Documentation is updated when user-facing behavior changes.
  • No secrets, local data, or generated build output are included.

🤖 Generated with Claude Code

A Base that is really a kanban board had to be reached through
/base/<slug>/<view> every time: the sidebar, breadcrumbs and search all
land on the bare route, which always opened the all-records grid.

Add `defaultViewSlug` to the closed node settings schema. The bare
/base/<slug> route now replaces itself with /base/<slug>/<defaultViewSlug>
when the Base node names an active view, so the URL stays canonical and
the pagination scope keeps keying off childId. An explicit childId still
wins. The view switcher's "All" tab links to /base/<slug>/all, a reserved
child id that is never redirected, so the grid stays reachable.

The Base settings dialog gets a "Default view" select (All records plus
the Base's active views). PATCH /nodes/{id}/settings validates the slug
against the Base's active views, and merging a view delete clears a
default that named it.

Closes busabase#92

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@mr-kelly

Copy link
Copy Markdown
Contributor

Hi @nicklaunches, thank you for this. The issue was clearly written and the PR is careful work: validation on write, cleanup when a view is deleted, tests, and labels for every locale. We ran it locally and it does what it says. Set Board as the default and the Base opens on the board, the All tab still gets you back to every record, and deep links to other views keep working.

While reviewing it we talked through how we want views to work in general, and we'd like to go a slightly different way than a separate setting:

  • Every Base gets a real grid view showing all records, instead of the built-in "All" tab. Existing Bases get one added automatically.
  • Views can be reordered by dragging, and the leftmost view is the one a Base opens on. Making Board the default is just dragging it to the front.
  • A Base always keeps at least one view, so the last one can't be deleted.

This also removes the need for a reserved /all route. We found it hides existing views whose slug is all (the Stock Watchlist demo Base has one), so a view named "All" could no longer be opened from its tab.

The part we'd keep from your PR is the redirect from the bare /base/<slug> route to a view. It will point at the first view instead of a setting.

Because the approach changes quite a bit, we won't merge this PR as it is. We'll build the new version on our side, reuse your redirect, and credit you as a co-author. We'll link it here when it lands. Thanks again for pushing on this. It's a real gap and your issue made it clear.

@nicklaunches

Copy link
Copy Markdown
Author

Hi @mr-kelly,

Thanks a lot for reply. Please let me know once its there. Really like your product so far and hope pushing more feedback

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.

Base: let a saved view open by default instead of the all-records grid

2 participants