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/clever-moments-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---

Fixed that some tasks in task history were red
5 changes: 5 additions & 0 deletions .changeset/ten-ravens-lose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---

Improve support for VSCode's HTTP proxy settings
2 changes: 2 additions & 0 deletions apps/storybook/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Preview } from "@storybook/react-vite"

import { withExtensionState } from "../src/decorators/withExtensionState"
import { withPostMessageMock } from "../src/decorators/withPostMessageMock"
import { withQueryClient } from "../src/decorators/withQueryClient"
import { withTheme } from "../src/decorators/withTheme"
import { withI18n } from "../src/decorators/withI18n"
Expand Down Expand Up @@ -49,6 +50,7 @@ const preview: Preview = {
withI18n,
withQueryClient,
withExtensionState,
withPostMessageMock,
withTheme,
withTooltipProvider,
withFixedContainment,
Expand Down
43 changes: 43 additions & 0 deletions apps/storybook/src/decorators/withPostMessageMock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { Decorator } from "@storybook/react-vite"
import React from "react"

type PostMessage = Record<string, unknown>

/**
* Decorator to mock VSCode postMessage for components that listen to messages.
*
* To override in a story, use parameters.postMessages:
* ```tsx
* export const MyStory: Story = {
* parameters: {
* postMessages: [
* { type: "kilocodeNotificationsResponse", notifications: [...] },
* ],
* },
* }
* ```
*
* Multiple messages are sent sequentially
*/
export const withPostMessageMock: Decorator = (Story, context) => {
const messages = context.parameters?.postMessages as PostMessage[] | undefined

React.useEffect(() => {
if (!messages || messages.length === 0) {
return
}

const timers: NodeJS.Timeout[] = []
messages.forEach((message, index) => {
const event = new MessageEvent("message", { data: message })
const timer = setTimeout(() => {
window.dispatchEvent(event)
})
timers.push(timer)
})

return () => timers.forEach(clearTimeout)
}, [messages])

return <Story />
}
5 changes: 1 addition & 4 deletions apps/storybook/src/utils/createExtensionStateMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ export const createExtensionStateMock = (
): ExtensionStateContextType => {
// Only define properties that Storybook stories actually use
const knownProperties: Partial<ExtensionStateContextType> = {
// Add properties here as they're needed in stories
// For example:
// theme: {},
// apiConfiguration: null,
kilocodeDefaultModel: "claude-sonnet-4",
}

// Merge with overrides
Expand Down
71 changes: 71 additions & 0 deletions apps/storybook/stories/KilocodeNotifications.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import type { Meta, StoryObj } from "@storybook/react-vite"
import { fn } from "storybook/test"
import { KilocodeNotifications } from "@/components/kilocode/KilocodeNotifications"

const meta = {
title: "Components/KilocodeNotifications",
component: KilocodeNotifications,
parameters: {
extensionState: {
dismissedNotificationIds: [],
},
},
args: {
onDismiss: fn(),
},
} satisfies Meta<typeof KilocodeNotifications>

export default meta
type Story = StoryObj<typeof meta>

const defaultNotification = {
id: "1",
title: "Welcome to Kilo Code!",
message: "Get started by setting up your API configuration in the settings.",
action: {
actionText: "Open Settings",
actionURL: "https://example.com/settings",
},
}

export const Default: Story = {
parameters: {
postMessages: [
{
type: "kilocodeNotificationsResponse",
notifications: [defaultNotification],
},
],
},
}

export const MultipleNotifications: Story = {
parameters: {
postMessages: [
{
type: "kilocodeNotificationsResponse",
notifications: [
{
id: "1",
title: "First Notification",
message: "This is the first notification in a series.",
},
{
id: "2",
title: "Second Notification",
message: "You can navigate between notifications using the arrows.",
},
{
id: "3",
title: "Third Notification",
message: "This is the last notification in this set.",
action: {
actionText: "Visit Website",
actionURL: "https://example.com",
},
},
],
},
],
},
}
1 change: 0 additions & 1 deletion packages/types/src/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const historyItemSchema = z.object({
size: z.number().optional(),
workspace: z.string().optional(),
isFavorited: z.boolean().optional(), // kilocode_change
fileNotfound: z.boolean().optional(), // kilocode_change
mode: z.string().optional(),
status: z.enum(["active", "completed", "delegated"]).optional(),
delegatedToId: z.string().optional(), // Last child this parent delegated to
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

111 changes: 0 additions & 111 deletions src/api/providers/__tests__/fetch-with-timeout.spec.ts

This file was deleted.

7 changes: 1 addition & 6 deletions src/api/providers/base-openai-compatible-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { DEFAULT_HEADERS } from "./constants"
import { BaseProvider } from "./base-provider"
import { verifyFinishReason } from "./kilocode/verifyFinishReason"
import { handleOpenAIError } from "./utils/openai-error-handler"
import { fetchWithTimeout } from "./kilocode/fetchWithTimeout" // kilocode_change
import { calculateApiCostOpenAI } from "../../shared/cost"
import { getApiRequestTimeout } from "./utils/timeout-config"

Expand Down Expand Up @@ -61,15 +60,11 @@ export abstract class BaseOpenAiCompatibleProvider<ModelName extends string>
throw new Error("API key is required")
}

const timeout = getApiRequestTimeout() // kilocode_change
this.client = new OpenAI({
baseURL,
apiKey: this.options.apiKey,
defaultHeaders: DEFAULT_HEADERS,
// kilocode_change start
timeout: timeout,
fetch: timeout ? fetchWithTimeout(timeout) : undefined,
// kilocode_change end
timeout: getApiRequestTimeout(),
})
}

Expand Down
25 changes: 0 additions & 25 deletions src/api/providers/kilocode/fetchWithTimeout.ts

This file was deleted.

8 changes: 4 additions & 4 deletions src/api/providers/kilocode/getKilocodeDefaultModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { openRouterDefaultModelId, type ProviderSettings } from "@roo-code/types
import { getKiloUrlFromToken } from "@roo-code/types"
import { TelemetryService } from "@roo-code/telemetry"
import { z } from "zod"
import { fetchWithTimeout } from "./fetchWithTimeout"
import { DEFAULT_HEADERS } from "../constants"

type KilocodeToken = string
Expand All @@ -15,8 +14,6 @@ const defaultsSchema = z.object({
defaultModel: z.string().nullish(),
})

const fetcher = fetchWithTimeout(5000)

async function fetchKilocodeDefaultModel(
kilocodeToken: KilocodeToken,
organizationId?: OrganizationId,
Expand All @@ -39,7 +36,10 @@ async function fetchKilocodeDefaultModel(
headers["X-KILOCODE-TESTER"] = "SUPPRESS"
}

const response = await fetcher(url, { headers })
const controller = new AbortController()
const timeout = setTimeout(() => controller.abort(), 5000)
const response = await fetch(url, { headers, signal: controller.signal })
clearTimeout(timeout)
if (!response.ok) {
throw new Error(`Fetching default model from ${url} failed: ${response.status}`)
}
Expand Down
Loading