You've already forked agentic-coding-workflow
feat(web): base_branch selector with remote branch list in worktree creation
This commit is contained in:
@@ -52,6 +52,11 @@ export const workspacesApi = {
|
||||
release: (wtID: string) =>
|
||||
request<Worktree>(`/api/v1/worktrees/${enc(wtID)}/release`, { method: 'POST' }),
|
||||
|
||||
listBranches(wsID: string): Promise<string[]> {
|
||||
return request<{ branches: string[] }>(`/api/v1/workspaces/${enc(wsID)}/branches`)
|
||||
.then(r => r.branches)
|
||||
},
|
||||
|
||||
// ===== Git ops =====
|
||||
statusOnMain: (wsID: string) =>
|
||||
request<FileStatus[]>(`/api/v1/workspaces/${enc(wsID)}/main/status`),
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
>
|
||||
<NButton
|
||||
type="primary"
|
||||
@click="showCreate = true"
|
||||
@click="openCreate"
|
||||
>
|
||||
新建 worktree
|
||||
</NButton>
|
||||
@@ -31,7 +31,13 @@
|
||||
<NInput v-model:value="newBranch" />
|
||||
</NFormItem>
|
||||
<NFormItem label="基线分支(默认 default_branch)">
|
||||
<NInput v-model:value="newBase" />
|
||||
<NSelect
|
||||
v-model:value="newBase"
|
||||
:options="baseBranchOptions"
|
||||
:loading="branchesLoading"
|
||||
clearable
|
||||
placeholder="默认使用 default_branch"
|
||||
/>
|
||||
</NFormItem>
|
||||
</NForm>
|
||||
<template #footer>
|
||||
@@ -71,11 +77,13 @@ import {
|
||||
NForm,
|
||||
NFormItem,
|
||||
NInput,
|
||||
NSelect,
|
||||
useMessage,
|
||||
useDialog,
|
||||
} from 'naive-ui'
|
||||
import type { DataTableColumns } from 'naive-ui'
|
||||
import { useWorkspacesStore } from '@/stores/workspaces'
|
||||
import { workspacesApi } from '@/api/workspaces'
|
||||
import CommitDialog from './CommitDialog.vue'
|
||||
import type { Workspace, Worktree, WorktreeStatus } from '@/api/types'
|
||||
|
||||
@@ -87,16 +95,40 @@ const dialog = useDialog()
|
||||
const showCreate = ref<boolean>(false)
|
||||
const creating = ref<boolean>(false)
|
||||
const newBranch = ref<string>('')
|
||||
const newBase = ref<string>('')
|
||||
const newBase = ref<string | null>(null)
|
||||
|
||||
const commitFor = ref<Worktree | null>(null)
|
||||
|
||||
// Branch list for base_branch selector
|
||||
const branches = ref<string[]>([])
|
||||
const branchesLoading = ref(false)
|
||||
|
||||
const STATUS_TAG_TYPE: Record<WorktreeStatus, 'warning' | 'error' | 'default'> = {
|
||||
active: 'warning',
|
||||
pruning: 'error',
|
||||
idle: 'default',
|
||||
}
|
||||
|
||||
async function openCreate() {
|
||||
showCreate.value = true
|
||||
newBranch.value = ''
|
||||
newBase.value = null
|
||||
// Fetch branch list when dialog opens
|
||||
branchesLoading.value = true
|
||||
try {
|
||||
branches.value = await workspacesApi.listBranches(props.ws.id)
|
||||
} catch {
|
||||
// Silently fail — user can still type manually
|
||||
branches.value = []
|
||||
} finally {
|
||||
branchesLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const baseBranchOptions = computed(() =>
|
||||
branches.value.map((b) => ({ label: b, value: b })),
|
||||
)
|
||||
|
||||
async function onCreate() {
|
||||
if (!newBranch.value.trim()) {
|
||||
msg.error('分支名为必填')
|
||||
@@ -110,7 +142,7 @@ async function onCreate() {
|
||||
})
|
||||
showCreate.value = false
|
||||
newBranch.value = ''
|
||||
newBase.value = ''
|
||||
newBase.value = null
|
||||
} catch (e: unknown) {
|
||||
msg.error('创建失败:' + (e instanceof Error ? e.message : String(e)))
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user