fix(agent-manager): activate cross-project imports

This commit is contained in:
marius-kilocode
2026-08-06 11:03:22 +02:00
parent fa9974996a
commit d422267e9f
4 changed files with 127 additions and 6 deletions
@@ -14,8 +14,8 @@ describe("Agent Manager New Worktree project targeting", () => {
expect(dialog).toContain('type: "agentManager.requestBranches", projectId: id')
expect(dialog).toContain('type: "agentManager.createMultiVersion"')
expect(dialog).toContain("projectId: target")
expect(dialog).toContain('type: "agentManager.importFromPR", projectId: project()')
expect(dialog).toContain('type: "agentManager.importFromBranch", projectId: project()')
expect(dialog).toContain('type: "agentManager.importFromPR"')
expect(dialog).toContain('type: "agentManager.importFromBranch"')
})
it("tags branch and import responses with their owning project", () => {
@@ -1392,6 +1392,7 @@ const AgentManagerContent: Component = () => {
target: { projectId: ev.projectId, kind: "worktree", worktreeId: ev.worktreeId },
})
}
if (ev.status === "error" && pending?.projectId === ev.projectId) setPendingCreate(undefined)
const store = ev.projectId ? registry.ensure(ev.projectId) : registry.active()
const updateBusy: Setter<Map<string, WorktreeBusyState>> = (value) => store.setBusy(value)
if (ev.status === "ready" || ev.status === "error") {
@@ -602,7 +602,9 @@ export const NewWorktreeDialog: Component<{
const url = prUrl().trim()
if (!url || isPending()) return
setPrPending(true)
vscode.postMessage({ type: "agentManager.importFromPR", projectId: project(), url })
const target = project()
if (target) props.onCreate?.(target)
vscode.postMessage({ type: "agentManager.importFromPR", projectId: target, url })
}
const handleBranchSelect = (name: string) => {
@@ -611,7 +613,9 @@ export const NewWorktreeDialog: Component<{
setImportPending(true)
setBranchOpen(false)
setBranchSearch("")
vscode.postMessage({ type: "agentManager.importFromBranch", projectId: project(), branch: name })
const target = project()
if (target) props.onCreate?.(target)
vscode.postMessage({ type: "agentManager.importFromBranch", projectId: target, branch: name })
}
return (
@@ -26,8 +26,16 @@ import { Icon } from "@kilocode/kilo-ui/icon"
import { TooltipKeybind } from "@kilocode/kilo-ui/tooltip"
import { ContextMenu } from "@kilocode/kilo-ui/context-menu"
import { ThinkingSelectorBase } from "../components/shared/ThinkingSelector"
import { DeferredPopover } from "../components/shared/DeferredPopover"
import { ProjectSelect } from "../../agent-manager/ProjectSelect"
import { createSignal, onCleanup, onMount, type JSX } from "solid-js"
import type { WorktreeFileDiff, WorktreeState, WorktreeGitStats, PRStatus } from "../types/messages"
import type {
AgentProjectSnapshot,
WorktreeFileDiff,
WorktreeState,
WorktreeGitStats,
PRStatus,
} from "../types/messages"
import type { ReviewComment } from "../../diff-viewer/review-comments"
import { createModeRouter } from "../../agent-manager/mode-router"
import "../../agent-manager/agent-manager.css"
@@ -1075,6 +1083,115 @@ export const NewWorktreeVariantDropdown1280: Story = {
),
}
const projectPickerProjects: AgentProjectSnapshot[] = [
{
id: "project-main",
root: "/workspace/kilocode",
label: "kilocode",
pinned: true,
active: true,
expanded: true,
initialized: true,
trusted: true,
missing: false,
},
{
id: "project-cloud",
root: "/workspace/cloud",
label: "cloud",
pinned: false,
active: false,
expanded: false,
initialized: true,
trusted: true,
missing: false,
},
{
id: "project-untrusted",
root: "/workspace/sample-app",
label: "sample-app",
pinned: false,
active: false,
expanded: false,
initialized: false,
trusted: false,
missing: false,
},
]
export const NewWorktreeProjectDropdown: Story = {
name: "NewWorktreeDialog — project dropdown open",
parameters: { layout: "fullscreen" },
render: () => (
<StoryProviders noPadding>
<div style={{ height: "100vh", display: "flex", "flex-direction": "column" }}>
<div data-component="dialog" data-fit="true">
<div data-slot="dialog-container">
<div data-slot="dialog-content">
<div data-slot="dialog-header">
<div data-slot="dialog-title">New Worktree</div>
</div>
<div data-slot="dialog-body">
<div class="am-tab-switcher">
<button class="am-tab-switcher-pill am-tab-switcher-pill-active" type="button">
New
</button>
<button class="am-tab-switcher-pill" type="button">
Import
</button>
<div class="am-nv-project-inline">
<div class="am-selector-wrapper">
<DeferredPopover
open
onOpenChange={() => undefined}
placement="bottom-start"
flip={false}
sameWidth
portal={false}
deferDismiss
class="am-dropdown"
trigger={
<button class="am-selector-trigger" type="button" aria-label="Select project">
<span class="am-selector-left">
<Icon name="folder" size="small" />
<span class="am-selector-value">kilocode</span>
</span>
<span class="am-selector-right">
<Icon name="selector" size="small" />
</span>
</button>
}
>
<ProjectSelect
projects={projectPickerProjects}
selected="project-main"
onSelect={() => undefined}
labels={{
untrusted: "Trust this project in the sidebar first",
missing: "Repository not found",
}}
/>
</DeferredPopover>
</div>
</div>
</div>
<div class="am-nv-dialog" style={{ "max-height": "520px" }}>
<div class="am-nv-dialog-content">
<div style={{ height: "420px", "flex-shrink": 0 }} />
<div class="am-nv-version-bar">
<span class="am-nv-config-label">VERSIONS</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</StoryProviders>
),
}
const searchSection = { id: "polish", name: "Polish", color: "Blue", order: 0, collapsed: false }
const slackedSection = { id: "slacked", name: "SLACKED", color: "Yellow", order: 1, collapsed: false }
const sidebarSearchItems: SidebarSearchItem[] = [
@@ -1200,7 +1317,6 @@ export const SidebarSearchOpen: Story = {
import { ProjectList } from "../../agent-manager/ProjectList"
import type {
AgentManagerStateMessage,
AgentProjectSnapshot,
LocalGitStats,
ProjectSessionInfo,
} from "../types/messages"