Skip to content

🤖 feat: replace sections with sub-projects#3225

Merged
ammario merged 8 commits into
mainfrom
feat/sub-projects
May 3, 2026
Merged

🤖 feat: replace sections with sub-projects#3225
ammario merged 8 commits into
mainfrom
feat/sub-projects

Conversation

@ammar-agent
Copy link
Copy Markdown
Collaborator

@ammar-agent ammar-agent commented May 2, 2026

Summary

Replaces the old Sections/sub-folder feature wholesale with first-class sub-projects. Sub-projects are registered projects whose path is inside a top-level parent project, render beneath that parent in the sidebar, and share the parent worktree/branch model while providing sub-project-specific cwd and AGENTS.md context.

Background

Sections were free-form workspace groups. The new model ties grouping to real project paths so nested app/package directories can have their own steering while staying inside the same git repo and parent worktree.

Implementation

  • Removes section schemas, ORPC routes, workspace sectionId, section ordering, section deep-link handling, section picker UI, and obsolete section tests.
  • Adds ProjectConfig.parentProjectPath and WorkspaceConfig.subProjectPath / WorkspaceMetadata.subProjectPath.
  • Auto-nests project registration by descendant path, enforces one-level depth, rejects nested git repos, and rejects cloning a repo inside an existing project tree.
  • Keeps sub-project workspaces parent-owned: creation stores the workspace under the top-level parent and uses subProjectPath only for cwd and prompt context.
  • Concatenates instruction sources as project → sub-project → workspace, and concatenates scoped Tool/Model instruction sections instead of first-match behavior.
  • Updates sidebar grouping, project creation modal prefill for “Add sub-project”, command palette labels, routing, drafts, and stories.

Validation

  • make static-check
  • make fmt
  • make lint
  • bun run typecheck
  • bun test src/common/utils/subProjects.test.ts src/common/utils/deepLink.test.ts src/node/runtime/runtimeHelpers.test.ts src/browser/components/ProjectSidebar/ProjectSidebar.test.tsx
  • make storybook-build + served storybook-static + make test-storybook

Risks

This intentionally removes compatibility for existing section data. The main regression risk is around workspace creation and execution path resolution because sub-projects share parent worktrees while changing cwd/prompt context. Local typecheck, lint, static-check, and targeted sidebar/runtime tests pass.


Generated with mux • Model: openai:gpt-5.5 • Thinking: high • Cost: $109.28

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0da090e1a6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/components/ProjectSidebar/ProjectSidebar.tsx Outdated
Comment thread src/node/services/projectService.ts
@ammar-agent ammar-agent force-pushed the feat/sub-projects branch from 0da090e to bbbed7f Compare May 2, 2026 19:27
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the two review comments:

  • sub-project draft creation now keeps the parent project as the draft bucket and passes the sub-project path as context
  • sub-project removal clears secrets before unregistering the sub-project

@ammar-agent ammar-agent force-pushed the feat/sub-projects branch from bbbed7f to 11d6aac Compare May 2, 2026 19:31
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11d6aacd66

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/contexts/WorkspaceContext.tsx
Comment thread src/node/services/projectService.ts
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Fixed the Windows path regression by keeping the user-facing project path stable in config while using realpath only for canonical duplicate checks.

@ammar-agent ammar-agent force-pushed the feat/sub-projects branch from 11d6aac to faaa3ac Compare May 2, 2026 19:37
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the latest comments:

  • opening a draft now navigates to its sub-project path when present, preserving the creation context
  • parent project removal now clears secrets for removed sub-projects as well as the parent

@ammar-agent ammar-agent force-pushed the feat/sub-projects branch from faaa3ac to c0d931e Compare May 2, 2026 19:41
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0d931e9f4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/contexts/WorkspaceContext.tsx
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Fixed draft creation/reuse navigation so sub-project drafts route to the sub-project page while remaining stored under the parent draft bucket.

@ammar-agent ammar-agent force-pushed the feat/sub-projects branch from c0d931e to df00b90 Compare May 2, 2026 19:49
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: df00b90fb9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/features/ChatInput/index.tsx
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Fixed creation draft storage so sub-project creation routes still use the parent project scope for draft/pending localStorage keys.

@ammar-agent ammar-agent force-pushed the feat/sub-projects branch from df00b90 to 6a04f21 Compare May 2, 2026 19:57
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a04f21fa2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/services/projectService.ts
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Fixed parent project removal to refresh the full project list after success so cascaded sub-project removals are reflected immediately in renderer state.

@ammar-agent ammar-agent force-pushed the feat/sub-projects branch from 6a04f21 to 0fc9d2c Compare May 2, 2026 20:05
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0fc9d2cd2a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/common/utils/subProjects.ts Outdated
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Updated ProjectContext test coverage for removeProject's full refresh behavior after cascaded sub-project removal.

@ammar-agent ammar-agent force-pushed the feat/sub-projects branch from 0fc9d2c to 4a2730f Compare May 2, 2026 20:14
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Fixed hierarchy derivation to compute top-level parentage from the full project path set, independent of map insertion order, and added coverage for nested existing paths.

@ammar-agent ammar-agent force-pushed the feat/sub-projects branch from 4a2730f to 1c01a52 Compare May 2, 2026 20:18
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1c01a52f32

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/runtime/runtimeHelpers.ts
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Normalized sub-project relative cwd segments to POSIX separators before passing them through runtime path normalization.

@ammar-agent ammar-agent force-pushed the feat/sub-projects branch from 1c01a52 to fe11f10 Compare May 2, 2026 20:24
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fe11f10846

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/common/utils/subProjects.ts Outdated
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Updated systemMessage tests to assert the new concatenation behavior for Tool/Model scoped instructions.

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Adjusted draft routing back to the parent project key and now pass the draft's sub-project path through WorkspaceContext → ProjectPage → ChatInput so creation still uses the sub-project cwd/AGENTS context.

@ammar-agent ammar-agent force-pushed the feat/sub-projects branch from ed7852b to a4f0aed Compare May 2, 2026 23:07
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a4f0aed8fe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/services/projectService.ts
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Added validation for the inverse registration order: adding a parent above existing descendants now verifies every descendant shares the same git root before hierarchy derivation can re-parent them.

@ammar-agent ammar-agent force-pushed the feat/sub-projects branch from a4f0aed to 41f7f1d Compare May 2, 2026 23:18
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Three follow-ups for sub-projects:

  1. Browse button in the New Project / Add Sub-project modal now seeds the native directory picker with the user's current input when that path is an existing directory (fs.stat check in the desktop main process). Falls back to the system default when the path doesn't exist.
  2. Sub-project name click in the LeftSidebar's SectionHeader now creates a draft scoped to that sub-project (matching how clicking a top-level project row creates a draft). Expand/collapse stays on the chevron.
  3. Hierarchy labels outside the LeftSidebar: WorkspaceMenuBar now shows parent / sub-project (via formatProjectHierarchyLabel) when the workspace is scoped to a sub-project. The LeftSidebar still renders the bare child name because nesting is visually obvious.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2a71a9174d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/components/SectionHeader/SectionHeader.tsx Outdated
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Two more sub-project follow-ups:

  1. Project dropdown on the new-chat page now shows the full hierarchy label for sub-projects ("gbot / bbot") in both the trigger and the menu items. The previous code keyed the trigger off creationParentProjectPath (always the parent), so picking "bbot" rendered "gbot". Added a selectedProjectPath prop on CreationControls that reflects the URL/route project (possibly a sub-project), while the existing projectPath prop continues to scope runtime/settings to the owning parent.

  2. GitInitBanner is now suppressed when the project lives inside an existing git work tree, even if .git is in an ancestor (the typical case for sub-projects). listBranches switched its repo check from isGitRepository (direct .git stat) to a new isInsideGitRepository (git rev-parse --is-inside-work-tree). Sub-projects therefore inherit the parent's branches and the "git init" prompt no longer renders for them.

@ammar-agent ammar-agent force-pushed the feat/sub-projects branch from 5c55a24 to 60bdfee Compare May 3, 2026 16:13
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5c55a24229

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/contexts/WorkspaceContext.tsx
- SectionHeader: drop double-click rename (raced with click-to-create-draft); rename remains on the kebab menu.
- WorkspaceContext: scrub stale subProjectPath from drafts when the sub-project has been removed; fall back to parent cwd so reopening a draft doesn't fail with 'Sub-project not found'.
@ammar-agent ammar-agent force-pushed the feat/sub-projects branch from 3b90ce8 to 74e14c2 Compare May 3, 2026 16:45
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Rebased on main (resolved conflicts with #3230's /new-mirrors-/fork change: kept its auto-name + pendingAutoTitle flow on top of the sub-project create signature; auto-name now reads branches from the owning parent project).

Addressed both review threads:

  • P2 — SectionHeader double-click race: Removed onDoubleClick={startEditing} from the sub-project name button. Click now exclusively starts a new chat; rename remains reachable via the existing kebab menu's "Rename" action.

  • P1 — Stale sub-project path in drafts: WorkspaceContext now drops pendingNewWorkspaceSubProjectPath when the stored sub-project no longer exists in userProjects. Reopening a legacy draft after the sub-project was removed falls back to the parent cwd instead of failing creation with Sub-project not found under parent.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 74e14c2a8d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/runtime/runtimeHelpers.ts Outdated
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

P2 — addressed: resolveWorkspaceExecutionPath no longer asserts when metadata.subProjectPath is not a descendant of metadata.projectPath. It now self-heals by falling back to the workspace root, matching how the rest of the persisted-state surface treats stale config (project path changes, removed/re-added projects, hand-edited config). Added a unit test covering the non-descendant case.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4bb787adb1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/services/systemMessage.ts Outdated
…t dir

Worktree/SSH/Docker workspaces have their own checkout. Reading AGENTS.md
from the parent's host directory mixed stale guidance from the parent
checkout into prompts and prevented the workspace branch from overriding
parent guidance. Switch single-project (incl. sub-project) instruction
loading to use the runtime view rooted at workspaceRoot, matching how
multi-project already prefers runtime-mounted reads. Sub-project segment
uses the workspaceRoot-relative path; bad/non-descendant subProjectPath
self-heals to parent-only instructions.
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

P2 — addressed: readSingleProjectContextInstructions now reads parent + sub-project AGENTS.md only from the workspace's own checkout (via the runtime), not from the host parent project dir. This avoids mixing stale parent-checkout guidance into the workspace's prompt and lets workspace-branch edits override parent guidance — same pattern multi-project already uses (runtime workspace mount only). Sub-project AGENTS.md is read at workspaceRoot/<relative sub-project path>. If subProjectPath is no longer a descendant of projectPath (stale persisted state), we fall back to parent-only instructions instead of throwing. Updated single-project AGENTS.md tests to write to the workspace dir to match the new semantic.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d92430eefe

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/services/systemMessage.ts
…imes

path.relative emits host-native separators, but SSH/Docker/devcontainer
runtimes read files via POSIX paths. Convert backslashes to forward
slashes and use runtime.normalizePath so Windows hosts using remote
runtimes still resolve the sub-project AGENTS.md location.
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

P2 — addressed: sub-project AGENTS.md lookup now normalizes the relative path with runtime.normalizePath(rel.replace(/\/g, "/"), workspacePath) so Windows hosts running SSH/Docker/devcontainer runtimes resolve the sub-project file at the right POSIX path.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ammario ammario merged commit 3917b6b into main May 3, 2026
24 checks passed
@ammario ammario deleted the feat/sub-projects branch May 3, 2026 17:56
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.

2 participants