Skip to content

Fix taxonomy links missing from admin sidebar#93

Merged
ascorbic merged 5 commits into
emdash-cms:mainfrom
eyupcanakman:fix/taxonomy-sidebar-missing
Apr 11, 2026
Merged

Fix taxonomy links missing from admin sidebar#93
ascorbic merged 5 commits into
emdash-cms:mainfrom
eyupcanakman:fix/taxonomy-sidebar-missing

Conversation

@eyupcanakman
Copy link
Copy Markdown
Contributor

@eyupcanakman eyupcanakman commented Apr 2, 2026

What does this PR do?

Closes #68

The admin sidebar hardcoded only "Categories" and "Tags" links. Any taxonomy created at runtime never showed up, so there was no way to manage its terms from the UI.

The fix loads taxonomy definitions from the database into the manifest and renders sidebar links from that list instead of a static array.

Type of change

  • Bug fix
  • Feature (requires approved Discussion)
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm --silent lint:json | jq '.diagnostics | length' returns 0
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/...

AI-generated code disclosure

  • This PR includes AI-generated code

Screenshots / test output

N/A

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 2, 2026

🦋 Changeset detected

Latest commit: 90fc110

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
emdash Patch
@emdash-cms/admin Patch
@emdash-cms/cloudflare Patch
@emdash-cms/plugin-ai-moderation Patch
@emdash-cms/plugin-atproto Patch
@emdash-cms/plugin-audit-log Patch
@emdash-cms/plugin-color Patch
@emdash-cms/plugin-embeds Patch
@emdash-cms/plugin-forms Patch
@emdash-cms/plugin-webhook-notifier Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

Copilot AI review requested due to automatic review settings April 5, 2026 07:39
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 5, 2026

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@93

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@93

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@93

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@93

emdash

npm i https://pkg.pr.new/emdash@93

create-emdash

npm i https://pkg.pr.new/create-emdash@93

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@93

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@93

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@93

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@93

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@93

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@93

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@93

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@93

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@93

commit: 90fc110

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR fixes missing runtime-created taxonomy links in the admin sidebar by sourcing taxonomy definitions dynamically and exposing them via the manifest.

Changes:

  • Load taxonomy definitions from the DB at runtime and include them in the manifest (and hash).
  • Extend manifest types in core and admin to include taxonomy definitions.
  • Render admin sidebar taxonomy links from the manifest instead of hardcoding Categories/Tags.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/core/src/emdash-runtime.ts Loads taxonomy definitions from DB, includes them in manifest + hash.
packages/core/src/astro/types.ts Adds taxonomies to the core EmDashManifest type.
packages/core/src/astro/routes/api/manifest.ts Ensures the “default” manifest shape includes taxonomies: [].
packages/admin/src/lib/api/client.ts Extends admin-side manifest typing to include taxonomies.
packages/admin/src/components/Sidebar.tsx Builds taxonomy sidebar links from manifest-provided taxonomies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/emdash-runtime.ts Outdated
Comment on lines +1301 to +1307
const rows = await this.db.selectFrom("_emdash_taxonomy_defs").selectAll().execute();
manifestTaxonomies = rows.map((row) => ({
name: row.name,
label: row.label,
labelSingular: row.label_singular ?? undefined,
hierarchical: row.hierarchical === 1,
collections: row.collections ? JSON.parse(row.collections) : [],
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

The manifest hash can become non-deterministic because selectAll().execute() has no explicit ordering, so DB row order may vary between runs (and JSON.stringify(manifestTaxonomies) will then vary). This can cause unnecessary cache invalidations. Make the taxonomy query ordering stable (e.g., orderBy('name')) and/or sort manifestTaxonomies before hashing (and consider sorting nested collections too if ordering isn’t guaranteed).

Suggested change
const rows = await this.db.selectFrom("_emdash_taxonomy_defs").selectAll().execute();
manifestTaxonomies = rows.map((row) => ({
name: row.name,
label: row.label,
labelSingular: row.label_singular ?? undefined,
hierarchical: row.hierarchical === 1,
collections: row.collections ? JSON.parse(row.collections) : [],
const rows = await this.db
.selectFrom("_emdash_taxonomy_defs")
.selectAll()
.orderBy("name")
.execute();
manifestTaxonomies = rows.map((row) => ({
name: row.name,
label: row.label,
labelSingular: row.label_singular ?? undefined,
hierarchical: row.hierarchical === 1,
collections: row.collections
? (JSON.parse(row.collections) as string[]).sort((a, b) => a.localeCompare(b))
: [],

Copilot uses AI. Check for mistakes.
Comment on lines +1315 to +1317
JSON.stringify(manifestCollections) +
JSON.stringify(manifestPlugins) +
JSON.stringify(manifestTaxonomies),
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

The manifest hash can become non-deterministic because selectAll().execute() has no explicit ordering, so DB row order may vary between runs (and JSON.stringify(manifestTaxonomies) will then vary). This can cause unnecessary cache invalidations. Make the taxonomy query ordering stable (e.g., orderBy('name')) and/or sort manifestTaxonomies before hashing (and consider sorting nested collections too if ordering isn’t guaranteed).

Copilot uses AI. Check for mistakes.
Comment on lines +1302 to +1308
manifestTaxonomies = rows.map((row) => ({
name: row.name,
label: row.label,
labelSingular: row.label_singular ?? undefined,
hierarchical: row.hierarchical === 1,
collections: row.collections ? JSON.parse(row.collections) : [],
}));
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

JSON.parse(row.collections) can throw for a single malformed row, which will currently drop all taxonomies due to the outer try/catch. Consider parsing per-row (catching/handling errors locally and defaulting that row’s collections to []), so one bad entry doesn’t remove the entire taxonomy list from the manifest.

Suggested change
manifestTaxonomies = rows.map((row) => ({
name: row.name,
label: row.label,
labelSingular: row.label_singular ?? undefined,
hierarchical: row.hierarchical === 1,
collections: row.collections ? JSON.parse(row.collections) : [],
}));
manifestTaxonomies = rows.map((row) => {
let collections: string[] = [];
if (row.collections) {
try {
collections = JSON.parse(row.collections);
} catch (error) {
console.debug(
`EmDash: Could not parse collections for taxonomy definition "${row.name}":`,
error,
);
}
}
return {
name: row.name,
label: row.label,
labelSingular: row.label_singular ?? undefined,
hierarchical: row.hierarchical === 1,
collections,
};
});

Copilot uses AI. Check for mistakes.
Comment thread packages/admin/src/lib/api/client.ts Outdated
Comment on lines +136 to +142
taxonomies?: Array<{
name: string;
label: string;
labelSingular?: string;
hierarchical: boolean;
collections: string[];
}>;
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

In core, EmDashManifest.taxonomies is required, and the API default manifest also always returns taxonomies: []. On the admin side it’s typed as optional (taxonomies?), which makes consumers handle an unnecessary undefined case and can hide contract mismatches. Consider making taxonomies required in AdminManifest (and in SidebarNavProps, where it’s also optional) and relying on the backend to provide an empty array when none exist.

Copilot uses AI. Check for mistakes.
@ascorbic
Copy link
Copy Markdown
Collaborator

@eyupcanakman this would be great to get in. Could you address the revew comments?

- Order taxonomy query by name for deterministic manifest hash
- Make taxonomies required in AdminManifest and SidebarNavProps
- Add changeset for emdash and @emdash-cms/admin
- Add tests for seeded and custom taxonomy loading from DB
- Add taxonomies field to AdminManifest test fixtures
@eyupcanakman eyupcanakman force-pushed the fix/taxonomy-sidebar-missing branch from e34420c to bb3d72d Compare April 11, 2026 08:55
@eyupcanakman
Copy link
Copy Markdown
Contributor Author

Addressed the review comments. Added orderBy, sorted collections for stable hashing, and made taxonomies required. Skipped the per-row try/catch since our own code writes that column.

Copy link
Copy Markdown
Collaborator

@ascorbic ascorbic left a comment

Choose a reason for hiding this comment

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

Thanks!

@ascorbic ascorbic merged commit a5e0603 into emdash-cms:main Apr 11, 2026
26 checks passed
@emdashbot emdashbot Bot mentioned this pull request Apr 11, 2026
@emdashbot emdashbot Bot mentioned this pull request Apr 12, 2026
fmhall pushed a commit to fmhall/emdash that referenced this pull request Apr 13, 2026
* Fix taxonomy links missing from admin sidebar

* Address review feedback and add changeset

- Order taxonomy query by name for deterministic manifest hash
- Make taxonomies required in AdminManifest and SidebarNavProps
- Add changeset for emdash and @emdash-cms/admin

* Add taxonomy manifest tests and fix test fixtures

- Add tests for seeded and custom taxonomy loading from DB
- Add taxonomies field to AdminManifest test fixtures

* Sort taxonomy collections for deterministic manifest hash

* style: format

---------

Co-authored-by: emdashbot[bot] <emdashbot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot add/edit new options for newly created Taxonomy

3 participants