refactor: remove working directory allocation terminology

This commit is contained in:
2026-07-08 04:56:22 +09:00
parent 5c33b2f63d
commit 25900f31cf
12 changed files with 247 additions and 216 deletions
@@ -48,7 +48,7 @@
let runtimeId = $state('');
let profile = $state('builtin:coder');
let initialText = $state('');
let workingDirectoryAllocationId = $state('');
let workingDirectoryId = $state('');
let workingDirectoryRepositoryId = $state('');
let workingDirectorySelector = $state('HEAD');
let relativeCwd = $state('');
@@ -114,7 +114,7 @@
display_name: displayName,
profile,
initial_text: initialText,
working_directory_allocation_id: workingDirectoryAllocationId,
working_directory_id: workingDirectoryId,
working_directory_repository_id: workingDirectoryRepositoryId,
working_directory_selector: workingDirectorySelector,
relative_cwd: relativeCwd,
@@ -122,7 +122,7 @@
runtimeId = form.runtime_id;
displayName = form.display_name;
profile = form.profile;
workingDirectoryAllocationId = form.working_directory_allocation_id;
workingDirectoryId = form.working_directory_id;
workingDirectoryRepositoryId = form.working_directory_repository_id;
workingDirectorySelector = form.working_directory_selector;
relativeCwd = form.relative_cwd;
@@ -158,9 +158,9 @@
const payload = (await response.json()) as BrowserWorkingDirectoryCreateResponse;
const items = options?.working_directories ?? [];
options = options
? { ...options, working_directories: [...items.filter((item) => item.allocation_id !== payload.item.allocation_id), payload.item] }
? { ...options, working_directories: [...items.filter((item) => item.working_directory_id !== payload.item.working_directory_id), payload.item] }
: options;
workingDirectoryAllocationId = payload.item.allocation_id;
workingDirectoryId = payload.item.working_directory_id;
} catch (err) {
submitError = exceptionDisplayError(err, 'working directory create failed');
} finally {
@@ -185,7 +185,7 @@
display_name: displayName,
profile,
initial_text: initialText,
working_directory_allocation_id: workingDirectoryAllocationId,
working_directory_id: workingDirectoryId,
working_directory_repository_id: workingDirectoryRepositoryId,
working_directory_selector: workingDirectorySelector,
relative_cwd: relativeCwd,
@@ -279,18 +279,18 @@
<fieldset class="worker-working-directory">
<legend>Working directory</legend>
<label>
<span>Allocation</span>
<select bind:value={workingDirectoryAllocationId}>
<option value="">No allocation selected</option>
<span>Working directory</span>
<select bind:value={workingDirectoryId}>
<option value="">No working directory selected</option>
{#each options?.working_directories ?? [] as directory}
<option value={directory.allocation_id} disabled={directory.status !== 'active'}>
<option value={directory.working_directory_id} disabled={directory.status !== 'active'}>
{directory.repository_id} · {directory.requested_selector ?? 'HEAD'} · {directory.resolved_commit.slice(0, 12)} · {directory.status}
</option>
{/each}
</select>
</label>
<label>
<span>Repository for new allocation</span>
<span>Repository</span>
<select bind:value={workingDirectoryRepositoryId}>
{#if options?.repositories.length}
{#each options.repositories as repository}
@@ -306,11 +306,11 @@
<input bind:value={workingDirectorySelector} autocomplete="off" placeholder="HEAD" />
</label>
<button type="button" disabled={creatingWorkingDirectory || !workingDirectoryRepositoryId} onclick={() => void createWorkingDirectory()}>
{creatingWorkingDirectory ? 'Allocating…' : 'Create working directory'}
{creatingWorkingDirectory ? 'Creating…' : 'Create working directory'}
</button>
<label>
<span>Relative cwd</span>
<input bind:value={relativeCwd} autocomplete="off" placeholder="Optional path inside allocation" />
<input bind:value={relativeCwd} autocomplete="off" placeholder="Optional path inside working directory" />
</label>
</fieldset>
<label>
@@ -335,7 +335,7 @@
{/if}
</div>
{/if}
<button type="submit" disabled={submitting || !runtimeId || !profile || !workingDirectoryAllocationId}>
<button type="submit" disabled={submitting || !runtimeId || !profile || !workingDirectoryId}>
{submitting ? 'Starting…' : 'Start Coding Worker'}
</button>
</form>
@@ -116,7 +116,7 @@ export type WorkingDirectoryRepositoryOption = {
};
export type WorkingDirectorySummary = {
allocation_id: string;
working_directory_id: string;
repository_id: string;
requested_selector?: string | null;
materializer_kind: string;
@@ -127,7 +127,7 @@ export type WorkingDirectorySummary = {
cleanup_policy: string;
cleanup_target: {
kind: string;
allocation_id: string;
working_directory_id: string;
repository_id: string;
};
};
@@ -145,7 +145,7 @@ export type BrowserWorkingDirectoryListResponse = {
};
export type BrowserWorkerWorkingDirectorySelection = {
allocation_id: string;
working_directory_id: string;
relative_cwd?: string | null;
};
@@ -45,7 +45,7 @@ const options: WorkerLaunchOptionsResponse = {
],
working_directories: [
{
allocation_id: "alloc-1-repo",
working_directory_id: "wd-1-repo",
repository_id: "repo",
requested_selector: "HEAD",
materializer_kind: "local_git_worktree",
@@ -55,7 +55,7 @@ const options: WorkerLaunchOptionsResponse = {
cleanup_policy: "manual_or_worker_stop",
cleanup_target: {
kind: "git_worktree",
allocation_id: "alloc-1-repo",
working_directory_id: "wd-1-repo",
repository_id: "repo",
},
},
@@ -69,7 +69,7 @@ Deno.test("defaultWorkerLaunchForm chooses active runtime, coder profile, reposi
display_name: "",
profile: "",
initial_text: "hello",
working_directory_allocation_id: "",
working_directory_id: "",
working_directory_repository_id: "",
working_directory_selector: "",
relative_cwd: "",
@@ -79,18 +79,18 @@ Deno.test("defaultWorkerLaunchForm chooses active runtime, coder profile, reposi
assertEquals(form.display_name, "Coding Worker");
assertEquals(form.profile, "builtin:coder");
assertEquals(form.initial_text, "hello");
assertEquals(form.working_directory_allocation_id, "alloc-1-repo");
assertEquals(form.working_directory_id, "wd-1-repo");
assertEquals(form.working_directory_repository_id, "repo");
assertEquals(form.working_directory_selector, "HEAD");
});
Deno.test("buildBrowserCreateWorkerRequest sends allocation id and relative cwd only", () => {
Deno.test("buildBrowserCreateWorkerRequest sends working_directory id and relative cwd only", () => {
const request = buildBrowserCreateWorkerRequest({
runtime_id: "embedded",
display_name: "Worker",
profile: "builtin:coder",
initial_text: "go",
working_directory_allocation_id: "alloc-1-repo",
working_directory_id: "wd-1-repo",
working_directory_repository_id: "repo",
working_directory_selector: "main",
relative_cwd: "crates/yoi",
@@ -102,7 +102,7 @@ Deno.test("buildBrowserCreateWorkerRequest sends allocation id and relative cwd
profile: "builtin:coder",
initial_text: "go",
working_directory: {
allocation_id: "alloc-1-repo",
working_directory_id: "wd-1-repo",
relative_cwd: "crates/yoi",
},
});
@@ -8,7 +8,7 @@ export type WorkerLaunchFormState = {
display_name: string;
profile: string;
initial_text: string;
working_directory_allocation_id: string;
working_directory_id: string;
working_directory_repository_id: string;
working_directory_selector: string;
relative_cwd: string;
@@ -54,12 +54,12 @@ export function defaultWorkerLaunchForm(
? current.profile
: preferredProfile?.id || "",
initial_text: current.initial_text,
working_directory_allocation_id: options?.working_directories.some(
working_directory_id: options?.working_directories.some(
(directory) =>
directory.allocation_id === current.working_directory_allocation_id,
directory.working_directory_id === current.working_directory_id,
)
? current.working_directory_allocation_id
: preferredWorkingDirectory?.allocation_id || "",
? current.working_directory_id
: preferredWorkingDirectory?.working_directory_id || "",
working_directory_repository_id: current.working_directory_repository_id ||
preferredRepository?.id || "",
working_directory_selector: current.working_directory_selector ||
@@ -77,9 +77,9 @@ export function buildBrowserCreateWorkerRequest(
profile: form.profile,
initial_text: form.initial_text,
};
if (form.working_directory_allocation_id) {
if (form.working_directory_id) {
request.working_directory = {
allocation_id: form.working_directory_allocation_id,
working_directory_id: form.working_directory_id,
};
const relativeCwd = form.relative_cwd.trim();
if (relativeCwd) {