Repository navigation
Conversation
1. **Database & Migrations**:
- Replaced single `projectId` and `assistantId` foreign keys with PostgreSQL text arrays `projectIds: text("project_ids").array().notNull().default(sql`'{}'::text[]`)` and `assistantIds: text("assistant_ids").array().notNull().default(sql`'{}'::text[]`)` in [`prompt-schema.ts`](./drizzle/schemas/prompt-schema.ts) and [`skill-schema.ts`](./drizzle/schemas/skill-schema.ts).
- Created migration [`0053_multi_scope_prompts_skills.sql`](./drizzle/migrations/0053_multi_scope_prompts_skills.sql) to backfill existing values into arrays and create GIN indexes.
2. **Validation & Server Actions**:
- Updated [`schemas/prompt/prompt.ts`](./schemas/prompt/prompt.ts) and [`schemas/skill/skill.ts`](./schemas/skill/skill.ts) to accept `projectIds: z.array(z.string()).default([])` and `assistantIds: z.array(z.string()).default([])`, removing legacy mutual exclusion.
- Updated ownership validation and mutation logic in [`actions/prompts/`](./actions/prompts/) and [`actions/skills/`](./actions/skills/).
- Updated runtime matching in [`load-chat-context.ts`](./lib/chat/load-chat-context.ts) and [`register-skill-tool.ts`](./lib/chat/register-skill-tool.ts) with `ANY(project_ids)` / `ANY(assistant_ids)` and cardinality checks for global availability.
3. **UI Components & UX**:
- [`EntityMultiSelect`](./components/shared/entity-multi-select.tsx): Shadcn Popover + Command multi-select with search, select/clear all, and removable badge chips.
- [`ScopeConfigurator`](./components/shared/scope-configurator.tsx): Two-mode selector ("Global" vs "Scoped") with concurrent multi-project and multi-assistant pickers and active item counters.
- Integrated into [`PromptScopeTab`](./components/prompt/prompt-scope-tab.tsx), [`PromptForm`](./components/prompt/prompt-form.tsx), [`SkillScopeTab`](./components/skill/skill-scope-tab.tsx), and [`CreateSkillForm`](./components/skill/create-skill-form.tsx).
- Updated [`PromptCard`](./components/prompt/prompt-card.tsx) and [`SkillCard`](./components/skill/skill-card.tsx) badges to display multi-project and multi-assistant assignment counts.
… not items themselves
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. High-Level Overview
Goal: Enable prompt shortcuts and agent skills to be scoped to multiple projects, multiple assistants, both simultaneously, or neither (global), replacing single-entity mutual exclusion with multi-entity array scoping and an intuitive Shadcn UI selector.
flowchart TD subgraph UI ["User Interface (Shadcn UI)"] Tab["Scope & Visibility Tab / Form"] Mode["Mode: Global vs. Scoped"] ProjSelect["Projects Multi-Select (Combobox / Popover + Badges)"] AsstSelect["Assistants Multi-Select (Combobox / Popover + Badges)"] end subgraph DataModel ["Data Model & Validation"] Zod["Zod Schemas: projectIds: string[], assistantIds: string[]"] Drizzle["Drizzle: project_ids text[], assistant_ids text[]"] end subgraph Runtime ["Execution & Scoping Context"] FilterPrompts["filterAccessiblePrompts(prompts, context)"] FilterSkills["filterAccessibleSkills(skills, context)"] ChatCtx["loadChatContext & registerSkillTool"] end Mode -->|"Global"| Zod Mode -->|"Scoped"| ProjSelect & AsstSelect ProjSelect & AsstSelect --> Zod Zod --> Drizzle Drizzle --> RuntimeGlobal Constraints
components/ui/; compose them into high-level features.assistantandprojectrather than introducing junction tables.2. User Review Required
Important
Database Migration: The single-column foreign keys
project_idandassistant_idon bothpromptandskilltables are replaced with PostgreSQL native array columnsproject_ids text[] DEFAULT '{}'::text[] NOT NULLandassistant_ids text[] DEFAULT '{}'::text[] NOT NULL. Existing rows with non-null values will be migrated into 1-element arrays before dropping the legacy columns.Note
Scope UI Concept:
The UI replaces the 3 mutually-exclusive radio buttons (
Global,Project,Assistant) with:3. Alternatives Evaluated
project_ids text[],assistant_ids text[])project.skill_ids,project.prompt_ids,assistant.skill_ids,assistant.prompt_ids. Zero joins needed. Instant client hydration into Zustand store. Minimal code changes.prompt_projects,prompt_assistants,skill_projects,skill_assistants)listPrompts,listSkills,loadChatContext), complex Drizzle relational mapping, much higher code bloat. Violates YAGNI.scopes: jsonb)4. Edge Cases & Failure Modes
filterAccessiblePrompts/filterAccessibleSkills./settings/prompts/new?projectId=123,projectIdsis initialized with['123'], and the user can easily add more projects or assistants.