-
-
Notifications
You must be signed in to change notification settings - Fork 477
feat(workspaces): add explicit managed workspace release lifecycle #292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2da45af
8d1325c
f9ce7ec
738a122
de857d7
279658b
a7def9d
c173df1
f2eddb0
708eaa5
91df46f
e6744ef
ea5bd3a
d1aa80c
ce1ef64
8371e30
55e2a23
40b5106
14987ce
f9af207
9aa3acf
7b622b5
9e348b3
8a2dc5e
f7c9d5e
ca1d4f6
a729a98
c2f10e8
3b1ae8d
124b4be
c853c4f
bafe234
10dfafd
f3b567b
5733d7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,29 +17,25 @@ ChatGPT should call `open_workspace` once for a project folder: | |
| The result includes a `workspaceId`. All later file, search, edit, show-changes, | ||
| and shell calls should reuse that same `workspaceId`. | ||
|
|
||
| ChatGPT may support automatic checkout recovery through optional host | ||
| ChatGPT may support automatic workspace recovery through optional host | ||
| conversation metadata. This is an OpenAI-host adapter detail, not a standard MCP | ||
| conversation field. When that optional context is available, opening the same | ||
| checkout project again in the same conversation can continue in the existing | ||
| workspace, and the context already provided for that reused checkout is not | ||
| repeated. The portable workflow remains the same: keep using the `workspaceId` | ||
| returned by `open_workspace` for later operations. Hosts without supported | ||
| conversation context receive a normal new workspace and continue with that | ||
| explicit `workspaceId` workflow. | ||
| workspace. Worktree mode similarly reuses the active managed worktree lease for | ||
| the same conversation, canonical Git repository, and base ref. The portable | ||
| workflow remains the same: keep using the `workspaceId` returned by | ||
| `open_workspace` for later operations. Hosts without supported conversation | ||
| context receive a normal new workspace and continue with that explicit | ||
| `workspaceId` workflow. | ||
| The model receives actionable workspace instructions; automatic-reuse | ||
| bookkeeping is not a model-facing choice. | ||
|
|
||
| Worktree mode is deliberately different: every call creates a new managed | ||
| worktree and a new workspace session with complete context, even for the same | ||
| path and base ref. | ||
|
|
||
| The first successful open of a checkout provides complete instructions and | ||
| coding context. A repeated open that reuses the same checkout workspace does | ||
| not repeat the model-visible context, but the workspace UI continues to show the | ||
| complete details. Every new worktree establishes and returns its own complete | ||
| context, even when the same project was already opened in checkout or another | ||
| worktree. Opening checkout after a worktree therefore provides the checkout's | ||
| own context. | ||
| The first successful open of a checkout or managed worktree provides complete | ||
| instructions and coding context. A repeated open that reuses the same | ||
| conversation workspace does not repeat the model-visible context, but the | ||
| workspace UI continues to show the complete details. A different conversation, | ||
| base ref, or workspace mode establishes its own context. Opening checkout after | ||
| a worktree therefore still provides the checkout's own context. | ||
|
|
||
| Do not call `open_workspace` again for the same checkout folder unless: | ||
|
|
||
|
|
@@ -80,15 +76,34 @@ Managed worktrees are created under: | |
| Worktree mode requires a Git repository with at least one commit. It starts from | ||
| `HEAD` unless `baseRef` is provided. | ||
|
|
||
| Each worktree-mode call creates a new managed worktree and returns a new | ||
| `workspaceId`. Reuse that ID for work inside that worktree; call | ||
| `open_workspace` in worktree mode again only when another isolated worktree is | ||
| actually required. | ||
| With supported conversation metadata, the first worktree-mode open creates one | ||
| managed worktree lease for the conversation, canonical Git repository, and base | ||
| ref. Repeated or concurrent opens reuse that same `workspaceId`, including after | ||
| a DevSpace restart. A different conversation or base ref receives a separate | ||
| managed worktree. After `close_workspace` releases a terminal lease, the next | ||
| open creates a fresh worktree. Hosts without supported conversation metadata | ||
|
Comment on lines
+83
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🤖 get_repo_knowledge executed:
Length of output: 5477 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- target documentation ---'
sed -n '70,92p' docs/chatgpt-coding-workflow.md
sed -n '88,106p' docs/configuration.md
printf '%s\n' '--- relevant symbols and callers ---'
rg -n -S --glob '!node_modules' 'managedWorktreePath|close_workspace|open_workspace|release.*workspace|workspace.*release' .Repository: Waishnav/devspace Length of output: 11684 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- worktree allocator ---'
cat -n src/git-worktrees.ts | sed -n '1,210p'
printf '%s\n' '--- conversation lifecycle tests ---'
cat -n src/workspace-conversation.test.ts | sed -n '150,245p'
printf '%s\n' '--- workspace registry lifecycle ---'
cat -n src/workspaces.ts | sed -n '400,470p'
printf '%s\n' '--- configuration documentation ---'
cat -n docs/configuration.md | sed -n '88,104p'Repository: Waishnav/devspace Length of output: 16946 🌐 Web query:
💡 Result: The git worktree add command will fail if the destination directory already exists and is non-empty [1][2]. By design, Git prevents the creation of a new worktree in an existing, non-empty directory to ensure a clean state, similar to how git clone behaves [1]. It is a common misunderstanding that options like -B (which allows resetting an existing branch name) or --force (which overrides specific safeguards regarding existing worktree metadata or locked paths) apply to the destination directory itself [3][2][4]. These flags do not override the requirement that the target directory must not exist or must be empty [2]. If you encounter an error stating that the path already exists, you must either remove the existing directory or specify a different path [2]. Note that while git worktree add creates a new branch as a convenience if one is not provided, this branch creation happens independently of the directory path validation; however, the overall command will still abort if the destination path requirement is not met [1][2]. Citations:
Prevent retained worktree deletion on path collision.
📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| continue to receive a fresh worktree for each open, so callers should still | ||
| reuse the returned `workspaceId` directly whenever possible. | ||
|
|
||
| Uncommitted source checkout changes are not copied into the managed worktree. | ||
| DevSpace reports when the source checkout was dirty so the model can decide how | ||
| to proceed with the user. | ||
|
|
||
| ## Release A Terminal Workspace | ||
|
|
||
| Call `close_workspace` once only when work in that workspace is genuinely | ||
| terminal and no DevSpace process session is still running for it. Closing the | ||
| workspace releases its durable DevSpace lease and makes that `workspaceId` | ||
| non-reusable. | ||
|
|
||
| `close_workspace` does not delete a managed worktree, branch, commit, or project | ||
| file. Worktree removal remains a separate repository-policy operation that can | ||
| apply Git cleanliness, integration, process, lock, and other safety checks. | ||
|
|
||
| Do not infer terminal state from a response ending, MCP transport closure, | ||
| server restart, workspace age, or filesystem mtime. Paused or resumable work | ||
| must keep its lease active. | ||
|
|
||
| ## Project Instructions | ||
|
|
||
| When a workspace opens, DevSpace loads root-level instruction files: | ||
|
|
@@ -153,6 +168,7 @@ sessions for that workspace. | |
| The Claude surface exposes these tool names: | ||
|
|
||
| - `open_workspace` | ||
| - `close_workspace` | ||
| - `read` | ||
| - `write` | ||
| - `edit` | ||
|
|
@@ -162,6 +178,7 @@ The Claude surface exposes these tool names: | |
| DevSpace uses the Codex-style surface by default. It exposes: | ||
|
|
||
| - `open_workspace` | ||
| - `close_workspace` | ||
| - `read` | ||
| - `apply_patch` | ||
| - `exec_command` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🤖 get_repo_knowledge executed:
get_repo_knowledge Waishnav/devspace /tmp/coderabbit-repo-knowledge/waishnav-devspace-70958ecd/conventions /tmp/coderabbit-repo-knowledge/waishnav-devspace-70958ecd/learningsLength of output: 5606
🏁 Script executed:
Repository: Waishnav/devspace
Length of output: 27021
🏁 Script executed:
Repository: Waishnav/devspace
Length of output: 50373
🏁 Script executed:
Repository: Waishnav/devspace
Length of output: 41197
🏁 Script executed:
Repository: Waishnav/devspace
Length of output: 50373
🏁 Script executed:
Repository: Waishnav/devspace
Length of output: 33115
Align
docs/gotchas.mdwith managed worktree reuse.openAiConversationScopeId(_meta)enables reuse by canonical Git root andbaseRef, including after restart. However,docs/gotchas.md#L146-L150says worktree mode always creates a new workspace. Update this statement to distinguish supported conversation metadata, released leases, and hosts without that metadata.📍 Affects 2 files
docs/chatgpt-coding-workflow.md#L20-L31(this comment)docs/chatgpt-coding-workflow.md#L33-L38docs/configuration.md#L95-L101🤖 Prompt for AI Agents
Source: Coding guidelines