@agent-native/core 0.101.14 → 0.102.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +12 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/cli/templates-meta.ts +13 -0
- package/corpus/core/src/client/agent-page/AgentTabsPage.tsx +1 -1
- package/corpus/core/src/client/org/OrgSwitcher.tsx +2 -0
- package/corpus/templates/analytics/changelog/2026-07-15-fixed-the-agent-discarding-a-successful-dashboard-edit-and-r.md +6 -0
- package/corpus/templates/analytics/server/lib/real-data-actions.ts +30 -1
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +15 -0
- package/corpus/templates/content/actions/_database-source-utils.ts +59 -4
- package/corpus/templates/content/actions/prepare-builder-source-review.ts +9 -0
- package/corpus/templates/content/actions/preview-builder-source-review.ts +6 -4
- package/corpus/templates/content/app/components/editor/DescriptionField.tsx +10 -2
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +4 -0
- package/corpus/templates/content/changelog/2026-07-15-page-and-database-descriptions-now-use-a-clean-single-line-f.md +6 -0
- package/corpus/templates/content/changelog/2026-07-15-selected-builder-reviews-now-load-only-the-chosen-rows-avoid.md +6 -0
- package/corpus/templates/content/shared/api.ts +1 -0
- package/corpus/templates/tasks/.agents/commands/visual-plan.md +9 -0
- package/corpus/templates/tasks/.agents/commands/visual-recap.md +8 -0
- package/corpus/templates/tasks/.agents/skills/actions/SKILL.md +492 -0
- package/corpus/templates/tasks/.agents/skills/adding-a-feature/SKILL.md +189 -0
- package/corpus/templates/tasks/.agents/skills/agent-native-docs/SKILL.md +76 -0
- package/corpus/templates/tasks/.agents/skills/agent-watchdog/README.md +43 -0
- package/corpus/templates/tasks/.agents/skills/agent-watchdog/SKILL.md +110 -0
- package/corpus/templates/tasks/.agents/skills/agent-watchdog/agents/openai.yaml +4 -0
- package/corpus/templates/tasks/.agents/skills/capture-learnings/SKILL.md +89 -0
- package/corpus/templates/tasks/.agents/skills/change-summary/SKILL.md +83 -0
- package/corpus/templates/tasks/.agents/skills/create-skill/SKILL.md +221 -0
- package/corpus/templates/tasks/.agents/skills/delegate-to-agent/SKILL.md +263 -0
- package/corpus/templates/tasks/.agents/skills/efficient-fable/README.md +75 -0
- package/corpus/templates/tasks/.agents/skills/efficient-fable/SKILL.md +95 -0
- package/corpus/templates/tasks/.agents/skills/efficient-frontier/README.md +53 -0
- package/corpus/templates/tasks/.agents/skills/efficient-frontier/SKILL.md +73 -0
- package/corpus/templates/tasks/.agents/skills/frontend-design/SKILL.md +112 -0
- package/corpus/templates/tasks/.agents/skills/plan-arbiter/README.md +41 -0
- package/corpus/templates/tasks/.agents/skills/plan-arbiter/SKILL.md +114 -0
- package/corpus/templates/tasks/.agents/skills/plan-arbiter/agents/openai.yaml +4 -0
- package/corpus/templates/tasks/.agents/skills/plow-ahead/README.md +42 -0
- package/corpus/templates/tasks/.agents/skills/plow-ahead/SKILL.md +104 -0
- package/corpus/templates/tasks/.agents/skills/plow-ahead/agents/openai.yaml +4 -0
- package/corpus/templates/tasks/.agents/skills/quick-recap/README.md +55 -0
- package/corpus/templates/tasks/.agents/skills/quick-recap/SKILL.md +54 -0
- package/corpus/templates/tasks/.agents/skills/read-the-damn-docs/README.md +54 -0
- package/corpus/templates/tasks/.agents/skills/read-the-damn-docs/SKILL.md +126 -0
- package/corpus/templates/tasks/.agents/skills/read-the-damn-docs/agents/openai.yaml +4 -0
- package/corpus/templates/tasks/.agents/skills/real-time-sync/SKILL.md +232 -0
- package/corpus/templates/tasks/.agents/skills/security/SKILL.md +280 -0
- package/corpus/templates/tasks/.agents/skills/self-modifying-code/SKILL.md +106 -0
- package/corpus/templates/tasks/.agents/skills/shadcn-ui/SKILL.md +95 -0
- package/corpus/templates/tasks/.agents/skills/stay-within-limits/README.md +61 -0
- package/corpus/templates/tasks/.agents/skills/stay-within-limits/SKILL.md +83 -0
- package/corpus/templates/tasks/.agents/skills/upgrade-agent-native/SKILL.md +87 -0
- package/corpus/templates/tasks/.agents/skills/visual-plan/SKILL.md +547 -0
- package/corpus/templates/tasks/.agents/skills/visual-plan/agent-native-skill.json +12 -0
- package/corpus/templates/tasks/.agents/skills/visual-plan/references/canvas.md +121 -0
- package/corpus/templates/tasks/.agents/skills/visual-plan/references/document-quality.md +178 -0
- package/corpus/templates/tasks/.agents/skills/visual-plan/references/exemplar.md +62 -0
- package/corpus/templates/tasks/.agents/skills/visual-plan/references/wireframe.md +264 -0
- package/corpus/templates/tasks/.agents/skills/visual-recap/SKILL.md +634 -0
- package/corpus/templates/tasks/.agents/skills/visual-recap/agent-native-skill.json +12 -0
- package/corpus/templates/tasks/.agents/skills/visual-recap/references/wireframe.md +264 -0
- package/corpus/templates/tasks/.claude/commands/visual-plan.md +9 -0
- package/corpus/templates/tasks/.claude/commands/visual-recap.md +8 -0
- package/corpus/templates/tasks/.env.example +5 -0
- package/corpus/templates/tasks/.ignore +0 -0
- package/corpus/templates/tasks/.prettierrc +5 -0
- package/corpus/templates/tasks/AGENTS.md +158 -0
- package/corpus/templates/tasks/DEVELOPING.md +185 -0
- package/corpus/templates/tasks/README.md +16 -0
- package/corpus/templates/tasks/actions/bulk-delete-inbox-items.ts +24 -0
- package/corpus/templates/tasks/actions/bulk-delete-tasks.ts +21 -0
- package/corpus/templates/tasks/actions/bulk-mark-inbox-items-ready.ts +27 -0
- package/corpus/templates/tasks/actions/bulk-update-tasks.ts +35 -0
- package/corpus/templates/tasks/actions/create-custom-field.ts +22 -0
- package/corpus/templates/tasks/actions/create-inbox-item.ts +30 -0
- package/corpus/templates/tasks/actions/create-task.ts +33 -0
- package/corpus/templates/tasks/actions/delete-custom-field.ts +19 -0
- package/corpus/templates/tasks/actions/delete-inbox-item.ts +17 -0
- package/corpus/templates/tasks/actions/delete-task.ts +17 -0
- package/corpus/templates/tasks/actions/lib/boolean-query-param.ts +30 -0
- package/corpus/templates/tasks/actions/list-custom-fields.ts +18 -0
- package/corpus/templates/tasks/actions/list-inbox-items.ts +16 -0
- package/corpus/templates/tasks/actions/list-tasks.ts +52 -0
- package/corpus/templates/tasks/actions/list-visible-task-fields.ts +18 -0
- package/corpus/templates/tasks/actions/mark-inbox-item-ready.ts +31 -0
- package/corpus/templates/tasks/actions/navigate.ts +51 -0
- package/corpus/templates/tasks/actions/reorder-custom-fields.ts +27 -0
- package/corpus/templates/tasks/actions/reorder-inbox-items.ts +24 -0
- package/corpus/templates/tasks/actions/reorder-tasks.ts +29 -0
- package/corpus/templates/tasks/actions/run.ts +2 -0
- package/corpus/templates/tasks/actions/update-custom-field.ts +33 -0
- package/corpus/templates/tasks/actions/update-inbox-item.ts +24 -0
- package/corpus/templates/tasks/actions/update-task.ts +68 -0
- package/corpus/templates/tasks/actions/update-visible-task-fields.ts +27 -0
- package/corpus/templates/tasks/actions/view-screen-helpers.ts +68 -0
- package/corpus/templates/tasks/actions/view-screen.ts +207 -0
- package/corpus/templates/tasks/app/components/custom-fields/FieldCreateBar.tsx +121 -0
- package/corpus/templates/tasks/app/components/custom-fields/FieldListRow.tsx +116 -0
- package/corpus/templates/tasks/app/components/custom-fields/FieldsList.tsx +225 -0
- package/corpus/templates/tasks/app/components/custom-fields/FieldsListSkeleton.tsx +18 -0
- package/corpus/templates/tasks/app/components/custom-fields/FieldsPage.tsx +42 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/FieldEditorSidebar.tsx +69 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/FieldTitleSection.tsx +32 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/config/CurrencyConfigControl.tsx +49 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/config/FieldConfigControl.tsx +56 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/config/NumberConfigControl.tsx +52 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/config/PercentConfigControl.tsx +30 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/config/SelectConfigControl.tsx +135 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/config/select-colors.ts +23 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/config/utils.ts +52 -0
- package/corpus/templates/tasks/app/components/custom-fields/editor/types.ts +7 -0
- package/corpus/templates/tasks/app/components/dnd/SortableItem.tsx +72 -0
- package/corpus/templates/tasks/app/components/dnd/SortableList.tsx +136 -0
- package/corpus/templates/tasks/app/components/dnd/reorder-moving-items.ts +160 -0
- package/corpus/templates/tasks/app/components/dnd/sortable-drag-props.ts +60 -0
- package/corpus/templates/tasks/app/components/inbox/InboxList.tsx +222 -0
- package/corpus/templates/tasks/app/components/inbox/InboxListPage.tsx +39 -0
- package/corpus/templates/tasks/app/components/inbox/InboxListRow.tsx +122 -0
- package/corpus/templates/tasks/app/components/layout/Header.tsx +55 -0
- package/corpus/templates/tasks/app/components/layout/HeaderActions.tsx +84 -0
- package/corpus/templates/tasks/app/components/layout/Layout.tsx +134 -0
- package/corpus/templates/tasks/app/components/layout/Sidebar.tsx +211 -0
- package/corpus/templates/tasks/app/components/shared/AddListItemInput.tsx +57 -0
- package/corpus/templates/tasks/app/components/shared/AlertDialog.tsx +53 -0
- package/corpus/templates/tasks/app/components/shared/BulkDeleteDialog.tsx +76 -0
- package/corpus/templates/tasks/app/components/shared/ChipSelect.tsx +240 -0
- package/corpus/templates/tasks/app/components/shared/DeleteItemDialog.tsx +40 -0
- package/corpus/templates/tasks/app/components/shared/InlineEditable.tsx +166 -0
- package/corpus/templates/tasks/app/components/shared/ListEmptyState.tsx +13 -0
- package/corpus/templates/tasks/app/components/shared/ListErrorMessage.tsx +15 -0
- package/corpus/templates/tasks/app/components/shared/ListViewHeader.tsx +75 -0
- package/corpus/templates/tasks/app/components/shared/PageHeader.tsx +25 -0
- package/corpus/templates/tasks/app/components/shared/RowActionsMenu.tsx +42 -0
- package/corpus/templates/tasks/app/components/shared/SidePanel.tsx +99 -0
- package/corpus/templates/tasks/app/components/shared/dnd/ListRowPreview.tsx +37 -0
- package/corpus/templates/tasks/app/components/shared/list/List.tsx +63 -0
- package/corpus/templates/tasks/app/components/shared/list/ListRow.tsx +159 -0
- package/corpus/templates/tasks/app/components/shared/list/ListRowDragHandle.tsx +52 -0
- package/corpus/templates/tasks/app/components/shared/list/ListSkeletonRows.tsx +11 -0
- package/corpus/templates/tasks/app/components/shared/list/SortableListItemShell.tsx +32 -0
- package/corpus/templates/tasks/app/components/shared/list/types.ts +1 -0
- package/corpus/templates/tasks/app/components/shared/selection/ListSelectionBar.tsx +158 -0
- package/corpus/templates/tasks/app/components/shared/selection/ListSelectionHeaderToggle.tsx +28 -0
- package/corpus/templates/tasks/app/components/shared/selection/ListSelectionToolbar.tsx +81 -0
- package/corpus/templates/tasks/app/components/shared/selection/get-list-row-selection-ui.ts +41 -0
- package/corpus/templates/tasks/app/components/shared/selection/use-list-selection.ts +196 -0
- package/corpus/templates/tasks/app/components/tasks/TaskList.tsx +333 -0
- package/corpus/templates/tasks/app/components/tasks/TaskListHeaderRow.tsx +46 -0
- package/corpus/templates/tasks/app/components/tasks/TaskListPage.tsx +115 -0
- package/corpus/templates/tasks/app/components/tasks/TaskListRow.css +49 -0
- package/corpus/templates/tasks/app/components/tasks/TaskListRow.tsx +307 -0
- package/corpus/templates/tasks/app/components/tasks/fields/TaskFieldsSidebar.tsx +102 -0
- package/corpus/templates/tasks/app/components/tasks/fields/TaskTitleSection.tsx +27 -0
- package/corpus/templates/tasks/app/components/tasks/fields/controls/DateValueControl.tsx +21 -0
- package/corpus/templates/tasks/app/components/tasks/fields/controls/FieldValueControl.tsx +76 -0
- package/corpus/templates/tasks/app/components/tasks/fields/controls/MultiSelectValueControl.tsx +52 -0
- package/corpus/templates/tasks/app/components/tasks/fields/controls/NumberValueControl.tsx +56 -0
- package/corpus/templates/tasks/app/components/tasks/fields/controls/RichTextValueControl.tsx +115 -0
- package/corpus/templates/tasks/app/components/tasks/fields/controls/SingleSelectValueControl.tsx +61 -0
- package/corpus/templates/tasks/app/components/tasks/fields/controls/TextValueControl.tsx +20 -0
- package/corpus/templates/tasks/app/components/tasks/use-task-row-completion-animation.ts +181 -0
- package/corpus/templates/tasks/app/components/ui/accordion.tsx +56 -0
- package/corpus/templates/tasks/app/components/ui/alert-dialog.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/alert.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/aspect-ratio.tsx +5 -0
- package/corpus/templates/tasks/app/components/ui/avatar.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/badge.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/breadcrumb.tsx +115 -0
- package/corpus/templates/tasks/app/components/ui/button.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/calendar.tsx +70 -0
- package/corpus/templates/tasks/app/components/ui/card.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/carousel.tsx +260 -0
- package/corpus/templates/tasks/app/components/ui/chart.tsx +379 -0
- package/corpus/templates/tasks/app/components/ui/checkbox.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/collapsible.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/command.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/context-menu.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/dialog.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/drawer.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/dropdown-menu.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/form.tsx +177 -0
- package/corpus/templates/tasks/app/components/ui/hover-card.tsx +27 -0
- package/corpus/templates/tasks/app/components/ui/input-otp.tsx +69 -0
- package/corpus/templates/tasks/app/components/ui/input.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/label.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/menubar.tsx +254 -0
- package/corpus/templates/tasks/app/components/ui/navigation-menu.tsx +128 -0
- package/corpus/templates/tasks/app/components/ui/pagination.tsx +121 -0
- package/corpus/templates/tasks/app/components/ui/popover.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/progress.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/radio-group.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/resizable.tsx +43 -0
- package/corpus/templates/tasks/app/components/ui/scroll-area.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/select.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/separator.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/sheet.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/sidebar.tsx +782 -0
- package/corpus/templates/tasks/app/components/ui/skeleton.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/slider.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/sonner.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/spinner.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/switch.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/table.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/tabs.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/textarea.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/toast.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/toaster.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/toggle-group.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/toggle.tsx +43 -0
- package/corpus/templates/tasks/app/components/ui/tooltip.tsx +1 -0
- package/corpus/templates/tasks/app/components/ui/use-toast.ts +3 -0
- package/corpus/templates/tasks/app/entry.client.tsx +19 -0
- package/corpus/templates/tasks/app/entry.server.tsx +10 -0
- package/corpus/templates/tasks/app/global.css +93 -0
- package/corpus/templates/tasks/app/hooks/cache.ts +31 -0
- package/corpus/templates/tasks/app/hooks/use-custom-fields.ts +93 -0
- package/corpus/templates/tasks/app/hooks/use-inbox-items.ts +196 -0
- package/corpus/templates/tasks/app/hooks/use-mobile.tsx +21 -0
- package/corpus/templates/tasks/app/hooks/use-navigation-state.ts +40 -0
- package/corpus/templates/tasks/app/hooks/use-tasks.ts +276 -0
- package/corpus/templates/tasks/app/hooks/use-toast.ts +188 -0
- package/corpus/templates/tasks/app/hooks/use-visible-task-fields.ts +140 -0
- package/corpus/templates/tasks/app/lib/app-config.ts +11 -0
- package/corpus/templates/tasks/app/lib/tab-id.ts +1 -0
- package/corpus/templates/tasks/app/lib/utils.ts +1 -0
- package/corpus/templates/tasks/app/root.tsx +130 -0
- package/corpus/templates/tasks/app/routes/_index.tsx +22 -0
- package/corpus/templates/tasks/app/routes/extensions.$id.$slug.tsx +2 -0
- package/corpus/templates/tasks/app/routes/extensions.$id.tsx +11 -0
- package/corpus/templates/tasks/app/routes/extensions._index.tsx +11 -0
- package/corpus/templates/tasks/app/routes/extensions.tsx +5 -0
- package/corpus/templates/tasks/app/routes/fields.tsx +16 -0
- package/corpus/templates/tasks/app/routes/inbox.tsx +16 -0
- package/corpus/templates/tasks/app/routes/tasks.tsx +17 -0
- package/corpus/templates/tasks/app/routes/team.tsx +17 -0
- package/corpus/templates/tasks/app/routes.ts +4 -0
- package/corpus/templates/tasks/app/vite-env.d.ts +6 -0
- package/corpus/templates/tasks/components.json +20 -0
- package/corpus/templates/tasks/data/sync-config.json +1 -0
- package/corpus/templates/tasks/docs/features/README.md +81 -0
- package/corpus/templates/tasks/docs/features/f1-tasks.mdx +67 -0
- package/corpus/templates/tasks/docs/features/f2-custom-fields.mdx +68 -0
- package/corpus/templates/tasks/docs/features/f3-projects.mdx +33 -0
- package/corpus/templates/tasks/docs/features/f4-inbox.mdx +55 -0
- package/corpus/templates/tasks/docs/features/f5-views.mdx +65 -0
- package/corpus/templates/tasks/docs/features/f6-search.mdx +43 -0
- package/corpus/templates/tasks/docs/features/f7-first-run.mdx +66 -0
- package/corpus/templates/tasks/docs/features/f8-chat.mdx +120 -0
- package/corpus/templates/tasks/e2e/global-setup.ts +42 -0
- package/corpus/templates/tasks/e2e/helpers/inbox.ts +71 -0
- package/corpus/templates/tasks/e2e/helpers/tasks.ts +99 -0
- package/corpus/templates/tasks/learnings.defaults.md +5 -0
- package/corpus/templates/tasks/netlify.toml +10 -0
- package/corpus/templates/tasks/package.json +104 -0
- package/corpus/templates/tasks/playwright.config.ts +34 -0
- package/corpus/templates/tasks/public/agent-native-icon-dark.svg +10 -0
- package/corpus/templates/tasks/public/agent-native-icon-light.svg +10 -0
- package/corpus/templates/tasks/public/agent-native-logo-dark.svg +21 -0
- package/corpus/templates/tasks/public/agent-native-logo-light.svg +21 -0
- package/corpus/templates/tasks/public/favicon.svg +1 -0
- package/corpus/templates/tasks/public/icon-180.svg +1 -0
- package/corpus/templates/tasks/public/icon-192.svg +1 -0
- package/corpus/templates/tasks/public/icon-512.svg +1 -0
- package/corpus/templates/tasks/public/manifest.json +21 -0
- package/corpus/templates/tasks/react-router.config.ts +7 -0
- package/corpus/templates/tasks/server/custom-fields/normalize.ts +163 -0
- package/corpus/templates/tasks/server/custom-fields/parse.ts +146 -0
- package/corpus/templates/tasks/server/custom-fields/schema.ts +147 -0
- package/corpus/templates/tasks/server/custom-fields/store.ts +425 -0
- package/corpus/templates/tasks/server/custom-fields/task-fields.ts +104 -0
- package/corpus/templates/tasks/server/custom-fields/types.ts +98 -0
- package/corpus/templates/tasks/server/custom-fields/validate.ts +210 -0
- package/corpus/templates/tasks/server/custom-fields/values/store.ts +386 -0
- package/corpus/templates/tasks/server/db/bulk-write.ts +30 -0
- package/corpus/templates/tasks/server/db/index.ts +5 -0
- package/corpus/templates/tasks/server/db/record-utils.ts +7 -0
- package/corpus/templates/tasks/server/db/schema.ts +67 -0
- package/corpus/templates/tasks/server/db/test-tasks-table.ts +76 -0
- package/corpus/templates/tasks/server/db/transaction.ts +6 -0
- package/corpus/templates/tasks/server/errors.ts +31 -0
- package/corpus/templates/tasks/server/inbox/store.ts +216 -0
- package/corpus/templates/tasks/server/middleware/auth.ts +15 -0
- package/corpus/templates/tasks/server/plugins/agent-chat.ts +46 -0
- package/corpus/templates/tasks/server/plugins/auth.ts +15 -0
- package/corpus/templates/tasks/server/plugins/db.ts +90 -0
- package/corpus/templates/tasks/server/routes/[...page].get.ts +5 -0
- package/corpus/templates/tasks/server/stored-items/store.ts +548 -0
- package/corpus/templates/tasks/server/tasks/store.ts +306 -0
- package/corpus/templates/tasks/server/user-config/store.ts +138 -0
- package/corpus/templates/tasks/shared/app-state-tabs.ts +15 -0
- package/corpus/templates/tasks/shared/boolean-param.ts +22 -0
- package/corpus/templates/tasks/shared/bulk-limits.ts +7 -0
- package/corpus/templates/tasks/shared/list-screen-snapshot.ts +90 -0
- package/corpus/templates/tasks/shared/navigation.ts +104 -0
- package/corpus/templates/tasks/shared/visible-task-fields.ts +2 -0
- package/corpus/templates/tasks/ssr-entry.ts +15 -0
- package/corpus/templates/tasks/tsconfig.json +24 -0
- package/corpus/templates/tasks/vite.config.ts +19 -0
- package/corpus/templates/tasks/vitest.config.ts +8 -0
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +13 -0
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/client/agent-page/AgentTabsPage.js +1 -1
- package/dist/client/agent-page/AgentTabsPage.js.map +1 -1
- package/dist/client/org/OrgSwitcher.d.ts.map +1 -1
- package/dist/client/org/OrgSwitcher.js +2 -1
- package/dist/client/org/OrgSwitcher.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/routes.d.ts +5 -5
- package/dist/resources/handlers.d.ts +3 -3
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { useActionMutation, useActionQuery } from "@agent-native/core/client";
|
|
2
|
+
import { useQueryClient, type QueryClient } from "@tanstack/react-query";
|
|
3
|
+
|
|
4
|
+
import type { TaskFieldValue } from "../../server/custom-fields/task-fields.js";
|
|
5
|
+
import type { FieldValue } from "../../server/custom-fields/values/store.js";
|
|
6
|
+
import type { Task } from "../../server/tasks/store.js";
|
|
7
|
+
import { LIST_TASKS_QUERY_KEY, invalidateTasks } from "./cache";
|
|
8
|
+
|
|
9
|
+
export type { Task } from "../../server/tasks/store.js";
|
|
10
|
+
export { LIST_TASKS_QUERY_KEY };
|
|
11
|
+
|
|
12
|
+
export type TaskWithFields = Task & { fields?: TaskFieldValue[] };
|
|
13
|
+
|
|
14
|
+
type ListTasksData = { tasks: TaskWithFields[]; hasCompletedTasks?: boolean };
|
|
15
|
+
|
|
16
|
+
type ListTasksMutationContext = {
|
|
17
|
+
previous: [readonly unknown[], ListTasksData | undefined][];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function patchListTasksCache(
|
|
21
|
+
queryClient: QueryClient,
|
|
22
|
+
patch: (tasks: TaskWithFields[]) => TaskWithFields[],
|
|
23
|
+
) {
|
|
24
|
+
queryClient.setQueriesData<ListTasksData>(
|
|
25
|
+
{ queryKey: LIST_TASKS_QUERY_KEY },
|
|
26
|
+
(old) => {
|
|
27
|
+
if (!old?.tasks) return old;
|
|
28
|
+
return { ...old, tasks: patch(old.tasks) };
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function snapshotListTasksQueries(queryClient: QueryClient) {
|
|
34
|
+
return queryClient.getQueriesData<ListTasksData>({
|
|
35
|
+
queryKey: LIST_TASKS_QUERY_KEY,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function restoreListTasksQueries(
|
|
40
|
+
queryClient: QueryClient,
|
|
41
|
+
previous: ListTasksMutationContext["previous"],
|
|
42
|
+
) {
|
|
43
|
+
for (const [key, data] of previous) {
|
|
44
|
+
queryClient.setQueryData(key, data);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getPreviousListTasksQueries(
|
|
49
|
+
context: unknown,
|
|
50
|
+
): ListTasksMutationContext["previous"] {
|
|
51
|
+
if (
|
|
52
|
+
context &&
|
|
53
|
+
typeof context === "object" &&
|
|
54
|
+
"previous" in context &&
|
|
55
|
+
Array.isArray(context.previous)
|
|
56
|
+
) {
|
|
57
|
+
return context.previous;
|
|
58
|
+
}
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function beginListTasksOptimisticUpdate(
|
|
63
|
+
queryClient: QueryClient,
|
|
64
|
+
patch: (tasks: TaskWithFields[]) => TaskWithFields[],
|
|
65
|
+
) {
|
|
66
|
+
await queryClient.cancelQueries({ queryKey: LIST_TASKS_QUERY_KEY });
|
|
67
|
+
const previous = snapshotListTasksQueries(queryClient);
|
|
68
|
+
patchListTasksCache(queryClient, patch);
|
|
69
|
+
return { previous };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function listTasksOptimisticLifecycle(queryClient: QueryClient) {
|
|
73
|
+
return {
|
|
74
|
+
onError: (_error: unknown, _variables: unknown, context: unknown) => {
|
|
75
|
+
restoreListTasksQueries(
|
|
76
|
+
queryClient,
|
|
77
|
+
getPreviousListTasksQueries(context),
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
onSettled: () => {
|
|
81
|
+
queryClient.invalidateQueries({ queryKey: LIST_TASKS_QUERY_KEY });
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function makeOptimisticTask(title: string, tasks: TaskWithFields[]): Task {
|
|
87
|
+
const now = new Date().toISOString();
|
|
88
|
+
const minSortOrder = Math.min(0, ...tasks.map((task) => task.sortOrder));
|
|
89
|
+
return {
|
|
90
|
+
id: `optimistic-${crypto.randomUUID()}`,
|
|
91
|
+
title,
|
|
92
|
+
done: false,
|
|
93
|
+
sortOrder: minSortOrder - 1000,
|
|
94
|
+
ownerEmail: "",
|
|
95
|
+
createdAt: now,
|
|
96
|
+
updatedAt: now,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function getOptimisticTaskId(context: unknown) {
|
|
101
|
+
if (
|
|
102
|
+
context &&
|
|
103
|
+
typeof context === "object" &&
|
|
104
|
+
"optimisticId" in context &&
|
|
105
|
+
typeof context.optimisticId === "string"
|
|
106
|
+
) {
|
|
107
|
+
return context.optimisticId;
|
|
108
|
+
}
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function useTasks(opts?: {
|
|
113
|
+
includeDone?: boolean;
|
|
114
|
+
includeFields?: boolean;
|
|
115
|
+
}) {
|
|
116
|
+
// Omit false so GET query params are not serialized as the string "false".
|
|
117
|
+
const params = {
|
|
118
|
+
...(opts?.includeDone ? { includeDone: true } : {}),
|
|
119
|
+
...(opts?.includeFields ? { includeFields: true } : {}),
|
|
120
|
+
};
|
|
121
|
+
const query = useActionQuery("list-tasks", params);
|
|
122
|
+
const listData = query.data as ListTasksData | undefined;
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
...query,
|
|
126
|
+
tasks: listData?.tasks ?? [],
|
|
127
|
+
hasCompletedTasks: listData?.hasCompletedTasks ?? false,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function useCreateTask() {
|
|
132
|
+
const queryClient = useQueryClient();
|
|
133
|
+
return useActionMutation<Task, { title: string }>("create-task", {
|
|
134
|
+
onMutate: async ({ title }) => {
|
|
135
|
+
const existing =
|
|
136
|
+
queryClient
|
|
137
|
+
.getQueriesData<ListTasksData>({ queryKey: LIST_TASKS_QUERY_KEY })
|
|
138
|
+
.find(([, data]) => data?.tasks)?.[1]?.tasks ?? [];
|
|
139
|
+
const optimisticTask = makeOptimisticTask(title, existing);
|
|
140
|
+
const context = await beginListTasksOptimisticUpdate(
|
|
141
|
+
queryClient,
|
|
142
|
+
(tasks) => [optimisticTask, ...tasks],
|
|
143
|
+
);
|
|
144
|
+
return { ...context, optimisticId: optimisticTask.id };
|
|
145
|
+
},
|
|
146
|
+
onSuccess: (created, _variables, context) => {
|
|
147
|
+
const optimisticId = getOptimisticTaskId(context);
|
|
148
|
+
patchListTasksCache(queryClient, (tasks) =>
|
|
149
|
+
tasks.map((task) =>
|
|
150
|
+
optimisticId && task.id === optimisticId ? created : task,
|
|
151
|
+
),
|
|
152
|
+
);
|
|
153
|
+
},
|
|
154
|
+
...listTasksOptimisticLifecycle(queryClient),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function useUpdateTask() {
|
|
159
|
+
const queryClient = useQueryClient();
|
|
160
|
+
return useActionMutation<
|
|
161
|
+
TaskWithFields,
|
|
162
|
+
{
|
|
163
|
+
taskId: string;
|
|
164
|
+
title?: string;
|
|
165
|
+
done?: boolean;
|
|
166
|
+
fieldValues?: Array<{ fieldId: string; value: FieldValue | null }>;
|
|
167
|
+
}
|
|
168
|
+
>("update-task", {
|
|
169
|
+
onMutate: async ({ taskId, title, done, fieldValues }) => {
|
|
170
|
+
const timestamp = new Date().toISOString();
|
|
171
|
+
return beginListTasksOptimisticUpdate(queryClient, (tasks) =>
|
|
172
|
+
tasks.map((task) =>
|
|
173
|
+
task.id === taskId
|
|
174
|
+
? {
|
|
175
|
+
...task,
|
|
176
|
+
...(title !== undefined ? { title } : {}),
|
|
177
|
+
...(done !== undefined ? { done } : {}),
|
|
178
|
+
...(fieldValues && task.fields
|
|
179
|
+
? {
|
|
180
|
+
fields: task.fields.map((field) => {
|
|
181
|
+
const next = fieldValues.find(
|
|
182
|
+
(value) => value.fieldId === field.id,
|
|
183
|
+
);
|
|
184
|
+
return next ? { ...field, value: next.value } : field;
|
|
185
|
+
}),
|
|
186
|
+
}
|
|
187
|
+
: {}),
|
|
188
|
+
updatedAt: timestamp,
|
|
189
|
+
}
|
|
190
|
+
: task,
|
|
191
|
+
),
|
|
192
|
+
);
|
|
193
|
+
},
|
|
194
|
+
onSuccess: (updated) => {
|
|
195
|
+
patchListTasksCache(queryClient, (tasks) =>
|
|
196
|
+
tasks.map((task) =>
|
|
197
|
+
task.id === updated.id
|
|
198
|
+
? { ...task, ...updated, fields: updated.fields ?? task.fields }
|
|
199
|
+
: task,
|
|
200
|
+
),
|
|
201
|
+
);
|
|
202
|
+
},
|
|
203
|
+
...listTasksOptimisticLifecycle(queryClient),
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function useDeleteTask() {
|
|
208
|
+
const queryClient = useQueryClient();
|
|
209
|
+
return useActionMutation<{ ok: true }, { taskId: string }>("delete-task", {
|
|
210
|
+
onMutate: async ({ taskId }) =>
|
|
211
|
+
beginListTasksOptimisticUpdate(queryClient, (tasks) =>
|
|
212
|
+
tasks.filter((task) => task.id !== taskId),
|
|
213
|
+
),
|
|
214
|
+
...listTasksOptimisticLifecycle(queryClient),
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export function useBulkUpdateTasks() {
|
|
219
|
+
const queryClient = useQueryClient();
|
|
220
|
+
return useActionMutation<
|
|
221
|
+
{ tasks: Task[] },
|
|
222
|
+
{ taskIds: string[]; title?: string; done?: boolean }
|
|
223
|
+
>("bulk-update-tasks", {
|
|
224
|
+
onMutate: async ({ taskIds, title, done }) => {
|
|
225
|
+
const selected = new Set(taskIds);
|
|
226
|
+
const timestamp = new Date().toISOString();
|
|
227
|
+
return beginListTasksOptimisticUpdate(queryClient, (tasks) =>
|
|
228
|
+
tasks.map((task) =>
|
|
229
|
+
selected.has(task.id)
|
|
230
|
+
? {
|
|
231
|
+
...task,
|
|
232
|
+
...(title !== undefined ? { title } : {}),
|
|
233
|
+
...(done !== undefined ? { done } : {}),
|
|
234
|
+
updatedAt: timestamp,
|
|
235
|
+
}
|
|
236
|
+
: task,
|
|
237
|
+
),
|
|
238
|
+
);
|
|
239
|
+
},
|
|
240
|
+
onSuccess: ({ tasks: updatedTasks }) => {
|
|
241
|
+
const byId = new Map(updatedTasks.map((task) => [task.id, task]));
|
|
242
|
+
patchListTasksCache(queryClient, (tasks) =>
|
|
243
|
+
tasks.map((task) => {
|
|
244
|
+
const updated = byId.get(task.id);
|
|
245
|
+
return updated ? { ...task, ...updated, fields: task.fields } : task;
|
|
246
|
+
}),
|
|
247
|
+
);
|
|
248
|
+
},
|
|
249
|
+
...listTasksOptimisticLifecycle(queryClient),
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export function useBulkDeleteTasks() {
|
|
254
|
+
const queryClient = useQueryClient();
|
|
255
|
+
return useActionMutation<
|
|
256
|
+
{ ok: true; deleted: number },
|
|
257
|
+
{ taskIds: string[] }
|
|
258
|
+
>("bulk-delete-tasks", {
|
|
259
|
+
onMutate: async ({ taskIds }) => {
|
|
260
|
+
const selected = new Set(taskIds);
|
|
261
|
+
return beginListTasksOptimisticUpdate(queryClient, (tasks) =>
|
|
262
|
+
tasks.filter((task) => !selected.has(task.id)),
|
|
263
|
+
);
|
|
264
|
+
},
|
|
265
|
+
...listTasksOptimisticLifecycle(queryClient),
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function useReorderTasks() {
|
|
270
|
+
const queryClient = useQueryClient();
|
|
271
|
+
return useActionMutation("reorder-tasks", {
|
|
272
|
+
onSettled: () => {
|
|
273
|
+
invalidateTasks(queryClient);
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import type { ToastActionElement, ToastProps } from "@/components/ui/toast";
|
|
4
|
+
|
|
5
|
+
const TOAST_LIMIT = 1;
|
|
6
|
+
const TOAST_REMOVE_DELAY = 1000000;
|
|
7
|
+
|
|
8
|
+
type ToasterToast = ToastProps & {
|
|
9
|
+
id: string;
|
|
10
|
+
title?: React.ReactNode;
|
|
11
|
+
description?: React.ReactNode;
|
|
12
|
+
action?: ToastActionElement;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const actionTypes = {
|
|
16
|
+
ADD_TOAST: "ADD_TOAST",
|
|
17
|
+
UPDATE_TOAST: "UPDATE_TOAST",
|
|
18
|
+
DISMISS_TOAST: "DISMISS_TOAST",
|
|
19
|
+
REMOVE_TOAST: "REMOVE_TOAST",
|
|
20
|
+
} as const;
|
|
21
|
+
|
|
22
|
+
let count = 0;
|
|
23
|
+
|
|
24
|
+
function genId() {
|
|
25
|
+
count = (count + 1) % Number.MAX_SAFE_INTEGER;
|
|
26
|
+
return count.toString();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type ActionType = typeof actionTypes;
|
|
30
|
+
|
|
31
|
+
type Action =
|
|
32
|
+
| {
|
|
33
|
+
type: ActionType["ADD_TOAST"];
|
|
34
|
+
toast: ToasterToast;
|
|
35
|
+
}
|
|
36
|
+
| {
|
|
37
|
+
type: ActionType["UPDATE_TOAST"];
|
|
38
|
+
toast: Partial<ToasterToast>;
|
|
39
|
+
}
|
|
40
|
+
| {
|
|
41
|
+
type: ActionType["DISMISS_TOAST"];
|
|
42
|
+
toastId?: ToasterToast["id"];
|
|
43
|
+
}
|
|
44
|
+
| {
|
|
45
|
+
type: ActionType["REMOVE_TOAST"];
|
|
46
|
+
toastId?: ToasterToast["id"];
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
interface State {
|
|
50
|
+
toasts: ToasterToast[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>();
|
|
54
|
+
|
|
55
|
+
const addToRemoveQueue = (toastId: string) => {
|
|
56
|
+
if (toastTimeouts.has(toastId)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const timeout = setTimeout(() => {
|
|
61
|
+
toastTimeouts.delete(toastId);
|
|
62
|
+
dispatch({
|
|
63
|
+
type: "REMOVE_TOAST",
|
|
64
|
+
toastId: toastId,
|
|
65
|
+
});
|
|
66
|
+
}, TOAST_REMOVE_DELAY);
|
|
67
|
+
|
|
68
|
+
toastTimeouts.set(toastId, timeout);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const reducer = (state: State, action: Action): State => {
|
|
72
|
+
switch (action.type) {
|
|
73
|
+
case "ADD_TOAST":
|
|
74
|
+
return {
|
|
75
|
+
...state,
|
|
76
|
+
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
case "UPDATE_TOAST":
|
|
80
|
+
return {
|
|
81
|
+
...state,
|
|
82
|
+
toasts: state.toasts.map((t) =>
|
|
83
|
+
t.id === action.toast.id ? { ...t, ...action.toast } : t,
|
|
84
|
+
),
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
case "DISMISS_TOAST": {
|
|
88
|
+
const { toastId } = action;
|
|
89
|
+
|
|
90
|
+
// ! Side effects ! - This could be extracted into a dismissToast() action,
|
|
91
|
+
// but I'll keep it here for simplicity
|
|
92
|
+
if (toastId) {
|
|
93
|
+
addToRemoveQueue(toastId);
|
|
94
|
+
} else {
|
|
95
|
+
state.toasts.forEach((toast) => {
|
|
96
|
+
addToRemoveQueue(toast.id);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
...state,
|
|
102
|
+
toasts: state.toasts.map((t) =>
|
|
103
|
+
t.id === toastId || toastId === undefined
|
|
104
|
+
? {
|
|
105
|
+
...t,
|
|
106
|
+
open: false,
|
|
107
|
+
}
|
|
108
|
+
: t,
|
|
109
|
+
),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
case "REMOVE_TOAST":
|
|
113
|
+
if (action.toastId === undefined) {
|
|
114
|
+
return {
|
|
115
|
+
...state,
|
|
116
|
+
toasts: [],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
...state,
|
|
121
|
+
toasts: state.toasts.filter((t) => t.id !== action.toastId),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const listeners: Array<(state: State) => void> = [];
|
|
127
|
+
|
|
128
|
+
let memoryState: State = { toasts: [] };
|
|
129
|
+
|
|
130
|
+
function dispatch(action: Action) {
|
|
131
|
+
memoryState = reducer(memoryState, action);
|
|
132
|
+
listeners.forEach((listener) => {
|
|
133
|
+
listener(memoryState);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
type Toast = Omit<ToasterToast, "id">;
|
|
138
|
+
|
|
139
|
+
function toast({ ...props }: Toast) {
|
|
140
|
+
const id = genId();
|
|
141
|
+
|
|
142
|
+
const update = (props: ToasterToast) =>
|
|
143
|
+
dispatch({
|
|
144
|
+
type: "UPDATE_TOAST",
|
|
145
|
+
toast: { ...props, id },
|
|
146
|
+
});
|
|
147
|
+
const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
|
|
148
|
+
|
|
149
|
+
dispatch({
|
|
150
|
+
type: "ADD_TOAST",
|
|
151
|
+
toast: {
|
|
152
|
+
...props,
|
|
153
|
+
id,
|
|
154
|
+
open: true,
|
|
155
|
+
onOpenChange: (open) => {
|
|
156
|
+
if (!open) dismiss();
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
id: id,
|
|
163
|
+
dismiss,
|
|
164
|
+
update,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function useToast() {
|
|
169
|
+
const [state, setState] = React.useState<State>(memoryState);
|
|
170
|
+
|
|
171
|
+
React.useEffect(() => {
|
|
172
|
+
listeners.push(setState);
|
|
173
|
+
return () => {
|
|
174
|
+
const index = listeners.indexOf(setState);
|
|
175
|
+
if (index > -1) {
|
|
176
|
+
listeners.splice(index, 1);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
}, [state]);
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
...state,
|
|
183
|
+
toast,
|
|
184
|
+
dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export { useToast, toast };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { useActionMutation, useActionQuery } from "@agent-native/core/client";
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_TASK_CARD_FIELD_NAMES,
|
|
4
|
+
TASK_CARD_FIELD_LIMIT,
|
|
5
|
+
} from "@shared/visible-task-fields";
|
|
6
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
7
|
+
import { useEffect, useRef } from "react";
|
|
8
|
+
|
|
9
|
+
import type { FieldDefinition } from "@/hooks/use-custom-fields";
|
|
10
|
+
import { useCustomFields } from "@/hooks/use-custom-fields";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
invalidateVisibleTaskFields,
|
|
14
|
+
LIST_VISIBLE_TASK_FIELDS_QUERY_KEY,
|
|
15
|
+
} from "./cache";
|
|
16
|
+
|
|
17
|
+
export { DEFAULT_TASK_CARD_FIELD_NAMES, TASK_CARD_FIELD_LIMIT };
|
|
18
|
+
|
|
19
|
+
const TASK_CARD_FIELD_NAMES_KEY = "task-card-field-names";
|
|
20
|
+
const TASK_CARD_FIELD_IDS_KEY = "task-card-field-ids";
|
|
21
|
+
|
|
22
|
+
function readStringArray(key: string, limit: number) {
|
|
23
|
+
if (typeof window === "undefined") return [];
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const stored = window.localStorage.getItem(key);
|
|
27
|
+
if (!stored) return [];
|
|
28
|
+
const parsed = JSON.parse(stored);
|
|
29
|
+
if (!Array.isArray(parsed)) return [];
|
|
30
|
+
return parsed
|
|
31
|
+
.filter((value): value is string => typeof value === "string")
|
|
32
|
+
.slice(0, limit);
|
|
33
|
+
} catch {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function fieldIdsForNames(
|
|
39
|
+
fieldNames: readonly string[],
|
|
40
|
+
fields: readonly FieldDefinition[],
|
|
41
|
+
limit: number,
|
|
42
|
+
) {
|
|
43
|
+
const fieldsByName = new Map(
|
|
44
|
+
fields.map((field) => [field.title.toLowerCase(), field.id]),
|
|
45
|
+
);
|
|
46
|
+
return fieldNames
|
|
47
|
+
.map((name) => fieldsByName.get(name.toLowerCase()))
|
|
48
|
+
.filter((id): id is string => Boolean(id))
|
|
49
|
+
.slice(0, limit);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function readLegacyLocalStorageFieldIds(
|
|
53
|
+
fields: readonly FieldDefinition[],
|
|
54
|
+
limit: number,
|
|
55
|
+
) {
|
|
56
|
+
const storedIds = readStringArray(TASK_CARD_FIELD_IDS_KEY, limit);
|
|
57
|
+
if (storedIds.length > 0) {
|
|
58
|
+
if (fields.length === 0) return [];
|
|
59
|
+
const knownIds = new Set(fields.map((field) => field.id));
|
|
60
|
+
return storedIds.filter((fieldId) => knownIds.has(fieldId));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (fields.length === 0) return [];
|
|
64
|
+
|
|
65
|
+
return fieldIdsForNames(
|
|
66
|
+
readStringArray(TASK_CARD_FIELD_NAMES_KEY, limit),
|
|
67
|
+
fields,
|
|
68
|
+
limit,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function clearLegacyLocalStorage() {
|
|
73
|
+
if (typeof window === "undefined") return;
|
|
74
|
+
window.localStorage.removeItem(TASK_CARD_FIELD_IDS_KEY);
|
|
75
|
+
window.localStorage.removeItem(TASK_CARD_FIELD_NAMES_KEY);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
type ListVisibleTaskFieldsData = { fieldIds: string[] };
|
|
79
|
+
|
|
80
|
+
export function useVisibleTaskFieldIds() {
|
|
81
|
+
const query = useActionQuery("list-visible-task-fields", {});
|
|
82
|
+
const { fields } = useCustomFields();
|
|
83
|
+
const updateVisibleTaskFields = useUpdateVisibleTaskFields();
|
|
84
|
+
const migratedRef = useRef(false);
|
|
85
|
+
const listData = query.data as ListVisibleTaskFieldsData | undefined;
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (migratedRef.current || query.isPending || !query.isSuccess) return;
|
|
89
|
+
|
|
90
|
+
const hasLegacyIds =
|
|
91
|
+
readStringArray(TASK_CARD_FIELD_IDS_KEY, TASK_CARD_FIELD_LIMIT).length >
|
|
92
|
+
0;
|
|
93
|
+
const hasLegacyNames =
|
|
94
|
+
readStringArray(TASK_CARD_FIELD_NAMES_KEY, TASK_CARD_FIELD_LIMIT).length >
|
|
95
|
+
0;
|
|
96
|
+
if (!hasLegacyIds && !hasLegacyNames) {
|
|
97
|
+
migratedRef.current = true;
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (fields.length === 0) return;
|
|
102
|
+
|
|
103
|
+
const legacyFieldIds = readLegacyLocalStorageFieldIds(
|
|
104
|
+
fields,
|
|
105
|
+
TASK_CARD_FIELD_LIMIT,
|
|
106
|
+
);
|
|
107
|
+
if (legacyFieldIds.length === 0) {
|
|
108
|
+
migratedRef.current = true;
|
|
109
|
+
clearLegacyLocalStorage();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
void updateVisibleTaskFields
|
|
114
|
+
.mutateAsync({ fieldIds: legacyFieldIds })
|
|
115
|
+
.then(() => {
|
|
116
|
+
clearLegacyLocalStorage();
|
|
117
|
+
migratedRef.current = true;
|
|
118
|
+
})
|
|
119
|
+
.catch(() => {
|
|
120
|
+
// Keep localStorage so a later retry can migrate the saved selection.
|
|
121
|
+
});
|
|
122
|
+
}, [fields, query.isPending, query.isSuccess, updateVisibleTaskFields]);
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
...query,
|
|
126
|
+
fieldIds: listData?.fieldIds ?? [],
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function useUpdateVisibleTaskFields() {
|
|
131
|
+
const queryClient = useQueryClient();
|
|
132
|
+
return useActionMutation<{ fieldIds: string[] }, { fieldIds: string[] }>(
|
|
133
|
+
"update-visible-task-fields",
|
|
134
|
+
{
|
|
135
|
+
onSettled: () => {
|
|
136
|
+
invalidateVisibleTaskFields(queryClient);
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
);
|
|
140
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const rawAppName = "tasks";
|
|
2
|
+
const rawAppTitle = "Tasks";
|
|
3
|
+
|
|
4
|
+
const APP_NAME_PLACEHOLDER = "{" + "{APP_NAME}}";
|
|
5
|
+
const APP_TITLE_PLACEHOLDER = "{" + "{APP_TITLE}}";
|
|
6
|
+
|
|
7
|
+
export const APP_NAME =
|
|
8
|
+
rawAppName === APP_NAME_PLACEHOLDER ? "tasks" : rawAppName;
|
|
9
|
+
|
|
10
|
+
export const APP_TITLE =
|
|
11
|
+
rawAppTitle === APP_TITLE_PLACEHOLDER ? "Tasks" : rawAppTitle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const TAB_ID = Math.random().toString(36).slice(2, 10);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { cn } from "@agent-native/core/client";
|