| 1 | package main |
| 2 | |
| 3 | import "errors" |
| 4 | |
| 5 | // registerProjectRoot indexes workspaceRoot, realigns open tabs to its |
| 6 | // canonical spelling, and discovers existing sessions once per process. |
| 7 | func (a *App) registerProjectRoot(workspaceRoot string) error { |
| 8 | if err := addProject(workspaceRoot, ""); errors.Is(err, errProjectStateCollisionAssignment) { |
| 9 | return err |
| 10 | } |
| 11 | a.syncTabWorkspaceRootSpellings() |
| 12 | root := normalizeProjectRoot(workspaceRoot) |
| 13 | if root == "" { |
| 14 | return nil |
| 15 | } |
| 16 | registrationKey := projectRootKey(root) |
| 17 | if _, loaded := a.catalogRegisteredProjectRoots.LoadOrStore(registrationKey, struct{}{}); loaded { |
| 18 | return nil |
| 19 | } |
| 20 | if !a.requestSessionCatalogReconcile(desktopSessionDir(root)) { |
| 21 | a.catalogRegisteredProjectRoots.Delete(registrationKey) |
| 22 | } |
| 23 | return nil |
| 24 | } |
| 25 | |
| 26 | func (a *App) beginRegisteredProjectRuntimeAdmission(tab *WorkspaceTab, scope, workspaceRoot string) (func(), error) { |
| 27 | release, err := a.beginChangedProjectRuntimeAdmission(tab, scope, workspaceRoot) |
| 28 | if err != nil { |
| 29 | return nil, err |
| 30 | } |
| 31 | if err := a.registerProjectRoot(workspaceRoot); err != nil { |
| 32 | release() |
| 33 | return nil, err |
| 34 | } |
| 35 | return release, nil |
| 36 | } |
| 37 |