Skip to content

Add shared scripts functionality with allowedUsers access control#43

Open
coreyloftus wants to merge 5 commits intodevfrom
feat/shared-projects-2026-01-19
Open

Add shared scripts functionality with allowedUsers access control#43
coreyloftus wants to merge 5 commits intodevfrom
feat/shared-projects-2026-01-19

Conversation

@coreyloftus
Copy link
Copy Markdown
Owner

Summary

Implements a new "shared" data source that enables users to access scripts shared with them through the allowedUsers field in Firestore. This allows script sharing between users without making scripts fully public.

Changes

  • Backend (FirestoreService): Added getSharedScripts() method that queries the shared_projects collection and filters documents using Firestore's array-contains operator on the allowedUsers field
  • Backend (ScriptService): Added support for "shared" data source in all script-related methods (getScripts, getScenes, getCharacters, getLines)
  • Backend (tRPC Router): Updated all procedures to include "shared" in data source enums with proper authentication checks
  • Frontend (Hooks): Updated useScriptData hook to support "shared" data source with authentication requirement
  • Frontend (Context): Updated UserConfig type to include "shared" option
  • Frontend (NewScriptSelect): Added query to fetch shared scripts and display them in the project dropdown alongside public and personal scripts

How It Works

When a user logs in, the app now:

  1. Queries the shared_projects Firestore collection
  2. Filters for documents where the allowedUsers array contains the user's email
  3. Displays these shared scripts in the project list (marked as "shared")
  4. Allows full access to run lines from shared scripts

Test Plan

  • User can see shared scripts in project dropdown after authentication
  • Shared scripts are properly filtered by user email
  • Scenes and characters load correctly from shared scripts
  • Line running works properly with shared scripts
  • Non-authenticated users cannot access shared scripts

🤖 Generated with Claude Code

Implements a new "shared" data source that allows users to access scripts
shared with them via the allowedUsers field in Firestore. Scripts in the
shared_projects collection are filtered by user email and displayed
alongside public and personal scripts.

- Add getSharedScripts method to FirestoreService with array-contains query
- Update ScriptService to support "shared" data source
- Update tRPC router procedures to include "shared" in data source enum
- Update frontend hooks and context to support shared scripts
- Update NewScriptSelect to fetch and display shared projects

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Jan 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
linerunner Error Error Jan 19, 2026 8:52pm

… components

The shared scripts functionality was missing from ScriptViewer, ScriptBox, and
ScriptData components, causing them to fail to load character data for shared
projects. Added shared data source queries to all components that display scripts.

- Add sharedData query to ScriptViewer
- Add sharedData query to ScriptBox
- Add sharedData query to ScriptData
- Update getCurrentData() in all components to check for shared projects

Fixes issue where selecting a shared project showed "undefined" for all character names.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The shared_projects collection was using the old data format where each line
has a 'characters' array instead of a 'character' string. This caused
"undefined" to appear in the script viewer and empty character dropdowns.

Added data normalization in getSharedScripts() to convert the old format:
- characters: ["Baker"] -> character: "Baker"
- Takes first character from array if multiple exist
- Preserves all other line properties

Added debug logging to help diagnose data structure issues.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added detailed console logs to trace the data from Firestore through the
backend services to the frontend components. This will help diagnose the
undefined character issue.

Logging added to:
- FirestoreService.getSharedScripts (already had some)
- ScriptService.getSharedScripts (new)
- NewScriptSelect component (new)
- getCharacterData function (new)

Each log shows the data structure at that point in the flow.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The previous normalization was adding the new 'character' field but keeping
the old 'characters' array, causing the frontend to still see undefined
values when accessing line.character.

Updated to use destructuring to remove the old field:
- const { characters, ...rest } = line
- return { ...rest, character: characters[0] }

This ensures the normalized data only has 'character' (singular string) and
not 'characters' (plural array).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.

1 participant