Skip to content
Closed
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
2 changes: 1 addition & 1 deletion packages/tui/src/feature-plugins/sidebar/lsp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createMemo, For, Show, createSignal } from "solid-js"

const id = "internal:sidebar-lsp"

function View(props: { api: TuiPluginApi }) {
export function View(props: { api: TuiPluginApi }) {
const [open, setOpen] = createSignal(true)
const theme = () => props.api.theme.current
const list = createMemo(() => props.api.state.lsp())
Expand Down
49 changes: 49 additions & 0 deletions packages/tui/test/feature-plugins/sidebar-lsp.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/** @jsxImportSource @opentui/solid */
import { expect, test } from "bun:test"
import { testRender } from "@opentui/solid"
import { RGBA } from "@opentui/core"
import type { TuiPluginApi } from "@opencode-ai/plugin/tui"
import { View } from "../../src/feature-plugins/sidebar/lsp"

function createApi(opts: {
lspEnabled: boolean
servers?: Array<{ id: string; root: string; status: "connected" | "disconnected" }>
}) {
const color = RGBA.fromInts(200, 200, 200)
return {
theme: { current: new Proxy({}, { get: () => color }) },
state: {
config: { lsp: opts.lspEnabled ? {} : undefined },
lsp: () => opts.servers ?? [],
},
} as unknown as TuiPluginApi
}

async function frame(api: TuiPluginApi) {
const app = await testRender(() => <View api={api} />, { width: 40, height: 10 })
try {
await app.renderOnce()
return app.captureCharFrame()
} finally {
app.renderer.destroy()
}
}

test("hides the whole LSP section when config.lsp is disabled", async () => {
expect(await frame(createApi({ lspEnabled: false }))).not.toContain("LSP")
})

test("renders the LSP heading and empty state when enabled", async () => {
const output = await frame(createApi({ lspEnabled: true }))
expect(output).toContain("LSP")
expect(output).toContain("LSPs will activate as files are read")
})

test("lists connected servers when enabled", async () => {
const output = await frame(
createApi({ lspEnabled: true, servers: [{ id: "typescript", root: "/work", status: "connected" }] }),
)
expect(output).toContain("LSP")
expect(output).toContain("typescript")
expect(output).not.toContain("LSPs will activate")
})
Loading