Skip to content

feat(workspaces): Add repo button on /projects (standalone repos)#43

Closed
dvcdsys wants to merge 1 commit into
developfrom
feat/standalone-projects-add-repo
Closed

feat(workspaces): Add repo button on /projects (standalone repos)#43
dvcdsys wants to merge 1 commit into
developfrom
feat/standalone-projects-add-repo

Conversation

@dvcdsys
Copy link
Copy Markdown
Owner

@dvcdsys dvcdsys commented May 14, 2026

Summary

  • Adds an Add repo button to the /projects page so a GitHub repository can be cloned + indexed without having to first pick or create a workspace. Reuses the existing AddRepoDialog; the only new piece is the workspaceID-optional code path that POSTs to /api/v1/git-repos instead of /api/v1/workspaces/{id}/repos.
  • Introduces a singleton default workspace (workspaces.is_default = 1) bootstrapped at server startup. The /git-repos endpoint internally resolves it and proxies to AddWorkspaceRepo, so the existing clone/index/webhook pipeline is untouched. The row is protected from delete (409) so the standalone endpoint always has a target.

Motivation

Projects in this codebase are canonical, workspaces are groupings. Requiring a workspace selection to add a repo broke that mental model. The default workspace keeps the data model intact while giving users a frictionless "just add this repo" flow from /projects.

Notes

  • EnsureDefault is idempotent + handles operator name collisions (e.g. a pre-existing workspace called "Personal" stays untouched; the bootstrap picks "Personal (2)" etc).
  • The partial UNIQUE index on workspaces(is_default) WHERE is_default = 1 lives in the migration only — keeping it out of Schema so pre-feature databases don't trip on it before the column is added (same pattern as idx_projects_path_hash).
  • The default workspace shows up in /workspaces and can be renamed — only delete is blocked. A future polish PR could surface it specially in the workspace list (badge or sort-first).

Test plan

  • go test ./... — adds:
    • TestEnsureDefault_CreatesOnFirstCall
    • TestEnsureDefault_Idempotent
    • TestEnsureDefault_AvoidsNameCollision
    • TestDelete_DefaultProtected
    • TestStandaloneGitRepo_LandsInDefaultWorkspace
    • TestStandaloneGitRepo_DeleteDefaultWorkspaceConflict
  • npm run build in server/dashboard — typecheck + production build clean against regenerated generated.ts.
  • Dashboard E2E (manual):
    • On a fresh server boot, observe "workspaces: default workspace ready" log line.
    • Open /projects → click Add repo → walk through token/account/repo/branch → submit → confirm the new project appears in /projects and a workspace_repos row lands in the default workspace.
    • Open /workspaces → confirm the default workspace exists; attempting to delete it surfaces a 409 error in the UI.
    • Link the standalone repo into a regular workspace via the existing Add Existing Project dialog to confirm the cross-workspace link flow still works.

🤖 Generated with Claude Code

Adding a GitHub repo previously required navigating into a specific
workspace, which is awkward when projects in this codebase exist
independently of workspaces (workspaces are aggregations). The
dashboard's /projects page now has an Add repo button next to the
title that runs the same clone+index pipeline without forcing the
user to think about workspace assignment first.

Backend: workspaces gain an is_default flag (partial-UNIQUE index +
ALTER-TABLE migration) and a singleton default row is created at
startup via workspaces.EnsureDefault. POST /api/v1/git-repos resolves
that row and proxies into AddWorkspaceRepo so the existing job queue,
webhook, and link flows stay untouched. The default workspace is
protected from delete (409) so the standalone endpoint always has a
home. EnsureDefault is idempotent and side-steps name collisions
("Personal" → "Personal (2)") so an operator-created workspace with
the same name is never reassigned.

Frontend: AddRepoDialog's workspaceID prop is now optional; the
component routes to /git-repos when omitted. ProjectsListPage gets
the trigger button + an updated empty-state copy that points users
at it.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@dvcdsys
Copy link
Copy Markdown
Owner Author

dvcdsys commented May 14, 2026

Folded into #42 — consolidated PR now carries both feature sets.

@dvcdsys dvcdsys closed this May 14, 2026
@dvcdsys dvcdsys deleted the feat/standalone-projects-add-repo branch May 14, 2026 11:15
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