diff --git a/.changeset/rude-dots-grab.md b/.changeset/rude-dots-grab.md new file mode 100644 index 0000000000..14156dcff3 --- /dev/null +++ b/.changeset/rude-dots-grab.md @@ -0,0 +1,6 @@ +--- +"@gradio/chatbot": patch +"gradio": patch +--- + +fix:fix pending chatbot message styling and ensure messages with value `None` don't render diff --git a/js/chatbot/Chatbot.test.ts b/js/chatbot/Chatbot.test.ts index bcc973cc57..07c5aa9186 100644 --- a/js/chatbot/Chatbot.test.ts +++ b/js/chatbot/Chatbot.test.ts @@ -36,8 +36,8 @@ describe("Chatbot", () => { assert.exists(user); }); - test("renders none messages", async () => { - const { getAllByTestId } = await render(Chatbot, { + test("null messages are not visible", async () => { + const { getByRole, container } = await render(Chatbot, { loading_status, label: "chatbot", value: [[null, null]], @@ -47,10 +47,33 @@ describe("Chatbot", () => { theme_mode: "dark" }); - const user = getAllByTestId("user"); - const bot = getAllByTestId("bot"); - assert.isFalse(user[0].innerHTML.includes("span")); - assert.isFalse(bot[0].innerHTML.includes("span")); + const chatbot = getByRole("log"); + + const userButton = container.querySelector(".user button"); + const botButton = container.querySelector(".bot button"); + + assert.notExists(userButton); + assert.notExists(botButton); + + assert.isFalse(chatbot.innerHTML.includes("button")); + }); + + test("empty string messages are visible", async () => { + const { container } = await render(Chatbot, { + loading_status, + label: "chatbot", + value: [["", ""]], + root: "", + root_url: "", + latex_delimiters: [{ left: "$$", right: "$$", display: true }], + theme_mode: "dark" + }); + + const userButton = container.querySelector(".user button"); + const botButton = container.querySelector(".bot button"); + + assert.exists(userButton); + assert.exists(botButton); }); test("renders additional message as they are passed", async () => { diff --git a/js/chatbot/static/ChatBot.svelte b/js/chatbot/static/ChatBot.svelte index 3a6cf702fb..fa7d1b7dfa 100644 --- a/js/chatbot/static/ChatBot.svelte +++ b/js/chatbot/static/ChatBot.svelte @@ -121,131 +121,131 @@ {#if value !== null} {#each value as message_pair, i} {#each message_pair as message, j} -
+ {/if} {/each} {/each} {/if} -