Skip to content

🤖 fix: pre-fill sub-project on Ctrl+N from sub-project workspace#3265

Open
ammar-agent wants to merge 1 commit into
mainfrom
fix-ctrl-n-subproject-prefill
Open

🤖 fix: pre-fill sub-project on Ctrl+N from sub-project workspace#3265
ammar-agent wants to merge 1 commit into
mainfrom
fix-ctrl-n-subproject-prefill

Conversation

@ammar-agent
Copy link
Copy Markdown
Collaborator

Summary

Fix Ctrl/Cmd+N (new chat) so it pre-fills the focused workspace's sub-project instead of falling back to the parent project.

Background

When a workspace lives in a sub-project, pressing Ctrl+N would open the new-chat screen with the parent project selected in the picker rather than the sub-project. Users then had to manually re-pick the sub-project every time, even though clicking the sub-project section's + button already does the right thing.

Sub-project workspaces share the parent's worktree, so WorkspaceSelection.projectPath is always the parent path. The discriminator (subProjectPath) lives on the workspace metadata, but the global Ctrl+N handler never looked it up — it just called handleAddWorkspace(selectedWorkspace.projectPath), persisting the draft with subProjectPath: null. From there the existing pendingSubProjectPathcreationSubProjectPath pipeline in ChatInput had nothing to work with and defaulted to the parent.

Implementation

In the Ctrl+N branch of the keydown handler in ProjectSidebar.tsx, look up the focused workspace's metadata via workspaceStore.getWorkspaceMetadata(...) and forward its subProjectPath to handleAddWorkspace. This mirrors what the sub-project section header's + button already does (handleAddWorkspace(projectPath, section.id)) and rides on the existing draft → creation-screen pre-fill logic.

Risks

Very low. One-line change scoped to a single keybind branch; metadata lookup falls back to undefined for non-sub-project workspaces, preserving prior behavior. No schema, IPC, or persisted-state changes.


Generated with mux • Model: anthropic:claude-opus-4-7 • Thinking: high • Cost: $1.84

@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: 2d81278141

ℹ️ 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
@ammar-agent ammar-agent force-pushed the fix-ctrl-n-subproject-prefill branch from 2d81278 to d408670 Compare May 10, 2026 22:09
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the P2 staleness concern: switched the Ctrl+N handler to read subProjectPath from sortedWorkspacesByProject (the live React prop the sidebar already renders from) instead of WorkspaceStore.getWorkspaceMetadata (whose backing Map is insert-only via syncWorkspaces and can serve a stale value after a section drop). This mirrors the existing pattern in SidebarTitleEditKeybinds (EDIT_WORKSPACE_TITLE, lines 561–567). Please take another look.

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: d40867049d

ℹ️ 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
@ammar-agent ammar-agent force-pushed the fix-ctrl-n-subproject-prefill branch from d408670 to 7a1d21a Compare May 10, 2026 22:15
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the deleted-sub-project edge case: before forwarding meta.subProjectPath, the handler now validates it against the current getSubProjectsForParent(parentPath, userProjects) set, matching how partitionWorkspacesBySection decides what to render. If the section has been removed from the project config, the draft falls back to the parent (matching the sidebar's visible "unsectioned" placement) instead of forwarding a stale path that workspace.create would reject.

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: 7a1d21a2f5

ℹ️ 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
The Ctrl/Cmd+N keybind handler in ProjectSidebar called handleAddWorkspace
with only the parent projectPath, dropping the focused workspace's
subProjectPath. Sub-project workspaces share the parent's worktree, so
projectPath is always the parent and subProjectPath is the discriminator.
The downstream draft -> creation-screen pipeline already supports passing
a subProjectPath (the section-header '+' button does this), so the fix is
to recover it from workspace metadata and forward it.
@ammar-agent ammar-agent force-pushed the fix-ctrl-n-subproject-prefill branch from 7a1d21a to f781019 Compare May 10, 2026 22:20
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the inherited-section case: extracted the renderer's parent-walk into an exported resolveEffectiveSectionId(workspace, byId, sectionIds) in workspaceFiltering.ts, reused by partitionWorkspacesBySection and by the Ctrl+N keybind handler. The keybind now resolves the same effective section the sidebar renders — including for sub-agent rows that inherit subProjectPath via parentWorkspaceId, and unsectioned fallback when the section has been deleted from the project config.

@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".

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