Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fork-completed-agent-sessions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kilo-code": minor
---

Add a Fork Session button to completed Agent Manager sessions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2999,6 +2999,7 @@ const AgentManagerContent: Component = () => {
}}
onShowHistory={() => setHistory(true)}
onForkMessage={readOnly() ? undefined : handleForkSession}
onForkSession={readOnly() ? undefined : handleForkSession}
readonly={readOnly()}
continueInWorktree={selection() === LOCAL}
promptBoxId={`agent-manager:${selection() ?? "unassigned"}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const SortableTab: Component<{
<ContextMenu.Content class="am-ctx-menu">
<Show when={props.onFork}>
<ContextMenu.Item onSelect={() => props.onFork?.()}>
<Icon name="branch" size="small" />
<Icon name="fork" size="small" />
<ContextMenu.ItemLabel>{t("agentManager.tab.forkSession")}</ContextMenu.ItemLabel>
</ContextMenu.Item>
<ContextMenu.Separator />
Expand Down
25 changes: 24 additions & 1 deletion packages/kilo-vscode/webview-ui/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface ChatViewProps {
onSelectSession?: (id: string) => void
onShowHistory?: () => void
onForkMessage?: (sessionId: string, messageId: string) => void
onForkSession?: (sessionId: string) => void
readonly?: boolean
/** When true, show the "Continue in Worktree" button. Defaults to true in the sidebar. */
continueInWorktree?: boolean
Expand Down Expand Up @@ -129,6 +130,12 @@ export const ChatView: Component<ChatViewProps> = (props) => {

const startSession = () => window.dispatchEvent(new CustomEvent("newTaskRequest"))

const fork = () => {
const sid = id()
if (!sid) return
props.onForkSession?.(sid)
}

const startWorktree = () => vscode.postMessage({ type: "agentManager.createWorktree" })

const startWorktreeFromBranch = () =>
Expand Down Expand Up @@ -181,11 +188,14 @@ export const ChatView: Component<ChatViewProps> = (props) => {

const canStartSession = (hasChat: boolean) => hasChat

const canFork = (hasChat: boolean) => hasChat && !isSidebar() && session.status() === "idle" && !!props.onForkSession

const canStartWorktree = () => isSidebar() && server.gitInstalled()

const canMoveToWorktree = (hasChat: boolean) => hasChat && canContinueInWorktree() && server.gitInstalled()

const hasActions = (hasChat: boolean) => canStartSession(hasChat) || canStartWorktree() || canMoveToWorktree(hasChat)
const hasActions = (hasChat: boolean) =>
canStartSession(hasChat) || canFork(hasChat) || canStartWorktree() || canMoveToWorktree(hasChat)

const renderActions = (hasChat: boolean) => (
<Show when={hasActions(hasChat)}>
Expand All @@ -204,6 +214,19 @@ export const ChatView: Component<ChatViewProps> = (props) => {
</Button>
</Tooltip>
</Show>
<Show when={canFork(hasChat)}>
<Tooltip value={language.t("agentManager.tab.forkSession")} placement="top">
<Button
variant="ghost"
size="small"
onClick={fork}
aria-label={language.t("agentManager.tab.forkSession")}
>
<Icon name="fork" size="small" />
{language.t("agentManager.tab.forkSession")}
</Button>
</Tooltip>
</Show>
<Show when={canStartWorktree()}>
<div class="session-worktree-split" ref={worktreeRef}>
<Tooltip value={worktreeTooltip} placement="top">
Expand Down
25 changes: 25 additions & 0 deletions packages/kilo-vscode/webview-ui/src/stories/chat.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { MessageList } from "../components/chat/MessageList"
import { TurnOutcome } from "../components/shared/TurnOutcome"
import { SessionContext } from "../context/session"
import { ServerContext } from "../context/server"
import { WorktreeModeProvider } from "../context/worktree-mode"
import type { Message, Part, QuestionRequest, SuggestionRequest, TodoItem } from "../types/messages"

const SESSION_ID = "story-session-chat-001"
Expand Down Expand Up @@ -149,6 +150,30 @@ export const ChatViewWithMessages: Story = {
},
}

export const ChatViewAgentManagerCompleted: Story = {
name: "ChatView — completed Agent Manager session actions",
render: () => {
const session = {
...mockSessionValue({ id: SESSION_ID, status: "idle", closeReason: "completed" }),
messages: () => [{ id: "msg-001" }] as any[],
worktreeStats: () => ({ files: 2, additions: 12, deletions: 4 }),
}
return (
<StoryProviders sessionID={SESSION_ID} status="idle" noPadding>
<ServerContext.Provider value={mockServer as any}>
<SessionContext.Provider value={session as any}>
<WorktreeModeProvider>
<div style={{ height: "200px", display: "flex", "flex-direction": "column" }}>
<ChatView onForkSession={() => undefined} continueInWorktree />
</div>
</WorktreeModeProvider>
</SessionContext.Provider>
</ServerContext.Provider>
</StoryProviders>
)
},
}

/**
* ChatView with a pending question tool call and an empty input.
*
Expand Down
Loading