Skip to content

Comments

Fix Collaborator Issue#15

Merged
DongDuong2001 merged 9 commits intomainfrom
fix/Collaborator
Jan 20, 2026
Merged

Fix Collaborator Issue#15
DongDuong2001 merged 9 commits intomainfrom
fix/Collaborator

Conversation

@DongDuong2001
Copy link
Collaborator

This pull request introduces a new API route for managing project collaborators, and refactors the dashboard's collaborators and projects pages to use these new API endpoints. The changes move collaborator management from client-side local storage and direct database calls to a more secure, server-side API approach. Additionally, the production deployment documentation for Ollama has been removed.

Collaborator Management API:

  • Added a new API route (app/api/projects/[id]/collaborators/route.ts) that provides GET, POST, and DELETE endpoints for listing, adding, and removing project collaborators, with authentication and authorization checks. (app/api/projects/[id]/collaborators/route.tsR1-R251)

Dashboard Refactors:

  • Refactored the collaborators dashboard page (app/dashboard/collaborators/page.tsx) to load, add, and remove collaborators using the new API endpoints instead of local storage and direct DB calls. This includes improved error handling and user feedback.
  • Updated the projects dashboard page (app/dashboard/projects/page.tsx) to add and remove collaborators via the new API endpoints, simplifying the logic and ensuring consistency with backend validation. [1] [2]

Documentation:

  • Removed the production deployment guide for Ollama (docs/PRODUCTION_DEPLOYMENT_OLLAMA.md), possibly to avoid outdated or unnecessary documentation.

Implements GET, POST, and DELETE handlers for managing project collaborators. Includes authentication, authorization, and error handling for listing, adding, and removing collaborators on a project.
Updated collaborator loading and removal functions to fetch and modify collaborator data via API endpoints instead of relying solely on localStorage. This improves data consistency and ensures that collaborator changes are reflected across all clients. Added error handling and user feedback for API operations.
Updated the logic for adding and removing project collaborators to use REST API endpoints instead of direct database calls. This simplifies the frontend code, improves error handling, and ensures collaborator lists are refreshed using API responses.
Deleted docs/PRODUCTION_DEPLOYMENT_OLLAMA.md, which contained instructions for deploying AI tools with Ollama in production. This may indicate a change in deployment strategy or documentation restructuring.
@DongDuong2001 DongDuong2001 self-assigned this Jan 19, 2026
@vercel
Copy link
Contributor

vercel bot commented Jan 19, 2026

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

Project Deployment Review Updated (UTC)
lab68dev-platform-1ds5 Ready Ready Preview, Comment Jan 19, 2026 3:50pm

Deleted the .github/FUNDING.yml file, removing the Buy Me a Coffee funding link from the repository.
Introduces a GitHub Actions workflow that runs linting, type checking, build, code formatting, and security audit on push and pull requests to the main branch. Ensures code quality and security by enforcing checks before merging.
Deleted docs/AI_TOOLS_SUMMARY.md and docs/PRODUCTION_DEPLOYMENT.md to clean up or relocate documentation related to AI tools and production deployment processes.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces a new server-side API for managing project collaborators and refactors dashboard pages to use these endpoints instead of direct database calls and local storage manipulation. The changes improve security, consistency, and maintainability. Additionally, several documentation files are removed and a GitHub Actions CI workflow is added.

Changes:

  • Added new /api/projects/[id]/collaborators API route with GET, POST, and DELETE methods for secure collaborator management with proper authentication and authorization
  • Refactored projects and collaborators dashboard pages to consume the new API endpoints instead of direct database operations
  • Removed outdated Ollama deployment documentation and AI tools summary files
  • Added comprehensive CI/CD workflow with linting, type-checking, building, formatting, and security scanning
  • Removed funding configuration file

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
app/api/projects/[id]/collaborators/route.ts New API route implementing secure collaborator management with authentication, authorization, and validation
app/dashboard/projects/page.tsx Refactored to use API endpoints for adding/removing collaborators instead of direct database calls
app/dashboard/collaborators/page.tsx Updated to fetch collaborator data from API endpoints with improved error handling
.github/workflows/ci.yml Added comprehensive CI workflow for automated quality checks
docs/PRODUCTION_DEPLOYMENT_OLLAMA.md Removed outdated deployment documentation
docs/PRODUCTION_DEPLOYMENT.md Removed general deployment documentation
docs/AI_TOOLS_SUMMARY.md Removed AI tools feature summary
.github/FUNDING.yml Removed funding configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

localStorage.setItem("lab68_projects", JSON.stringify(updatedProjects))
loadCollaborators()
// Reload collaborators
loadCollaborators()
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After successfully removing a collaborator from all projects, there is no success feedback shown to the user. Only failures show an alert. Consider adding a success message to confirm the operation completed.

Suggested change
loadCollaborators()
loadCollaborators()
alert('Collaborator removed from all projects.')

Copilot uses AI. Check for mistakes.
Comment on lines +170 to +171
// Reload collaborators
loadCollaborators()
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After successfully removing a collaborator from a project, there is no success feedback shown to the user. Only failures show an alert. Consider adding a success message to confirm the operation completed.

Copilot uses AI. Check for mistakes.
{ params }: { params: { id: string } }
) {
try {
const projectId = params.id
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The params object in Next.js 15+ App Router is now a Promise and should be awaited. The current synchronous access pattern may cause runtime errors in Next.js 15+. Update to use: const { id } = await params

Copilot uses AI. Check for mistakes.
alert("This user is already a collaborator.")
if (!response.ok) {
setError(data.error || "Failed to add collaborator")
alert(data.error || "Failed to add collaborator. Please try again.")
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loading state is not cleared when the API request fails. This causes the loading state to persist indefinitely on failure. Add 'setLoading(false)' in the error return paths before returning, or ensure it's handled in the finally block.

Suggested change
alert(data.error || "Failed to add collaborator. Please try again.")
alert(data.error || "Failed to add collaborator. Please try again.")
setLoading(false)

Copilot uses AI. Check for mistakes.
Comment on lines +279 to +280
const collaboratorsResponse = await fetch(`/api/projects/${selectedProject.id}/collaborators`)
const collaboratorsData = await collaboratorsResponse.json()
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error responses from the API are not checked before calling response.json(). If the response body is empty or malformed, this could throw an error. Consider wrapping the response.json() call in a try-catch or checking response.ok before parsing.

Copilot uses AI. Check for mistakes.
) {
try {
const projectId = params.id
const { email, role = "viewer" } = await request.json()
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The email input should be validated before use. Consider adding basic email format validation and trimming the email value consistently. Currently, trimming happens in getProfileByEmail but not in the initial validation, which could lead to inconsistent behavior.

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +11
{ params }: { params: { id: string } }
) {
try {
const projectId = params.id
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The params object in Next.js 15+ App Router is now a Promise and should be awaited. The current synchronous access pattern may cause runtime errors in Next.js 15+. Update to use: const { id } = await params

Suggested change
{ params }: { params: { id: string } }
) {
try {
const projectId = params.id
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id: projectId } = await params

Copilot uses AI. Check for mistakes.
{ params }: { params: { id: string } }
) {
try {
const projectId = params.id
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The params object in Next.js 15+ App Router is now a Promise and should be awaited. The current synchronous access pattern may cause runtime errors in Next.js 15+. Update to use: const { id } = await params

Copilot uses AI. Check for mistakes.
Comment on lines +321 to +324
if (!response.ok) {
alert(data.error || "Failed to remove collaborator")
return
}
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loading state is not cleared when errors occur in the early return paths. Add 'setLoading(false)' before the return statements or ensure the finally block is reached.

Copilot uses AI. Check for mistakes.
Comment on lines +330 to +331
const collaboratorsResponse = await fetch(`/api/projects/${selectedProject.id}/collaborators`)
const collaboratorsData = await collaboratorsResponse.json()
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error responses from the API are not checked before calling response.json(). If the response body is empty or malformed, this could throw an error. Consider wrapping the response.json() call in a try-catch or checking response.ok before parsing.

Copilot uses AI. Check for mistakes.
@DongDuong2001
Copy link
Collaborator Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Jan 19, 2026

@DongDuong2001 I've opened a new pull request, #16, to work on those changes. Once the pull request is ready, I'll request review from you.

Updates the CI workflow to allow lint, type check, and formatting steps to continue on error, making only the build step required for passing. This change provides more flexibility by surfacing issues without blocking the pipeline, and improves messaging for each check's result.
Corrected a typo in the step command from 'ruecho' to 'run' and removed emoji from status messages for consistency. Ensures proper execution and clearer output in the CI workflow.
@DongDuong2001 DongDuong2001 merged commit 6ceaefb into main Jan 20, 2026
4 of 8 checks passed
@DongDuong2001 DongDuong2001 deleted the fix/Collaborator branch January 22, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants