diff --git a/packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/ui/md/MdViewTest.kt b/packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/ui/md/MdViewTest.kt index 16ba83868a..39109bc8bb 100644 --- a/packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/ui/md/MdViewTest.kt +++ b/packages/kilo-jetbrains/frontend/src/test/kotlin/ai/kilocode/client/ui/md/MdViewTest.kt @@ -1,7 +1,6 @@ package ai.kilocode.client.ui.md import ai.kilocode.client.session.ui.style.SessionEditorStyle -import ai.kilocode.client.session.ui.style.SessionUiStyle import com.intellij.openapi.editor.DefaultLanguageHighlighterColors import com.intellij.openapi.editor.HighlighterColors import com.intellij.openapi.editor.colors.CodeInsightColors @@ -64,11 +63,8 @@ class MdViewTest : BasePlatformTestCase() { fun `test set renders inline code`() { view.set("use `foo()` here") - val color = MdCommon.hex(MdCommon.defaults(SessionEditorStyle.current()).inlineCodeFg) - val html = view.html() - - assertTrue(html.contains("foo()")) - assertFalse(html.contains("")) + assertTrue(view.html().contains("foo()")) } fun `test set renders fenced code block`() { @@ -83,57 +79,6 @@ class MdViewTest : BasePlatformTestCase() { assertTrue(view.html().contains("https://example.com")) } - fun `test set renders prose file refs as underlined brown links`() { - view.set("See packages/opencode/src/session/prompt.ts") - val color = MdCommon.hex(SessionUiStyle.View.Markdown.string()) - val html = view.html() - val sheet = view.overrideSheet() - - assertTrue(html.contains("packages/opencode/src/session/prompt.ts")) - assertTrue(sheet.contains("a.kilo-file-ref, code a.kilo-file-ref { color: $color; font-family:")) - assertTrue(sheet.contains("monospace; text-decoration: underline")) - } - - fun `test inline code file refs keep code color and become file links`() { - view.set("See `packages/opencode/src/session/prompt.ts`") - val color = MdCommon.hex(SessionUiStyle.View.Markdown.string()) - val html = view.html() - - assertTrue(html.contains("packages/opencode/src/session/prompt.ts")) - assertFalse(html.contains("background:")) - } - - fun `test file refs keep line suffix and trailing punctuation outside link`() { - view.set("See kilocode/session/prompt.ts:302 and native-plan-prompt.txt:37-38.") - val html = view.html() - - assertTrue(html.contains("href=\"kilocode/session/prompt.ts:302\">kilocode/session/prompt.ts:302")) - assertTrue(html.contains("href=\"native-plan-prompt.txt:37-38\">native-plan-prompt.txt:37-38.")) - } - - fun `test framework names are not file ref links`() { - view.set("Next.js, Node.js, Vue.js, and Chart.js are framework names, not paths.") - val html = view.html() - - assertFalse(html.contains("kilo-file-ref")) - } - - fun `test existing markdown links are not file ref links`() { - view.set("[prompt](packages/opencode/src/session/prompt.ts)") - val html = view.html() - - assertTrue(html.contains("prompt")) - assertFalse(html.contains("kilo-file-ref")) - } - - fun `test fenced code file refs are not file ref links`() { - view.set("```text\npackages/opencode/src/session/prompt.ts\n```") - val html = view.html() - - assertTrue(html.contains("packages/opencode/src/session/prompt.ts")) - assertFalse(html.contains("kilo-file-ref")) - } - fun `test set renders headings`() { view.set("# Title") assertTrue(view.html().contains("

")) @@ -268,7 +213,7 @@ class MdViewTest : BasePlatformTestCase() { assertTrue(html.contains("

")) assertTrue(html.contains("")) assertTrue(html.contains("")) - assertTrue(html.contains("")) assertTrue(html.contains("
    ")) assertTrue(html.contains("
    "))
             assertTrue(html.contains("
    ")) @@ -320,22 +265,14 @@ class MdViewTest : BasePlatformTestCase() { fun `test applyStyle derives markdown colors from editor scheme`() { val style = customStyle() - val color = MdCommon.hex(SessionUiStyle.View.Markdown.string()) - val quote = "#445566" view.applyStyle(style) - view.set("use `inline` code") val sheet = view.overrideSheet() - val html = view.html() assertTrue(sheet.contains("a { color: #778899")) - assertTrue(html.contains("inline")) - assertFalse(html.contains("background: #112233")) - assertFalse(html.contains("#cc8866")) + assertTrue(sheet.contains("code { background: #112233; color: #aabbcc")) assertTrue(sheet.contains("pre { background: #445566; color: #ddeeff; border-color: #223344")) - assertTrue(sheet.contains("blockquote { background:")) - assertTrue(sheet.contains("border-left-color: #223344; color: $quote")) - assertTrue(sheet.contains("blockquote p { color: $quote")) + assertTrue(sheet.contains("blockquote { border-left-color: #223344; color: #334455")) assertTrue(sheet.contains("th, td { border-color: #223344")) } @@ -353,11 +290,10 @@ class MdViewTest : BasePlatformTestCase() { assertTrue(view.overrideSheet().contains("#ff0077")) } - fun `test code bg override does not add inline code background`() { + fun `test code bg override appears in override sheet`() { view.codeBg = Color(0x10, 0x20, 0x30) view.set("`code`") - assertFalse(view.overrideSheet().contains("#102030")) - assertFalse(view.html().contains("#102030")) + assertTrue(view.overrideSheet().contains("#102030")) } fun `test pre bg and fg overrides appear in override sheet`() { @@ -373,23 +309,7 @@ class MdViewTest : BasePlatformTestCase() { fun `test code font override appears in override sheet`() { view.codeFont = "Fira Code" view.set("`x`") - val sheet = view.overrideSheet() - - assertTrue(sheet.contains("tt, code, samp, pre, pre code { font-family: 'Fira Code', monospace")) - assertTrue(sheet.contains("a.kilo-file-ref, code a.kilo-file-ref { color:")) - assertTrue(sheet.contains("font-family: 'Fira Code', monospace; text-decoration: underline")) - } - - fun `test prose keeps transcript font while inline code uses editor font`() { - val style = SessionEditorStyle.create(family = "Courier New", size = 21) - - view.applyStyle(style) - view.set("hello `code` packages/opencode/src/session/prompt.ts") - val sheet = view.overrideSheet() - - assertTrue(sheet.contains("body { color:")) - assertTrue(sheet.contains("font-family: '${style.transcriptFont.name}', sans-serif")) - assertTrue(sheet.contains("tt, code, samp, pre, pre code { font-family: 'Courier New', monospace")) + assertTrue(view.overrideSheet().contains("Fira Code")) } fun `test blockquote color overrides appear in override sheet`() { @@ -578,18 +498,10 @@ class MdViewTest : BasePlatformTestCase() { DefaultLanguageHighlighterColors.DOC_COMMENT, TextAttributes(Color(0x33, 0x44, 0x55), null, null, null, Font.PLAIN), ) - scheme.setAttributes( - DefaultLanguageHighlighterColors.LINE_COMMENT, - TextAttributes(Color(0x44, 0x55, 0x66), null, null, null, Font.PLAIN), - ) scheme.setAttributes( DefaultLanguageHighlighterColors.DOC_CODE_INLINE, TextAttributes(Color(0xAA, 0xBB, 0xCC), Color(0x11, 0x22, 0x33), null, null, Font.PLAIN), ) - scheme.setAttributes( - DefaultLanguageHighlighterColors.STRING, - TextAttributes(Color(0xCC, 0x88, 0x66), null, null, null, Font.PLAIN), - ) scheme.setAttributes( DefaultLanguageHighlighterColors.DOC_CODE_BLOCK, TextAttributes(Color(0xDD, 0xEE, 0xFF), Color(0x44, 0x55, 0x66), null, null, Font.PLAIN), diff --git a/packages/opencode/test/session/prompt.test.ts b/packages/opencode/test/session/prompt.test.ts index db4219ca6b..9229c64944 100644 --- a/packages/opencode/test/session/prompt.test.ts +++ b/packages/opencode/test/session/prompt.test.ts @@ -346,18 +346,20 @@ const useServerConfig = Effect.fn("test.useServerConfig")(function* (config: (ur return { dir, llm } }) -// kilocode_change start - wait for the runner state that cancel observes instead of session status +// Wait for a session's runner to enter a busy state. SessionStatus is flipped to +// "busy" inside Runner.startShell's modifyEffect at the same moment the runner +// is registered, so this is a deterministic readiness signal — cancel can't +// no-op once we observe it. const waitForBusy = (sessionID: SessionID, duration: Duration.Input = "2 seconds") => pollWithTimeout( Effect.gen(function* () { - const run = yield* SessionRunState.Service - const exit = yield* run.assertNotBusy(sessionID).pipe(Effect.exit) - return Exit.isFailure(exit) ? (true as const) : undefined + const status = yield* SessionStatus.Service + const s = yield* status.get(sessionID) + return s.type === "busy" ? (true as const) : undefined }), `session ${sessionID} never became busy`, duration, ) -// kilocode_change end const hasBash = Effect.sync(() => Bun.which("bash") !== null)