Skip to content
Open
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
7 changes: 7 additions & 0 deletions packages/kilo-ui/src/components/basic-tool.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
font-size: 12px;
}

[data-slot="basic-tool-actions"] {
margin-left: auto;
display: inline-flex;
align-items: center;
flex-shrink: 0;
}

[data-slot="basic-tool-tool-info-structured"] {
min-width: 0;
overflow: hidden;
Expand Down
29 changes: 28 additions & 1 deletion packages/kilo-ui/src/components/message-part.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1794,6 +1794,11 @@ ToolRegistry.register({
})
const running = createMemo(() => busy(props.status))
const reveal = useToolReveal(running, () => props.reveal !== false)
const stop = () => {
const id = childSessionId()
if (!id) return
data.abortSession?.(id)
}

const href = createMemo(() => {
const sessionId = childSessionId()
Expand Down Expand Up @@ -1852,7 +1857,29 @@ ToolRegistry.register({
</div>
)

return <BasicTool hideDetails icon="task" status={props.status} trigger={trigger()} animated />
return (
<BasicTool
hideDetails
icon="task"
status={props.status}
trigger={trigger()}
animated
actions={
<Show when={running() && data.abortSession && childSessionId()}>
<Tooltip value={i18n.t("prompt.action.stop")} placement="top" gutter={4}>
<IconButton
icon="stop"
size="small"
variant="secondary"
onMouseDown={(e) => e.preventDefault()}
onClick={stop}
aria-label={i18n.t("prompt.action.stop")}
/>
</Tooltip>
</Show>
}
/>
)
},
})

Expand Down
5 changes: 5 additions & 0 deletions packages/kilo-vscode/webview-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export const DataBridge: Component<{ children: any }> = (props) => {
vscode.postMessage({ type: "openExternal", url })
}

const abort = (sessionID: string) => {
session.abort(sessionID)
}

const directory = () => {
const dir = server.workspaceDirectory()
if (!dir) return ""
Expand All @@ -114,6 +118,7 @@ export const DataBridge: Component<{ children: any }> = (props) => {
onQuestionReject={reject}
onOpenFile={open}
onOpenUrl={openUrl}
onAbortSession={abort}
>
{props.children}
</DataProvider>
Expand Down
5 changes: 2 additions & 3 deletions packages/kilo-vscode/webview-ui/src/context/session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ interface SessionContextValue {
files?: FileAttachment[],
draftID?: string,
) => void
abort: () => void
abort: (sessionID?: string) => void
compact: () => void
respondToPermission: (
permissionId: string,
Expand Down Expand Up @@ -1476,8 +1476,7 @@ export const SessionProvider: ParentComponent = (props) => {
})
}

function abort() {
const sessionID = currentSessionID()
function abort(sessionID = currentSessionID()) {
if (!sessionID) {
console.warn("[Kilo New] Cannot abort: no current session")
return
Expand Down
7 changes: 7 additions & 0 deletions packages/ui/src/components/basic-tool.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
gap: 8px;
}

[data-slot="basic-tool-actions"] {
margin-left: auto;
display: inline-flex;
align-items: center;
flex-shrink: 0;
}

[data-slot="basic-tool-tool-indicator"] {
width: 16px;
height: 16px;
Expand Down
6 changes: 6 additions & 0 deletions packages/ui/src/components/basic-tool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface BasicToolProps {
locked?: boolean
animated?: boolean
onSubtitleClick?: () => void
actions?: JSX.Element // kilocode_change
}

const SPRING = { type: "spring" as const, visualDuration: 0.35, bounce: 0 }
Expand Down Expand Up @@ -190,6 +191,11 @@ export function BasicTool(props: BasicToolProps) {
</Switch>
</div>
</div>
<Show when={props.actions}>
<span data-slot="basic-tool-actions" onClick={(e) => e.stopPropagation()}>
{props.actions}
</span>
</Show>
<Show when={props.children && !props.hideDetails && !props.locked && !pending()}>
<Collapsible.Arrow />
</Show>
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/src/context/data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export type OpenFileFn = (filePath: string, line?: number, column?: number) => v

export type OpenUrlFn = (url: string) => void // kilocode_change

export type AbortSessionFn = (sessionID: string) => void // kilocode_change

export const { use: useData, provider: DataProvider } = createSimpleContext({
name: "Data",
init: (props: {
Expand All @@ -39,6 +41,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
onSessionHref?: SessionHrefFn
onOpenFile?: OpenFileFn // kilocode_change
onOpenUrl?: OpenUrlFn // kilocode_change
onAbortSession?: AbortSessionFn // kilocode_change
}) => {
return {
get store() {
Expand All @@ -51,6 +54,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
sessionHref: props.onSessionHref,
openFile: props.onOpenFile, // kilocode_change
openUrl: props.onOpenUrl, // kilocode_change
abortSession: props.onAbortSession, // kilocode_change
}
},
})
Loading