This walkthrough adds a completed-item summary and status badge to the desktop app’s Overview screen, then documents the badge statically on the Astro site. It is a hands-on tutorial to implement on a feature branch: the itemStatus recipe, ItemStatus component, GetItemSummary method, and summary query below are additions you will write, not APIs already shipped by the starter.
Complete Getting started first. Because the summary computes counts from the existing SQLite items table, no database migration is needed. Keep existing public component APIs, token values, theme behavior, and third-party license notices intact.
Using a renamed app? After running pnpm run setup, your Go module path in apps/desktop/go.mod is github.com/<OWNER>/<REPO>/apps/desktop instead of the template default. Whenever you add a Go import for an internal package or a new generated Wails binding import in apps/desktop/frontend/src/host/native.ts (../../bindings/<go-module-path>/internal/...), substitute your actual module path from apps/desktop/go.mod. Do not copy template-specific module paths into a renamed app.
Finished example
The completed Overview uses browser preview with two completed items out of three. Its data is session-only, and native actions are unavailable.

Overview — light theme.

Overview — dark theme.
The Astro page added in step 7 renders the same badge as a static specimen with an example count.

Static Astro specimen — light theme.

Static Astro specimen — dark theme.
1. Define a semantic role and foundation recipe
Start in the shared design system so both React and Astro get the exact same light/dark colors and badge geometry.
In packages/design-system/src/foundations.ts, add two semantic color tokens inside the existing foundations object. Reference existing semantic tokens rather than raw hex values:
'colors.status.complete': {
css: '--color-status-complete',
value: '{colors.accent.dark}',
dark: '{colors.accent.light}',
},
'colors.status.pending': {
css: '--color-status-pending',
value: '{colors.text.secondary}',
},
Panda’s design system builder converts these entries into CSS variables and semantic tokens: tokens with a dark field switch automatically on data-theme="dark", while single-value aliases inherit the light/dark behavior of the token they reference.
Next, add a framework-independent recipe inside recipes in packages/design-system/src/recipes.ts (before the existing satisfies clause):
itemStatus: {
className: 'item-status',
base: {
display: 'inline-flex',
maxWidth: '100%',
padding: '{spacing.fixed.1} {spacing.fixed.2}',
border: '1px solid currentColor',
borderRadius: 'square',
textStyle: 'label',
overflowWrap: 'anywhere',
},
variants: {
state: {
complete: { color: 'status.complete' },
pending: { color: 'status.pending' },
},
},
defaultVariants: { state: 'pending' },
},
A status badge is non-interactive text, so it needs no focus ring or motion. Rebuild shared package exports before importing the new recipe:
pnpm run design-system:build
2. Export a shared React component
Wrap the Wailspring recipe in @wailspring/ui so React apps can render it as a typed component while keeping it host-agnostic.
Create packages/ui/src/components/item-status.tsx:
import type { ComponentPropsWithoutRef } from 'react';
import { itemStatus } from '@wailspring/design-system/recipes';
export interface ItemStatusProps extends ComponentPropsWithoutRef<'span'> {
state?: 'complete' | 'pending';
}
export function ItemStatus({ state = 'pending', className, ...props }: ItemStatusProps) {
return <span {...props} className={[itemStatus({ state }), className].filter(Boolean).join(' ')} />;
}
Re-export it from packages/ui/src/components/index.ts:
export { ItemStatus, type ItemStatusProps } from './item-status.js';
Because the package’s root barrel re-exports ./components/index.js and the wildcard export exposes ./components/*, consumers can now import ItemStatus from either @wailspring/ui or @wailspring/ui/components/item-status. Notice what this component does not know about: Go bindings, TanStack Query, or i18next. It renders the translated children passed by the host app, while its styling stays in @wailspring/design-system so Astro can reuse the same recipe. Run pnpm run design-system:build again after saving these files.
3. Add the Go read method
Add a typed read method to the existing ItemsService in apps/desktop/internal/items/summary.go:
package items
type ItemSummary struct {
Total int `json:"total"`
Completed int `json:"completed"`
}
func (s *ItemsService) GetItemSummary() (ItemSummary, error) {
items, err := s.GetItems()
if err != nil {
return ItemSummary{}, err
}
summary := ItemSummary{Total: len(items)}
for _, item := range items {
if item.Done {
summary.Completed++
}
}
return summary, nil
}
Because ItemsService is already registered in apps/desktop/internal/app/run.go, Wails exposes GetItemSummary automatically once bindings are regenerated. Calling s.GetItems() preserves startup and database initialization errors without opening a second connection. (If you add a brand-new Go package instead, register its service in internal/app/run.go using your actual module path from apps/desktop/go.mod.)
For features that write data, always validate every input in Go regardless of frontend Zod schemas—follow internal/items/database.go, which trims titles, counts Unicode runes (1–200), checks IDs, and uses parameterized SQL. Write unit tests covering zero items, mixed completion, and an unavailable store using temporary directories rather than personal app data.
Regenerate Wails bindings and run the Go test suite (never hand-edit files in frontend/bindings/):
pnpm run desktop:bindings
pnpm run test:go
Generated bindings stay ignored by Git. Keep all imports of generated bindings inside apps/desktop/frontend/src/host/native.ts.
4. Validate the contract in both adapters
Define the shared Zod schema and TypeScript type alongside the item schemas in apps/desktop/frontend/src/host/contract.ts:
export const itemSummarySchema = z.object({
total: z.number().int().nonnegative().safe(),
completed: z.number().int().nonnegative().safe(),
}).refine(value => value.completed <= value.total, 'Invalid item summary');
export type ItemSummary = z.infer<typeof itemSummarySchema>;
Add getItemSummary(): Promise<ItemSummary>; to the Host interface in the same file, then import itemSummarySchema from ./contract in both src/host/native.ts and src/host/browser.ts.
In apps/desktop/frontend/src/host/native.ts, add the method to the returned host object (reusing the existing dynamically imported items binding and guard() check):
getItemSummary: async () => {
guard();
return itemSummarySchema.parse(await items.GetItemSummary());
},
If your own feature introduces a new Go service instead of extending ItemsService, add its dynamic import() to the Promise.all([...]) list in native.ts using your actual module path from apps/desktop/go.mod:
../../bindings/<go-module-path>/internal/<package>/<service>.js.
In apps/desktop/frontend/src/host/browser.ts, compute the summary from the preview adapter’s in-memory items array:
getItemSummary: async () => itemSummarySchema.parse({
total: items.length,
completed: items.filter(item => item.done).length,
}),
Browser preview keeps source: 'preview' and never claims data came from SQLite. Update any typed mock Host objects in frontend tests to include getItemSummary, and add tests verifying that invalid counts (completed > total) fail Zod validation and that preview counts update after mutations.
5. Use the existing query invalidation boundary
Add a child query key and TanStack Query queryOptions helper to apps/desktop/frontend/src/query.ts:
export const itemSummaryKey = [...itemsKey, 'summary'] as const;
export const itemSummaryQuery = (host: Host) =>
queryOptions({ queryKey: itemSummaryKey, queryFn: () => host.getItemSummary() });
Because itemSummaryKey starts with itemsKey (['items']), the existing client.invalidateQueries({ queryKey: itemsKey }) call in pages/items.tsx automatically invalidates ['items', 'summary'] on every add, edit, completion toggle, or delete. Active observers refetch immediately; inactive ones mark stale until mounted. Keep the app’s single QueryClient with networkMode: 'always' so local IPC works offline, and never construct a QueryClient inside a shared @wailspring/ui component.
If your feature also adds a mutation form, follow the pattern in pages/items.tsx: React Hook Form useForm with zodResolver(...), Field.ErrorText rendering translated validation keys, visible pending/error/success feedback, form reset and focus restoration on success, and independent Go validation on the backend.
6. Compose and translate in the app
Merge a summary object into the root of both locale files under apps/desktop/frontend/src/i18n/locales/. In en.json:
{
"summary": {
"heading": "Completion",
"completed_one": "{{count}} completed item",
"completed_other": "{{count}} completed items",
"total_one": "{{count}} item in total",
"total_other": "{{count}} items in total"
}
}
Add the matching German keys to de.json:
heading: Abgeschlossen
completed_one: {{count}} abgeschlossener Eintrag
completed_other: {{count}} abgeschlossene Einträge
total_one: {{count}} Eintrag insgesamt
total_other: {{count}} Einträge insgesamt
en.json drives the typed t() keys in src/i18n/index.ts (consumed via useTranslation), so both locale files must stay in sync.
Create apps/desktop/frontend/src/components/item-summary.tsx:
import { useTranslation } from 'react-i18next';
import { useQuery } from '@tanstack/react-query';
import { ItemStatus } from '@wailspring/ui';
import type { Host } from '../host/contract';
import { itemSummaryQuery } from '../query';
import { styles } from '../app.styles';
import { Failure } from './feedback';
export function ItemSummary({ host }: { host: Host }) {
const { t } = useTranslation();
const summary = useQuery(itemSummaryQuery(host));
return (
<section className={styles.panel} aria-labelledby="completion-heading">
<h2 id="completion-heading" className={styles.label}>{t('summary.heading')}</h2>
{summary.isPending && <p role="status">{t('items.loading')}</p>}
{summary.isError && <Failure error={summary.error} retry={() => { void summary.refetch(); }} />}
{summary.isSuccess && <>
<ItemStatus state={summary.data.completed > 0 ? 'complete' : 'pending'}>
{t('summary.completed', { count: summary.data.completed })}
</ItemStatus>
<p>{t('summary.total', { count: summary.data.total })}</p>
<p>{host.source === 'native' ? t('overview.stored') : t('overview.session')}</p>
</>}
</section>
);
}
Import ItemSummary from ../components/item-summary in apps/desktop/frontend/src/pages/overview.tsx and render <ItemSummary host={host} /> once inside its returned fragment (so id="completion-heading" stays unique on the page). The badge switches to the complete tone once at least one item is done while always showing the exact count and honest storage source. When a new component needs custom layout rules, place them in a colocated *.styles.ts Panda module; here we reuse styles.panel and styles.label from app.styles.ts.
7. Document it with the same static recipe
Because the itemStatus recipe lives in @wailspring/design-system, the Astro docs site can render a real specimen through the Astro MDX integration without importing React or shipping client JavaScript.
After rebuilding @wailspring/design-system, create apps/site/src/components/ItemStatusExample.astro:
---
import { itemStatus } from '@wailspring/design-system/recipes';
import { ComponentPreview } from '@wailspring/docs/astro';
import { TextLink } from '@wailspring/ui/astro';
---
<ComponentPreview title="Completed items" code={'<ItemStatus state="complete">2 completed items</ItemStatus>'}>
<span class={itemStatus({ state: 'complete' })}>2 completed items</span>
</ComponentPreview>
<TextLink href="/docs/build-a-feature/">Feature workflow</TextLink>
This is a static documentation example—not live user data. Only add reusable wrappers to @wailspring/ui/astro when a primitive is genuinely shared across pages; calling @wailspring/design-system/recipes directly works cleanly for one-off examples.
Next, create packages/content/docs/features/item-summary.mdx:
---
title: Item summary
description: Read the completed-item count and distinguish native storage from preview data.
---
import ItemStatusExample from '@/components/ItemStatusExample.astro';
## Completed count
The overview shows the completed count from the selected app host. Browser
preview uses session data. Native mode reads the current SQLite items.
<ItemStatusExample />
See the [feature workflow](../build-a-feature.md#3-add-the-go-read-method).
Astro publishes this nested file automatically at /docs/features/item-summary/, adds it to the landing page, docs index, and pager, and rewrites the relative Markdown link (including its #3-add-the-go-read-method anchor) into a site URL. See Writing documentation for ordering and drafts.
8. Verify the extension
Run the full check sequence from the repository root:
pnpm run desktop:bindings
pnpm run build
pnpm run check
pnpm test
pnpm run test:go
pnpm run desktop:build
Add focused tests for the new behavior: Go summary counts and error propagation, Zod rejection of impossible counts, preview mutations updating counts, and TanStack Query refetching the summary after an item change. Check English and German text, loading and retry states, light and dark themes, keyboard focus, and the new /docs/features/item-summary/ page on narrow mobile viewports (confirming no React island or Park UI stylesheet is emitted).
Finally, run pnpm run desktop:dev to test the real native app: complete an item, confirm the Overview summary updates, restart the app, and confirm the count persists from SQLite. A browser preview cannot verify Wails bindings, SQLite persistence, or webview rendering.
If you also want an isolated visual and accessibility check for ItemStatus, add a Storybook story in apps/storybook/src/ passing translated children for both pending and complete states with no native host, then run pnpm run storybook, pnpm run check:storybook, or pnpm run test:storybook. Storybook stays independent of root builds and production apps.
This walkthrough adds a completed-item summary and status badge to the desktop app’s Overview screen, then documents the badge statically on the Astro site. It is a hands-on tutorial to implement on a feature branch: the
itemStatusrecipe,ItemStatuscomponent,GetItemSummarymethod, and summary query below are additions you will write, not APIs already shipped by the starter.Complete Getting started first. Because the summary computes counts from the existing SQLite
itemstable, no database migration is needed. Keep existing public component APIs, token values, theme behavior, and third-party license notices intact.Finished example
The completed Overview uses browser preview with two completed items out of three. Its data is session-only, and native actions are unavailable.
Overview — light theme.
Overview — dark theme.
The Astro page added in step 7 renders the same badge as a static specimen with an example count.
Static Astro specimen — light theme.
Static Astro specimen — dark theme.
1. Define a semantic role and foundation recipe
Start in the shared design system so both React and Astro get the exact same light/dark colors and badge geometry.
In
packages/design-system/src/foundations.ts, add two semantic color tokens inside the existingfoundationsobject. Reference existing semantic tokens rather than raw hex values:Panda’s design system builder converts these entries into CSS variables and semantic tokens: tokens with a
darkfield switch automatically ondata-theme="dark", while single-value aliases inherit the light/dark behavior of the token they reference.Next, add a framework-independent recipe inside
recipesinpackages/design-system/src/recipes.ts(before the existingsatisfiesclause):A status badge is non-interactive text, so it needs no focus ring or motion. Rebuild shared package exports before importing the new recipe:
2. Export a shared React component
Wrap the Wailspring recipe in
@wailspring/uiso React apps can render it as a typed component while keeping it host-agnostic.Create
packages/ui/src/components/item-status.tsx:Re-export it from
packages/ui/src/components/index.ts:Because the package’s root barrel re-exports
./components/index.jsand the wildcard export exposes./components/*, consumers can now importItemStatusfrom either@wailspring/uior@wailspring/ui/components/item-status. Notice what this component does not know about: Go bindings, TanStack Query, ori18next. It renders the translated children passed by the host app, while its styling stays in@wailspring/design-systemso Astro can reuse the same recipe. Runpnpm run design-system:buildagain after saving these files.3. Add the Go read method
Add a typed read method to the existing
ItemsServiceinapps/desktop/internal/items/summary.go:Because
ItemsServiceis already registered inapps/desktop/internal/app/run.go, Wails exposesGetItemSummaryautomatically once bindings are regenerated. Callings.GetItems()preserves startup and database initialization errors without opening a second connection. (If you add a brand-new Go package instead, register its service ininternal/app/run.gousing your actual module path fromapps/desktop/go.mod.)For features that write data, always validate every input in Go regardless of frontend Zod schemas—follow
internal/items/database.go, which trims titles, counts Unicode runes (1–200), checks IDs, and uses parameterized SQL. Write unit tests covering zero items, mixed completion, and an unavailable store using temporary directories rather than personal app data.Regenerate Wails bindings and run the Go test suite (never hand-edit files in
frontend/bindings/):Generated bindings stay ignored by Git. Keep all imports of generated bindings inside
apps/desktop/frontend/src/host/native.ts.4. Validate the contract in both adapters
Define the shared Zod schema and TypeScript type alongside the item schemas in
apps/desktop/frontend/src/host/contract.ts:Add
getItemSummary(): Promise<ItemSummary>;to theHostinterface in the same file, then importitemSummarySchemafrom./contractin bothsrc/host/native.tsandsrc/host/browser.ts.In
apps/desktop/frontend/src/host/native.ts, add the method to the returned host object (reusing the existing dynamically importeditemsbinding andguard()check):If your own feature introduces a new Go service instead of extending
ItemsService, add its dynamicimport()to thePromise.all([...])list innative.tsusing your actual module path fromapps/desktop/go.mod:../../bindings/<go-module-path>/internal/<package>/<service>.js.In
apps/desktop/frontend/src/host/browser.ts, compute the summary from the preview adapter’s in-memoryitemsarray:Browser preview keeps
source: 'preview'and never claims data came from SQLite. Update any typed mockHostobjects in frontend tests to includegetItemSummary, and add tests verifying that invalid counts (completed > total) fail Zod validation and that preview counts update after mutations.5. Use the existing query invalidation boundary
Add a child query key and TanStack Query
queryOptionshelper toapps/desktop/frontend/src/query.ts:Because
itemSummaryKeystarts withitemsKey(['items']), the existingclient.invalidateQueries({ queryKey: itemsKey })call inpages/items.tsxautomatically invalidates['items', 'summary']on every add, edit, completion toggle, or delete. Active observers refetch immediately; inactive ones mark stale until mounted. Keep the app’s singleQueryClientwithnetworkMode: 'always'so local IPC works offline, and never construct aQueryClientinside a shared@wailspring/uicomponent.If your feature also adds a mutation form, follow the pattern in
pages/items.tsx: React Hook FormuseFormwithzodResolver(...),Field.ErrorTextrendering translated validation keys, visible pending/error/success feedback, form reset and focus restoration on success, and independent Go validation on the backend.6. Compose and translate in the app
Merge a
summaryobject into the root of both locale files underapps/desktop/frontend/src/i18n/locales/. Inen.json:Add the matching German keys to
de.json:heading:Abgeschlossencompleted_one:{{count}} abgeschlossener Eintragcompleted_other:{{count}} abgeschlossene Einträgetotal_one:{{count}} Eintrag insgesamttotal_other:{{count}} Einträge insgesamten.jsondrives the typedt()keys insrc/i18n/index.ts(consumed viauseTranslation), so both locale files must stay in sync.Create
apps/desktop/frontend/src/components/item-summary.tsx:Import
ItemSummaryfrom../components/item-summaryinapps/desktop/frontend/src/pages/overview.tsxand render<ItemSummary host={host} />once inside its returned fragment (soid="completion-heading"stays unique on the page). The badge switches to thecompletetone once at least one item is done while always showing the exact count and honest storage source. When a new component needs custom layout rules, place them in a colocated*.styles.tsPanda module; here we reusestyles.panelandstyles.labelfromapp.styles.ts.7. Document it with the same static recipe
Because the
itemStatusrecipe lives in@wailspring/design-system, the Astro docs site can render a real specimen through the Astro MDX integration without importing React or shipping client JavaScript.After rebuilding
@wailspring/design-system, createapps/site/src/components/ItemStatusExample.astro:This is a static documentation example—not live user data. Only add reusable wrappers to
@wailspring/ui/astrowhen a primitive is genuinely shared across pages; calling@wailspring/design-system/recipesdirectly works cleanly for one-off examples.Next, create
packages/content/docs/features/item-summary.mdx:Astro publishes this nested file automatically at
/docs/features/item-summary/, adds it to the landing page, docs index, and pager, and rewrites the relative Markdown link (including its#3-add-the-go-read-methodanchor) into a site URL. See Writing documentation for ordering and drafts.8. Verify the extension
Run the full check sequence from the repository root:
Add focused tests for the new behavior: Go summary counts and error propagation, Zod rejection of impossible counts, preview mutations updating counts, and TanStack Query refetching the summary after an item change. Check English and German text, loading and retry states, light and dark themes, keyboard focus, and the new
/docs/features/item-summary/page on narrow mobile viewports (confirming no React island or Park UI stylesheet is emitted).Finally, run
pnpm run desktop:devto test the real native app: complete an item, confirm the Overview summary updates, restart the app, and confirm the count persists from SQLite. A browser preview cannot verify Wails bindings, SQLite persistence, or webview rendering.If you also want an isolated visual and accessibility check for
ItemStatus, add a Storybook story inapps/storybook/src/passing translated children for bothpendingandcompletestates with no native host, then runpnpm run storybook,pnpm run check:storybook, orpnpm run test:storybook. Storybook stays independent of root builds and production apps.