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/tui-toast-title-leak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kilocode/cli": patch
---

Stop leftover toast titles from appearing when installing a TUI update.
3 changes: 2 additions & 1 deletion packages/tui/src/ui/toast.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createContext, useContext, type ParentProps, Show } from "solid-js"
import { createStore } from "solid-js/store"
import { reconcile } from "solid-js/store" // kilocode_change
import { useTheme } from "../context/theme"
import { useTerminalDimensions } from "@opentui/solid"
import { SplitBorder } from "./border"
Expand Down Expand Up @@ -60,7 +61,7 @@ function init() {
const toast = {
show(options: ToastInput) {
const toastOptions = { ...options, duration: options.duration ?? 5000 }
setStore("currentToast", toastOptions)
setStore("currentToast", reconcile(toastOptions)) // kilocode_change
if (timeoutHandle) clearTimeout(timeoutHandle)
// kilocode_change start
timeoutHandle = null
Expand Down
37 changes: 37 additions & 0 deletions packages/tui/test/kilocode/toast.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/** @jsxImportSource @opentui/solid */
import { expect, test } from "bun:test"
import { testRender } from "@opentui/solid"
import { ToastProvider, useToast } from "../../src/ui/toast"

test("replacing a toast does not keep the previous title", async () => {
let toast: ReturnType<typeof useToast>
function Probe() {
toast = useToast()
return <box />
}

const app = await testRender(() => (
<ToastProvider>
<Probe />
</ToastProvider>
))

try {
toast!.show({
title: "MCP Authentication Required",
message: `Server "foo" requires authentication.`,
variant: "warning",
duration: 0,
})
toast!.show({
variant: "info",
message: "Updating to v7.4.21...",
duration: 0,
})
expect(toast!.currentToast?.title).toBeUndefined()
expect(toast!.currentToast?.message).toBe("Updating to v7.4.21...")
expect(toast!.currentToast?.variant).toBe("info")
} finally {
app.renderer.destroy()
}
})
Loading