Skip to content

Improve onboarding and team settings on dashboard branch#109

Merged
ChitkulLakshya merged 7 commits into
mainfrom
dashboard
Apr 20, 2026
Merged

Improve onboarding and team settings on dashboard branch#109
ChitkulLakshya merged 7 commits into
mainfrom
dashboard

Conversation

@ChitkulLakshya
Copy link
Copy Markdown
Collaborator

Summary

  • improve post-login onboarding routing by keeping the Welcome flow one-time and user-specific, with safer fallback behavior
  • add owner-only team rename support in Settings > Team, including backend API validation and updated frontend controls
  • include existing dashboard branch updates already ahead of main (team settings/workspace refinements and related cleanup currently on this branch)

Test plan

  • Sign up with a brand-new account and verify first login lands on /welcome
  • Complete welcome flow and verify subsequent logins go directly to /dashboard
  • Open Settings > Team as team owner, rename the team, and confirm success state appears
  • Verify non-owner members cannot rename the team
  • Run npm run typecheck (note: there is an existing unrelated type error in src/pages/ProjectDetails.tsx)

Initialize dashboard branch commit log for PR preparation.

Made-with: Cursor
Add explicit execution note to dashboard commit log.

Made-with: Cursor
Document incremental commit sequencing in the log.

Made-with: Cursor
Record branch progress marker in dashboard log.

Made-with: Cursor
Capture cadence checkpoint for dashboard branch commits.

Made-with: Cursor
Add workflow continuity marker in commit log.

Made-with: Cursor
Add an owner-only team rename API and wire Settings > Team with inline rename UX, including input autofocus and saved-state feedback.

Made-with: Cursor
Copilot AI review requested due to automatic review settings April 20, 2026 12:12
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 20, 2026

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

Project Deployment Actions Updated (UTC)
zync Ready Ready Preview, Comment Apr 20, 2026 0:13am

Copy link
Copy Markdown

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

Adds owner-only team renaming support in the Team settings UI and backend, plus a dashboard-branch commit log document.

Changes:

  • Add a Team Name edit control (owner-only) and client-side rename flow in Settings > Team.
  • Add a protected backend endpoint to rename a team with basic validation/authorization.
  • Add dashboard-commit-log.md documenting dashboard branch commit sequencing.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/components/views/SettingsView.tsx Adds owner-only team rename UI, state, and API call logic
backend/routes/teamRoutes.js Adds PATCH /:teamId/name endpoint with owner authorization + validation
dashboard-commit-log.md Adds documentation for dashboard branch commit sequencing

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

Comment on lines +944 to +955
useEffect(() => {
if (!selectedTeam || selectedTeam.ownerId !== currentUser?.uid) {
return;
}

const focusTimer = window.setTimeout(() => {
teamNameInputRef.current?.focus();
teamNameInputRef.current?.select();
}, 0);

return () => window.clearTimeout(focusTimer);
}, [selectedTeamId, selectedTeam, currentUser?.uid]);
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

The autofocus effect depends on the entire selectedTeam object, so any update to team details (e.g. removing a member, transferring ownership, renaming) will re-run the effect and can steal focus back to the team name input unexpectedly. Consider tightening dependencies so focus only happens when the selected team changes (e.g., selectedTeamId and an isOwner boolean / selectedTeam?.ownerId), rather than on every selectedTeam reference change.

Copilot uses AI. Check for mistakes.
Comment on lines +350 to +366
router.patch('/:teamId/name', verifyToken, async (req, res) => {
const { teamId } = req.params;
const uid = req.user.uid;
const nextName = typeof req.body?.name === 'string' ? req.body.name.trim() : '';

if (!nextName) {
return res.status(400).json({ message: 'Team name is required' });
}

if (nextName.length > 80) {
return res.status(400).json({ message: 'Team name must be 80 characters or fewer' });
}

try {
const team = await Team.findById(teamId).lean();
if (!team) return res.status(404).json({ message: 'Team not found' });

Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

This endpoint treats an invalid teamId (non-ObjectId) as a server error because Team.findById(teamId) will throw a CastError and the catch returns 500. Since this is client input, consider validating teamId up front and returning 400 (e.g., via mongoose.Types.ObjectId.isValid(teamId)) to avoid misclassifying bad requests as server failures.

Copilot uses AI. Check for mistakes.
{ $set: { name: nextName } },
{ returnDocument: 'after', lean: true }
);

Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

findByIdAndUpdate can return null (e.g., if the team is deleted between the initial findById and the update). Right now the route responds 200 with null in that case. Add a guard for !updated and return a 404 (or re-fetch) to avoid returning a successful response with an empty body.

Suggested change
if (!updated) {
return res.status(404).json({ message: 'Team not found' });
}

Copilot uses AI. Check for mistakes.
Comment on lines +350 to +382
router.patch('/:teamId/name', verifyToken, async (req, res) => {
const { teamId } = req.params;
const uid = req.user.uid;
const nextName = typeof req.body?.name === 'string' ? req.body.name.trim() : '';

if (!nextName) {
return res.status(400).json({ message: 'Team name is required' });
}

if (nextName.length > 80) {
return res.status(400).json({ message: 'Team name must be 80 characters or fewer' });
}

try {
const team = await Team.findById(teamId).lean();
if (!team) return res.status(404).json({ message: 'Team not found' });

if (team.ownerId !== uid) {
return res.status(403).json({ message: 'Only the team owner can rename the team' });
}

const updated = await Team.findByIdAndUpdate(
teamId,
{ $set: { name: nextName } },
{ returnDocument: 'after', lean: true }
);

res.status(200).json(normalizeDoc(updated));
} catch (error) {
console.error('Error renaming team:', error);
res.status(500).json({ message: 'Server error' });
}
});
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

New behavior is introduced here (owner-only team renaming with validation), but there are currently no automated tests covering team routes in backend/tests/. Since the repo already uses Jest + Supertest for route/security coverage (e.g. backend/tests/project_security.test.js), please add tests for this endpoint (owner can rename, non-owner gets 403, empty/too-long name gets 400).

Copilot uses AI. Check for mistakes.
Comment thread dashboard-commit-log.md
Comment on lines +1 to +4
# Dashboard Branch Commit Log

This file tracks requested commit sequencing for the `dashboard` branch.

Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

The PR description mentions changes to post-login onboarding routing (/welcome vs /dashboard), but the diff shown here only includes team rename UI/API and this commit-log doc. If onboarding routing changes are intended in this PR, they appear to be missing from the actual changes; otherwise, please update the PR description to match the scope.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants