# Continuity ledger (per-branch)

## Human intent (must not be overwritten)

- Add useSWR with revalidateOnFocus to data stores so that newly added data stores are visible when returning to /workspaces/:id without page refresh
- Reuse the same fetch function for both initial server-side load and client-side SWR refetch
- Avoid creating an API route; use Server Action directly as SWR fetcher

## Goal (incl. success criteria)

- Data stores refresh automatically when the workspace page gains focus
- No page reload required to see newly created data stores
- Single Server Action (`getTeamDataStores`) shared between data-loader.ts and useSWR

## Constraints/Assumptions

- Follow existing pattern from `useDocumentVectorStores`
- Server Actions can be called from both server components and client components
- SWR's default `revalidateOnFocus: true` handles automatic refetch

## Key decisions

- Created `getTeamDataStores` Server Action in `lib/data-stores/actions.ts`
- Used Server Action directly as SWR fetcher instead of API route
- Added `fetchDataStores` optional function to `DataStoreContextValue` interface
- Created `useDataStores` hook that accepts fetcher as parameter

## State

- Implementation complete
- All verification passed: format, build-sdk, check-types, test, tidy

## Done

- Created `lib/data-stores/actions.ts` with `getTeamDataStores` Server Action
- Updated `data-loader.ts` to use the Server Action
- Created `use-data-stores.ts` hook with useSWR
- Updated `DataStoreContextValue` to include `fetchDataStores`
- Updated `page.client.tsx` to pass the Server Action
- Updated `DataStorePropertiesPanel` to use the new hook

## Now

- N/A (complete)

## Next

- N/A (complete)

## Open questions (UNCONFIRMED if needed)

- None

## Working set (files/ids/commands)

- `apps/studio.giselles.ai/lib/data-stores/actions.ts` (new)
- `apps/studio.giselles.ai/app/workspaces/[workspaceId]/data-loader.ts` (modified)
- `apps/studio.giselles.ai/app/workspaces/[workspaceId]/page.client.tsx` (modified)
- `internal-packages/workflow-designer-ui/src/editor/hooks/use-data-stores.ts` (new)
- `internal-packages/workflow-designer-ui/src/editor/properties-panel/data-store-properties-panel/index.tsx` (modified)
- `packages/react/src/data-store/context.tsx` (modified)

## 2026-02-11 `/tasks/[taskId]` authorization fix

### Key decisions

- Kept authorization check inline in `app/(main)/tasks/[taskId]/page.tsx` (no shared helper)
- Used the unified message `authorization error` only for refresh-time unauthorized access
- Preserved resource existence masking on first load with `notFound()` for both missing task and non-member
- Avoided relying on thrown Server Action error messages; `refreshAction` now returns an ActionResult-style object

### Files changed

- `apps/studio.giselles.ai/app/(main)/tasks/[taskId]/page.tsx`
- `apps/studio.giselles.ai/app/(main)/tasks/[taskId]/ui/task-client.tsx`

### Verification

- IDE linter (`ReadLints`) reports no diagnostics in changed files
- `pnpm exec biome check` is currently unavailable in this environment (`biome` command not found)
- Behavior alignment:
  - initial load: missing/non-member task -> `notFound()`
  - refresh: existing task + non-member -> `authorization error`
  - client: handles only `authorization error` with toast and `/tasks` redirect
