Skip to content

Migrate frontend data fetching to Pinia Colada#1542

Draft
Copilot wants to merge 4 commits intostagingfrom
copilot/refactor-frontend-state-logic
Draft

Migrate frontend data fetching to Pinia Colada#1542
Copilot wants to merge 4 commits intostagingfrom
copilot/refactor-frontend-state-logic

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 8, 2026

Replace custom useData/useDataLoader composables with Pinia Colada (@pinia/colada) for query caching, SSR hydration, and reactive data fetching.

New dependencies

  • @pinia/colada@1.0.0 — query/mutation cache layer on top of Pinia
  • @pinia/colada-nuxt@0.3.2 — Nuxt module for SSR payload serialization and auto-imports

Query definitions (app/queries/)

Domain-organized query files using useQuery():

  • useProjectQueries.ts — projects, starred, watching, pinned, channels, versions, pages, watchers, stargazers
  • useUserQueries.ts — users, orgs, staff, authors
  • useNotificationQueries.ts — notifications, unread count, invites
  • useAdminQueries.ts — stats, health, flags, approvals, action logs
  • useMiscQueries.ts — version info, owners, auth settings, API keys, reviews, jar scans

Bridge layer (useData.ts)

The 35+ composables in useData.ts now delegate to Pinia Colada queries while preserving the same public API. No consumer changes needed for read-only usage.

// Before: 150+ lines of custom caching, debounce, SSR prefetch
export function useStarred(user: () => string) {
  const { data, status } = useData(user, (u) => "starred:" + u,
    (u) => useApi<PaginatedResultProjectCompact>(`users/${u}/starred`));
  return { starred: data, starredStatus: status };
}

// After: delegates to Pinia Colada query with reactive key + staleTime
export function useStarred(user: () => string) {
  const q = useStarredQuery(user);
  return { starred: q.data, starredStatus: mapStatus(q) };
}

Optimistic updates

Consumers that mutate cached data now use useQueryCache().setQueryData() via writable computed refs instead of direct .value assignment:

  • Notification mark-as-read, API key CRUD, flag resolution, invite accept/decline

Removed

  • useData() generic function (~150 LOC) with manual useState caching, watchDebounced, Sentry spans, SSR prefetch orchestration
  • checkEqual() deep comparison utility

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • hangar.papermc.dev
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/Hangar/Hangar/frontend/node_modules/.bin/../.pnpm/nuxt@4.1.2_@netlify&#43;blobs@9.1.2_@parcel&#43;watcher@2.5.1_@types&#43;node@24.6.2_@vue&#43;compiler-_212c46afb5675bb5e2449a7f71efdee6/node_modules/nuxt/bin/nuxt.mjs typecheck (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/Hangar/Hangar/frontend/node_modules/.bin/../.pnpm/nuxt@4.1.2_@netlify&#43;blobs@9.1.2_@parcel&#43;watcher@2.5.1_@types&#43;node@24.6.2_@vue&#43;compiler-_212c46afb5675bb5e2449a7f71efdee6/node_modules/nuxt/bin/nuxt.mjs typecheck git conf�� s --global tools/pnpm/10.20.0_tmp_4187_0/node_modules/pnpm/dist/node-gyp-bin/node pages/notifications.vue app/pages/auth/settings/api-keys.vue &#34;$k=&#34;.$v[&#34;local/home/REDACTED/work/Hangar/Hangar/frontend/node_modules/.bin/../.pnpm/�� (dns block)
  • hangar.papermc.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/Hangar/Hangar/frontend/node_modules/.bin/../.pnpm/nuxt@4.1.2_@netlify&#43;blobs@9.1.2_@parcel&#43;watcher@2.5.1_@types&#43;node@24.6.2_@vue&#43;compiler-_212c46afb5675bb5e2449a7f71efdee6/node_modules/nuxt/bin/nuxt.mjs typecheck (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/Hangar/Hangar/frontend/node_modules/.bin/../.pnpm/nuxt@4.1.2_@netlify&#43;blobs@9.1.2_@parcel&#43;watcher@2.5.1_@types&#43;node@24.6.2_@vue&#43;compiler-_212c46afb5675bb5e2449a7f71efdee6/node_modules/nuxt/bin/nuxt.mjs typecheck git conf�� s --global tools/pnpm/10.20.0_tmp_4187_0/node_modules/pnpm/dist/node-gyp-bin/node pages/notifications.vue app/pages/auth/settings/api-keys.vue &#34;$k=&#34;.$v[&#34;local/home/REDACTED/work/Hangar/Hangar/frontend/node_modules/.bin/../.pnpm/�� (dns block)
  • o1.ingest.sentry.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/Hangar/Hangar/frontend/node_modules/.bin/../.pnpm/nuxt@4.1.2_@netlify&#43;blobs@9.1.2_@parcel&#43;watcher@2.5.1_@types&#43;node@24.6.2_@vue&#43;compiler-_212c46afb5675bb5e2449a7f71efdee6/node_modules/nuxt/bin/nuxt.mjs typecheck (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/Hangar/Hangar/frontend/node_modules/.bin/../.pnpm/nuxt@4.1.2_@netlify&#43;blobs@9.1.2_@parcel&#43;watcher@2.5.1_@types&#43;node@24.6.2_@vue&#43;compiler-_212c46afb5675bb5e2449a7f71efdee6/node_modules/nuxt/bin/nuxt.mjs typecheck git conf�� s --global tools/pnpm/10.20.0_tmp_4187_0/node_modules/pnpm/dist/node-gyp-bin/node pages/notifications.vue app/pages/auth/settings/api-keys.vue &#34;$k=&#34;.$v[&#34;local/home/REDACTED/work/Hangar/Hangar/frontend/node_modules/.bin/../.pnpm/�� (dns block)
  • pinia-colada.esm.dev
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)
  • www.npmjs.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 3 commits March 8, 2026 09:12
- Install @pinia/colada and @pinia/colada-nuxt
- Add @pinia/colada-nuxt module to nuxt.config.ts
- Create queries/ folder with domain-organized query definitions
- Rewrite useData.ts composables to delegate to Pinia Colada queries
- Simplify useDataLoader.ts (remove old useData function)
- Update consumer components for immutable optimistic updates
- Use useQueryCache().setQueryData() for cache mutations

Co-authored-by: MiniDigger <2185527+MiniDigger@users.noreply.github.com>
- Fix undefined values in query keys (use nullish coalescing)
- Remove unused imports and parameters
- Fix read-only computed assignment in notifications.vue
- Make notification/invite data writable for optimistic updates
- Run prettier and eslint fixes

Co-authored-by: MiniDigger <2185527+MiniDigger@users.noreply.github.com>
Co-authored-by: MiniDigger <2185527+MiniDigger@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor frontend state logic with pinia/pina-colada Migrate frontend data fetching to Pinia Colada Mar 8, 2026
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