diff --git a/gui/src/components/StyledMarkdownPreview/utils/commandExtractor.test.ts b/gui/src/components/StyledMarkdownPreview/utils/commandExtractor.test.ts index 1d1d6099c..e7505f310 100644 --- a/gui/src/components/StyledMarkdownPreview/utils/commandExtractor.test.ts +++ b/gui/src/components/StyledMarkdownPreview/utils/commandExtractor.test.ts @@ -1,80 +1,96 @@ -import { extractCommand } from './commandExtractor'; +import { extractCommand } from "./commandExtractor"; -describe('extractCommand', () => { +describe("extractCommand", () => { // Test basic command extraction - it('should extract command from $ prompt', () => { - expect(extractCommand('$ echo hello')).toBe('echo hello'); - expect(extractCommand('$ echo hello')).toBe('echo hello'); - expect(extractCommand('$echo hello')).toBe('echo hello'); + it("should extract command from $ prompt", () => { + expect(extractCommand("$ echo hello")).toBe("echo hello"); + expect(extractCommand("$ echo hello")).toBe("echo hello"); + expect(extractCommand("$echo hello")).toBe("echo hello"); }); // Test comment removal - it('should remove comments at beginning of lines', () => { - expect(extractCommand('# shell comment\necho hello')).toBe('echo hello'); - expect(extractCommand('// js comment\necho hello')).toBe('echo hello'); - expect(extractCommand('/* multi-line\ncomment */\necho hello')).toBe('echo hello'); + it("should remove comments at beginning of lines", () => { + expect(extractCommand("# shell comment\necho hello")).toBe("echo hello"); + expect(extractCommand("// js comment\necho hello")).toBe("echo hello"); + expect(extractCommand("/* multi-line\ncomment */\necho hello")).toBe( + "echo hello", + ); }); // Test multiline comment removal - it('should remove multiline comments anywhere in the text', () => { - expect(extractCommand('echo /* comment */ hello')).toBe('echo hello'); - expect(extractCommand('echo hello /* comment */')).toBe('echo hello'); - expect(extractCommand('echo /* multiple\nline\ncomment */ hello')).toBe('echo hello'); + it("should remove multiline comments anywhere in the text", () => { + expect(extractCommand("echo /* comment */ hello")).toBe("echo hello"); + expect(extractCommand("echo hello /* comment */")).toBe("echo hello"); + expect(extractCommand("echo /* multiple\nline\ncomment */ hello")).toBe( + "echo hello", + ); }); // Test line continuation handling - it('should handle line continuations correctly', () => { - expect(extractCommand('echo hello && \\\necho world')).toBe('echo hello && echo world'); - expect(extractCommand('echo hello | \\\ngrep h')).toBe('echo hello | grep h'); - expect(extractCommand('echo hello \\\nworld')).toBe('echo hello world'); + it("should handle line continuations correctly", () => { + expect(extractCommand("echo hello && \\\necho world")).toBe( + "echo hello && echo world", + ); + expect(extractCommand("echo hello | \\\ngrep h")).toBe( + "echo hello | grep h", + ); + expect(extractCommand("echo hello \\\nworld")).toBe("echo hello world"); }); // Test complex command combinations - it('should handle complex command combinations', () => { - expect(extractCommand(` + it("should handle complex command combinations", () => { + expect( + extractCommand(` # shell comment echo hello /* inline comment */ && \\ // js comment echo world - `)).toBe('echo hello && echo world'); + `), + ).toBe("echo hello && echo world"); }); // Test empty and whitespace handling - it('should handle empty and whitespace inputs', () => { - expect(extractCommand('')).toBe(''); - expect(extractCommand(' \n \t ')).toBe(''); + it("should handle empty and whitespace inputs", () => { + expect(extractCommand("")).toBe(""); + expect(extractCommand(" \n \t ")).toBe(""); }); // Test comment-only inputs - it('should handle comment-only inputs', () => { - expect(extractCommand('/* comment */')).toBe(''); - expect(extractCommand('# comment')).toBe(''); - expect(extractCommand('// comment')).toBe(''); - expect(extractCommand('/* multi\nline\ncomment */')).toBe(''); + it("should handle comment-only inputs", () => { + expect(extractCommand("/* comment */")).toBe(""); + expect(extractCommand("# comment")).toBe(""); + expect(extractCommand("// comment")).toBe(""); + expect(extractCommand("/* multi\nline\ncomment */")).toBe(""); }); // Test inline comments - it('should handle inline comments correctly according to implementation', () => { + it("should handle inline comments correctly according to implementation", () => { // But removes multiline comments even when inline - expect(extractCommand('/* inline */ echo hello world')).toBe('echo hello world'); + expect(extractCommand("/* inline */ echo hello world")).toBe( + "echo hello world", + ); }); // Test multiple line continuations - it('should handle multiple line continuations', () => { - expect(extractCommand(` + it("should handle multiple line continuations", () => { + expect( + extractCommand(` echo hello && \\ echo world && \\ echo test - `)).toBe('echo hello && echo world && echo test'); + `), + ).toBe("echo hello && echo world && echo test"); }); // Test nested line continuations - it('should handle nested line continuations', () => { - expect(extractCommand(` + it("should handle nested line continuations", () => { + expect( + extractCommand(` echo hello && \\ (echo nested && \\ echo more) && \\ echo final - `)).toBe('echo hello && (echo nested && echo more) && echo final'); + `), + ).toBe("echo hello && (echo nested && echo more) && echo final"); }); -}); \ No newline at end of file +}); diff --git a/gui/src/components/StyledMarkdownPreview/utils/commandExtractor.ts b/gui/src/components/StyledMarkdownPreview/utils/commandExtractor.ts index 35075b6bd..533410efb 100644 --- a/gui/src/components/StyledMarkdownPreview/utils/commandExtractor.ts +++ b/gui/src/components/StyledMarkdownPreview/utils/commandExtractor.ts @@ -4,10 +4,10 @@ * @returns The processed command string */ export function extractCommand(cmd: string): string { - if (!cmd || cmd.trim() === '') { - return ''; + if (!cmd || cmd.trim() === "") { + return ""; } - + // Remove multi-line comments (/* ... */) and replace with a single space cmd = cmd.replace(/\/\*[\s\S]*?\*\//g, " "); @@ -21,30 +21,31 @@ export function extractCommand(cmd: string): string { } // Process lines - remove single-line comments only at beginning of lines - const lines = cmd.split('\n') - .map(line => line.replace(/^\s*#.*$/, '').replace(/^\s*\/\/.*$/, '')) - .map(line => line.trim()) - .filter(line => line); + const lines = cmd + .split("\n") + .map((line) => line.replace(/^\s*#.*$/, "").replace(/^\s*\/\/.*$/, "")) + .map((line) => line.trim()) + .filter((line) => line); // Join lines with proper handling of continuations - let result = ''; + let result = ""; for (let i = 0; i < lines.length; i++) { let line = lines[i]; // Remove trailing continuation characters and join with next line while ( - (line.endsWith('&&') || line.endsWith('|') || line.endsWith('\\')) && + (line.endsWith("&&") || line.endsWith("|") || line.endsWith("\\")) && i < lines.length - 1 ) { // Remove the continuation character(s) and any trailing spaces - line = line.replace(/(&&|\||\\)\s*$/, '').trim(); + line = line.replace(/(&&|\||\\)\s*$/, "").trim(); // Join with the next line i++; - line += ' ' + lines[i]; + line += " " + lines[i]; } - result += line + ' '; + result += line + " "; } - return result.trim().replace(/\s+/g, ' '); -} \ No newline at end of file + return result.trim().replace(/\s+/g, " "); +} diff --git a/gui/src/components/StyledMarkdownPreview/utils/headerIsMarkdown.test.ts b/gui/src/components/StyledMarkdownPreview/utils/headerIsMarkdown.test.ts index a0643d3d3..51649c251 100644 --- a/gui/src/components/StyledMarkdownPreview/utils/headerIsMarkdown.test.ts +++ b/gui/src/components/StyledMarkdownPreview/utils/headerIsMarkdown.test.ts @@ -1,65 +1,67 @@ -import { headerIsMarkdown } from './headerIsMarkdown'; +import { headerIsMarkdown } from "./headerIsMarkdown"; -describe('headerIsMarkdown', () => { +describe("headerIsMarkdown", () => { // Test exact match with common Markdown identifiers - it('should identify exact matches with common Markdown identifiers', () => { - expect(headerIsMarkdown('md')).toBe(true); - expect(headerIsMarkdown('markdown')).toBe(true); - expect(headerIsMarkdown('gfm')).toBe(true); - expect(headerIsMarkdown('github-markdown')).toBe(true); + it("should identify exact matches with common Markdown identifiers", () => { + expect(headerIsMarkdown("md")).toBe(true); + expect(headerIsMarkdown("markdown")).toBe(true); + expect(headerIsMarkdown("gfm")).toBe(true); + expect(headerIsMarkdown("github-markdown")).toBe(true); }); // Test identifiers preceded by a space - it('should identify identifiers preceded by a space', () => { - expect(headerIsMarkdown('lang md')).toBe(true); - expect(headerIsMarkdown('something markdown')).toBe(true); - expect(headerIsMarkdown('language gfm')).toBe(true); - expect(headerIsMarkdown('spec github-markdown')).toBe(true); + it("should identify identifiers preceded by a space", () => { + expect(headerIsMarkdown("lang md")).toBe(true); + expect(headerIsMarkdown("something markdown")).toBe(true); + expect(headerIsMarkdown("language gfm")).toBe(true); + expect(headerIsMarkdown("spec github-markdown")).toBe(true); }); // Test file extensions - it('should identify file names with markdown extensions', () => { - expect(headerIsMarkdown('example.md')).toBe(true); - expect(headerIsMarkdown('document.markdown')).toBe(true); - expect(headerIsMarkdown('readme.gfm')).toBe(true); + it("should identify file names with markdown extensions", () => { + expect(headerIsMarkdown("example.md")).toBe(true); + expect(headerIsMarkdown("document.markdown")).toBe(true); + expect(headerIsMarkdown("readme.gfm")).toBe(true); }); // Test more complex cases with extensions - it('should identify file names with markdown extensions followed by other text', () => { - expect(headerIsMarkdown('example.md additional text')).toBe(true); - expect(headerIsMarkdown('document.markdown with some description')).toBe(true); - expect(headerIsMarkdown('readme.gfm v2.0')).toBe(true); + it("should identify file names with markdown extensions followed by other text", () => { + expect(headerIsMarkdown("example.md additional text")).toBe(true); + expect(headerIsMarkdown("document.markdown with some description")).toBe( + true, + ); + expect(headerIsMarkdown("readme.gfm v2.0")).toBe(true); }); // Test non-markdown cases - it('should not identify non-markdown headers', () => { - expect(headerIsMarkdown('javascript')).toBe(false); - expect(headerIsMarkdown('typescript')).toBe(false); - expect(headerIsMarkdown('plain')).toBe(false); - expect(headerIsMarkdown('python')).toBe(false); + it("should not identify non-markdown headers", () => { + expect(headerIsMarkdown("javascript")).toBe(false); + expect(headerIsMarkdown("typescript")).toBe(false); + expect(headerIsMarkdown("plain")).toBe(false); + expect(headerIsMarkdown("python")).toBe(false); }); // Test edge cases - it('should handle edge cases correctly', () => { - expect(headerIsMarkdown('')).toBe(false); - expect(headerIsMarkdown('mdx')).toBe(false); // Similar but not exactly "md" - expect(headerIsMarkdown('readme md')).toBe(true); - expect(headerIsMarkdown('md.js')).toBe(false); // "md" is not the extension + it("should handle edge cases correctly", () => { + expect(headerIsMarkdown("")).toBe(false); + expect(headerIsMarkdown("mdx")).toBe(false); // Similar but not exactly "md" + expect(headerIsMarkdown("readme md")).toBe(true); + expect(headerIsMarkdown("md.js")).toBe(false); // "md" is not the extension }); // Test case sensitivity - it('should respect case sensitivity', () => { - expect(headerIsMarkdown('MD')).toBe(false); - expect(headerIsMarkdown('MARKDOWN')).toBe(false); - expect(headerIsMarkdown('example.MD')).toBe(false); - expect(headerIsMarkdown('lang MD')).toBe(false); + it("should respect case sensitivity", () => { + expect(headerIsMarkdown("MD")).toBe(false); + expect(headerIsMarkdown("MARKDOWN")).toBe(false); + expect(headerIsMarkdown("example.MD")).toBe(false); + expect(headerIsMarkdown("lang MD")).toBe(false); }); // Test with special characters and spacing - it('should handle special characters and spacing correctly', () => { - expect(headerIsMarkdown(' md')).toBe(true); // Space before "md" - expect(headerIsMarkdown('md ')).toBe(true); // Space after "md" - expect(headerIsMarkdown('hello-md')).toBe(false); // "md" with hyphen prefix - expect(headerIsMarkdown('markdown:')).toBe(false); // "markdown" with suffix + it("should handle special characters and spacing correctly", () => { + expect(headerIsMarkdown(" md")).toBe(true); // Space before "md" + expect(headerIsMarkdown("md ")).toBe(true); // Space after "md" + expect(headerIsMarkdown("hello-md")).toBe(false); // "md" with hyphen prefix + expect(headerIsMarkdown("markdown:")).toBe(false); // "markdown" with suffix }); -}); \ No newline at end of file +}); diff --git a/gui/src/components/StyledMarkdownPreview/utils/headerIsMarkdown.ts b/gui/src/components/StyledMarkdownPreview/utils/headerIsMarkdown.ts index 7325f3a43..cfdba2fde 100644 --- a/gui/src/components/StyledMarkdownPreview/utils/headerIsMarkdown.ts +++ b/gui/src/components/StyledMarkdownPreview/utils/headerIsMarkdown.ts @@ -19,8 +19,8 @@ export function headerIsMarkdown(header: string): boolean { header.includes(" markdown") || header.includes(" gfm") || header.includes(" github-markdown") || - (header.split(" ")[0]?.split(".").pop() === "md") || - (header.split(" ")[0]?.split(".").pop() === "markdown") || - (header.split(" ")[0]?.split(".").pop() === "gfm") + header.split(" ")[0]?.split(".").pop() === "md" || + header.split(" ")[0]?.split(".").pop() === "markdown" || + header.split(" ")[0]?.split(".").pop() === "gfm" ); -} \ No newline at end of file +} diff --git a/gui/src/components/StyledMarkdownPreview/utils/patchNestedMarkdown.test.ts b/gui/src/components/StyledMarkdownPreview/utils/patchNestedMarkdown.test.ts index 982517bf5..af94f118d 100644 --- a/gui/src/components/StyledMarkdownPreview/utils/patchNestedMarkdown.test.ts +++ b/gui/src/components/StyledMarkdownPreview/utils/patchNestedMarkdown.test.ts @@ -1,105 +1,109 @@ -import { patchNestedMarkdown } from './patchNestedMarkdown'; +import { patchNestedMarkdown } from "./patchNestedMarkdown"; -describe('patchNestedMarkdown', () => { - it('should return unchanged content when no markdown codeblocks are present', () => { +describe("patchNestedMarkdown", () => { + it("should return unchanged content when no markdown codeblocks are present", () => { const source = 'Regular text\n```javascript\nconsole.log("hello");\n```'; expect(patchNestedMarkdown(source)).toBe(source); }); - it('should replace backticks with tildes for markdown codeblocks', () => { - const source = '```markdown\n# Header\nSome text\n```'; - const expected = '~~~markdown\n# Header\nSome text\n~~~'; + it("should replace backticks with tildes for markdown codeblocks", () => { + const source = "```markdown\n# Header\nSome text\n```"; + const expected = "~~~markdown\n# Header\nSome text\n~~~"; expect(patchNestedMarkdown(source)).toBe(expected); }); - it('should handle nested codeblocks within markdown blocks', () => { - const source = '```markdown\n# Example\n```js\nconsole.log("nested");\n```\n```'; - const expected = '~~~markdown\n# Example\n```js\nconsole.log("nested");\n```\n~~~'; + it("should handle nested codeblocks within markdown blocks", () => { + const source = + '```markdown\n# Example\n```js\nconsole.log("nested");\n```\n```'; + const expected = + '~~~markdown\n# Example\n```js\nconsole.log("nested");\n```\n~~~'; expect(patchNestedMarkdown(source)).toBe(expected); }); - it('should handle .md file extension', () => { - const source = '```test.md\nContent\n```'; - const expected = '~~~test.md\nContent\n~~~'; + it("should handle .md file extension", () => { + const source = "```test.md\nContent\n```"; + const expected = "~~~test.md\nContent\n~~~"; expect(patchNestedMarkdown(source)).toBe(expected); }); - it('should handle multiple levels of nesting', () => { - const source = '```markdown\n# Doc\n```js\nlet x = "```nested```";\n```\n```'; - const expected = '~~~markdown\n# Doc\n```js\nlet x = "```nested```";\n```\n~~~'; + it("should handle multiple levels of nesting", () => { + const source = + '```markdown\n# Doc\n```js\nlet x = "```nested```";\n```\n```'; + const expected = + '~~~markdown\n# Doc\n```js\nlet x = "```nested```";\n```\n~~~'; expect(patchNestedMarkdown(source)).toBe(expected); }); - it('should handle blocks that start with md', () => { - const source = '```md\n# Header\nSome text\n```'; - const expected = '~~~md\n# Header\nSome text\n~~~'; + it("should handle blocks that start with md", () => { + const source = "```md\n# Header\nSome text\n```"; + const expected = "~~~md\n# Header\nSome text\n~~~"; expect(patchNestedMarkdown(source)).toBe(expected); }); - it('should handle blocks with language specifier followed by md', () => { - const source = '```lang md\n# Header\nSome text\n```'; - const expected = '~~~lang md\n# Header\nSome text\n~~~'; + it("should handle blocks with language specifier followed by md", () => { + const source = "```lang md\n# Header\nSome text\n```"; + const expected = "~~~lang md\n# Header\nSome text\n~~~"; expect(patchNestedMarkdown(source)).toBe(expected); }); - it('should handle blocks with language specifier followed by markdown', () => { - const source = '```lang markdown\n# Header\nSome text\n```'; - const expected = '~~~lang markdown\n# Header\nSome text\n~~~'; + it("should handle blocks with language specifier followed by markdown", () => { + const source = "```lang markdown\n# Header\nSome text\n```"; + const expected = "~~~lang markdown\n# Header\nSome text\n~~~"; expect(patchNestedMarkdown(source)).toBe(expected); }); - it('should not replace backticks for non-markdown file extensions', () => { - const source = '```test.js\nContent\n```'; + it("should not replace backticks for non-markdown file extensions", () => { + const source = "```test.js\nContent\n```"; expect(patchNestedMarkdown(source)).toBe(source); }); - it('should check the file extension branch when extension is not md/markdown/gfm', () => { + it("should check the file extension branch when extension is not md/markdown/gfm", () => { // This tests the extension check branch with an unrecognized extension - const source = '```test.txt\nContent with md keyword\n```'; + const source = "```test.txt\nContent with md keyword\n```"; expect(patchNestedMarkdown(source)).toBe(source); }); - - it('should handle empty file name in code block header', () => { + + it("should handle empty file name in code block header", () => { // This covers the branch where file is empty or undefined - const source = '``` \nSome content\n```'; + const source = "``` \nSome content\n```"; expect(patchNestedMarkdown(source)).toBe(source); }); - it('should handle file names with no extension', () => { + it("should handle file names with no extension", () => { // This covers the branch where ext might be undefined - const source = '```filename\nContent\n```'; + const source = "```filename\nContent\n```"; expect(patchNestedMarkdown(source)).toBe(source); }); - it('should correctly identify .markdown extension', () => { + it("should correctly identify .markdown extension", () => { // This specifically tests the ext === "markdown" condition in the extension check - const source = '```example.markdown\n# Some markdown content\n```'; - const expected = '~~~example.markdown\n# Some markdown content\n~~~'; + const source = "```example.markdown\n# Some markdown content\n```"; + const expected = "~~~example.markdown\n# Some markdown content\n~~~"; expect(patchNestedMarkdown(source)).toBe(expected); }); // GitHub-specific tests - it('should handle gfm language identifier', () => { - const source = '```gfm\n# Header\nSome text\n```'; - const expected = '~~~gfm\n# Header\nSome text\n~~~'; + it("should handle gfm language identifier", () => { + const source = "```gfm\n# Header\nSome text\n```"; + const expected = "~~~gfm\n# Header\nSome text\n~~~"; expect(patchNestedMarkdown(source)).toBe(expected); }); - it('should handle github-markdown language identifier', () => { - const source = '```github-markdown\n# Header\nSome text\n```'; - const expected = '~~~github-markdown\n# Header\nSome text\n~~~'; + it("should handle github-markdown language identifier", () => { + const source = "```github-markdown\n# Header\nSome text\n```"; + const expected = "~~~github-markdown\n# Header\nSome text\n~~~"; expect(patchNestedMarkdown(source)).toBe(expected); }); - it('should handle language specifier followed by gfm', () => { - const source = '```lang gfm\n# Header\nSome text\n```'; - const expected = '~~~lang gfm\n# Header\nSome text\n~~~'; + it("should handle language specifier followed by gfm", () => { + const source = "```lang gfm\n# Header\nSome text\n```"; + const expected = "~~~lang gfm\n# Header\nSome text\n~~~"; expect(patchNestedMarkdown(source)).toBe(expected); }); - it('should handle .gfm file extension', () => { - const source = '```example.gfm\n# Some GitHub markdown content\n```'; - const expected = '~~~example.gfm\n# Some GitHub markdown content\n~~~'; + it("should handle .gfm file extension", () => { + const source = "```example.gfm\n# Some GitHub markdown content\n```"; + const expected = "~~~example.gfm\n# Some GitHub markdown content\n~~~"; expect(patchNestedMarkdown(source)).toBe(expected); }); }); diff --git a/gui/src/components/StyledMarkdownPreview/utils/patchNestedMarkdown.ts b/gui/src/components/StyledMarkdownPreview/utils/patchNestedMarkdown.ts index cdb41a468..9be5bfbb2 100644 --- a/gui/src/components/StyledMarkdownPreview/utils/patchNestedMarkdown.ts +++ b/gui/src/components/StyledMarkdownPreview/utils/patchNestedMarkdown.ts @@ -7,11 +7,12 @@ Note, this was benchmarked at sub-millisecond */ -import { headerIsMarkdown } from './headerIsMarkdown'; +import { headerIsMarkdown } from "./headerIsMarkdown"; export const patchNestedMarkdown = (source: string): string => { // Early return if no markdown codeblock pattern is found (including GitHub variants) - if (!source.match(/```(\w*|.*)(md|markdown|gfm|github-markdown)/)) return source; + if (!source.match(/```(\w*|.*)(md|markdown|gfm|github-markdown)/)) + return source; let nestCount = 0; const lines = source.split("\n"); diff --git a/gui/src/components/console/Details.tsx b/gui/src/components/console/Details.tsx index 2541fd8ba..fd0545763 100644 --- a/gui/src/components/console/Details.tsx +++ b/gui/src/components/console/Details.tsx @@ -60,7 +60,9 @@ export default function Details({ interaction }: DetailsProps) { } // Allow a small threshold for floating point errors const threshold = 5; - setIsAtBottom((elt.scrollHeight - elt.scrollTop - elt.clientHeight) < threshold); + setIsAtBottom( + elt.scrollHeight - elt.scrollTop - elt.clientHeight < threshold, + ); } useEffect(() => { diff --git a/gui/src/components/gui/Shortcut.css b/gui/src/components/gui/Shortcut.css index 57b85c277..4ce2ce563 100644 --- a/gui/src/components/gui/Shortcut.css +++ b/gui/src/components/gui/Shortcut.css @@ -6,12 +6,24 @@ } .keyboard-key-normal { - font-family: "JetBrains Mono", "SF Mono", Monaco, Menlo, Consolas, "Ubuntu Mono", "Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace; + font-family: "JetBrains Mono", "SF Mono", Monaco, Menlo, Consolas, + "Ubuntu Mono", "Liberation Mono", "DejaVu Sans Mono", "Courier New", + monospace; font-weight: 300; } .keyboard-key-special { - font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", "HelveticaNeue-Light", system-ui, "Ubuntu", "Droid Sans", sans-serif; + font-family: + "Inter", + -apple-system, + BlinkMacSystemFont, + "Segoe WPC", + "Segoe UI", + "HelveticaNeue-Light", + system-ui, + "Ubuntu", + "Droid Sans", + sans-serif; font-weight: 300; } @@ -20,4 +32,4 @@ top: 0.1rem; margin: 0 0.1rem; color: var(--vscode-editor-foreground); -} \ No newline at end of file +} diff --git a/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx b/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx index 4927a1bc1..d7fd74eee 100644 --- a/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/PromptsSection.tsx @@ -136,8 +136,7 @@ export function PromptsSection() { if ("uses" in yamlPrompt) { prompt.slug = yamlPrompt.uses; } else { - prompt.slug = - `${selectedProfile?.fullSlug.ownerSlug}/${selectedProfile?.fullSlug.packageSlug}`; + prompt.slug = `${selectedProfile?.fullSlug.ownerSlug}/${selectedProfile?.fullSlug.packageSlug}`; } } index = index + 1; diff --git a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx index fa9dff106..00876e845 100644 --- a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx @@ -9,7 +9,7 @@ import { DEFAULT_CHAT_SYSTEM_MESSAGE, DEFAULT_CHAT_SYSTEM_MESSAGE_URL, DEFAULT_AGENT_SYSTEM_MESSAGE, - DEFAULT_AGENT_SYSTEM_MESSAGE_URL + DEFAULT_AGENT_SYSTEM_MESSAGE_URL, } from "core/llm/constructMessages"; import { useContext, useMemo } from "react"; import { defaultBorderRadius, vscCommandCenterActiveBorder } from "../../.."; @@ -112,7 +112,8 @@ const RuleCard: React.FC = ({ rule }) => { {" "} - {rule.source === "default-chat" || rule.source === "default-agent" ? ( + {rule.source === "default-chat" || + rule.source === "default-agent" ? ( @@ -195,24 +196,24 @@ export function RulesSection() { rules.unshift({ rule: config.selectedModelByRole.chat?.baseAgentSystemMessage, source: "model-agent-options", - }) + }); } else { rules.unshift({ rule: DEFAULT_AGENT_SYSTEM_MESSAGE, source: "default-agent", - }) + }); } } else { if (config.selectedModelByRole.chat?.baseChatSystemMessage) { rules.unshift({ rule: config.selectedModelByRole.chat?.baseChatSystemMessage, source: "model-chat-options", - }) + }); } else { rules.unshift({ rule: DEFAULT_CHAT_SYSTEM_MESSAGE, source: "default-chat", - }) + }); } } diff --git a/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx b/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx index b1117c767..c5aa0a039 100644 --- a/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx @@ -28,7 +28,12 @@ export function ErrorSection() { ) : ( )} -

{error.message}

+

+ {error.message} +

))} diff --git a/gui/src/hooks/useWebviewListener.ts b/gui/src/hooks/useWebviewListener.ts index 797df3e61..b658724b8 100644 --- a/gui/src/hooks/useWebviewListener.ts +++ b/gui/src/hooks/useWebviewListener.ts @@ -13,7 +13,9 @@ export function useWebviewListener( useEffect( () => { - let listener: (event: { data: Message}) => Promise; + let listener: (event: { + data: Message; + }) => Promise; if (!skip) { listener = async (event) => { diff --git a/gui/src/pages/AddNewModel/configs/models.ts b/gui/src/pages/AddNewModel/configs/models.ts index 9e284aaea..d3f9c1617 100644 --- a/gui/src/pages/AddNewModel/configs/models.ts +++ b/gui/src/pages/AddNewModel/configs/models.ts @@ -1685,8 +1685,7 @@ export const models: { [key: string]: ModelPackage } = { }, deepseekR1DistillLlama70B: { title: "DeepSeek R1 Distill Llama 70B", - description: - "A llama 3.1 70 model distilled from deekseek R1", + description: "A llama 3.1 70 model distilled from deekseek R1", params: { title: "DeepSeek R1 Distill Llama 70B", model: "DeepSeek-R1-Distill-Llama-70B", @@ -1698,8 +1697,7 @@ export const models: { [key: string]: ModelPackage } = { }, deepseekR1: { title: "DeepSeek R1", - description: - "DeekSeek R1 reasoning model from DeepSeek", + description: "DeekSeek R1 reasoning model from DeepSeek", params: { title: "DeepSeek R1", model: "DeepSeek-R1", @@ -1711,8 +1709,7 @@ export const models: { [key: string]: ModelPackage } = { }, deepseekV3: { title: "DeepSeek V3", - description: - "DeekSeek V3 reasoning model from DeepSeek", + description: "DeekSeek V3 reasoning model from DeepSeek", params: { title: "DeepSeek V3", model: "DeepSeek-V3-0324", diff --git a/gui/src/pages/AddNewModel/configs/providers.ts b/gui/src/pages/AddNewModel/configs/providers.ts index f56a6b210..71389abfa 100644 --- a/gui/src/pages/AddNewModel/configs/providers.ts +++ b/gui/src/pages/AddNewModel/configs/providers.ts @@ -797,7 +797,7 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo }, ...completionParamsInputsConfigs, ], - packages:[ + packages: [ models.llama4Scout, models.llama4Maverick, models.llama3370BInstruct, @@ -808,7 +808,7 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo models.qwq32B, models.deepseekR1DistillLlama70B, models.deepseekR1, - models.deepseekV3 + models.deepseekV3, ], apiKeyUrl: "https://cloud.sambanova.ai/apis", }, @@ -1011,9 +1011,7 @@ To get started, [register](https://dataplatform.cloud.ibm.com/registration/stepo required: true, }, ], - packages: [ - {...models.AUTODETECT} - ], - apiKeyUrl: "https://venice.ai/chat" - } + packages: [{ ...models.AUTODETECT }], + apiKeyUrl: "https://venice.ai/chat", + }, }; diff --git a/gui/src/pages/config/IndexingProgress/IndexingProgressBar.tsx b/gui/src/pages/config/IndexingProgress/IndexingProgressBar.tsx index fa8e07097..95ea4497a 100644 --- a/gui/src/pages/config/IndexingProgress/IndexingProgressBar.tsx +++ b/gui/src/pages/config/IndexingProgress/IndexingProgressBar.tsx @@ -7,7 +7,8 @@ export interface IndexingProgressBarProps { function IndexingProgressBar({ update }: IndexingProgressBarProps) { // Show 100% red progress bar if indexing failed - const progressPercentage = update.status === "failed" ? 100 : getProgressPercentage(update.progress); + const progressPercentage = + update.status === "failed" ? 100 : getProgressPercentage(update.progress); return (
diff --git a/gui/src/pages/config/ModelRoleSelector.tsx b/gui/src/pages/config/ModelRoleSelector.tsx index a4606ad89..2214853a4 100644 --- a/gui/src/pages/config/ModelRoleSelector.tsx +++ b/gui/src/pages/config/ModelRoleSelector.tsx @@ -108,55 +108,57 @@ const ModelRoleSelector = ({ style={{ borderRadius: defaultBorderRadius }} className="min-w-40" > - {[...models].sort((a,b)=>a.title.localeCompare(b.title)).map((option, idx) => { - const showMissingApiKeyMsg = - option.configurationStatus === - LLMConfigurationStatuses.MISSING_API_KEY; + {[...models] + .sort((a, b) => a.title.localeCompare(b.title)) + .map((option, idx) => { + const showMissingApiKeyMsg = + option.configurationStatus === + LLMConfigurationStatuses.MISSING_API_KEY; - return ( - setHoveredIdx(idx)} - onMouseLeave={() => setHoveredIdx(null)} - onClick={(e: any) => - handleOptionClick(showMissingApiKeyMsg, e) - } - className={""} - > -
-
-
- - - {option.title} - {showMissingApiKeyMsg && ( - - (Missing API key) - + return ( + setHoveredIdx(idx)} + onMouseLeave={() => setHoveredIdx(null)} + onClick={(e: any) => + handleOptionClick(showMissingApiKeyMsg, e) + } + className={""} + > +
+
+
+ + + {option.title} + {showMissingApiKeyMsg && ( + + (Missing API key) + + )} + +
+
+ {hoveredIdx === idx && ( + )} - -
-
- {hoveredIdx === idx && ( - - )} - {option.title === selectedModel?.title && ( - - )} + {option.title === selectedModel?.title && ( + + )} +
-
- - ); - })} + + ); + })}
diff --git a/gui/src/pages/gui/ToolCallDiv/RunTerminalCommand.tsx b/gui/src/pages/gui/ToolCallDiv/RunTerminalCommand.tsx index 7356d01f5..c78ec3495 100644 --- a/gui/src/pages/gui/ToolCallDiv/RunTerminalCommand.tsx +++ b/gui/src/pages/gui/ToolCallDiv/RunTerminalCommand.tsx @@ -24,17 +24,23 @@ const CommandStatus = styled.div` align-items: center; `; -const StatusIcon = styled.span<{ status: 'running' | 'completed' | 'failed' | 'background' }>` +const StatusIcon = styled.span<{ + status: "running" | "completed" | "failed" | "background"; +}>` width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; - background-color: ${props => - props.status === 'running' ? '#4caf50' : - props.status === 'completed' ? '#4caf50' : - props.status === 'background' ? '#2196f3' : - '#f44336'}; - ${props => props.status === 'running' ? 'animation: pulse 1.5s infinite;' : ''} + background-color: ${(props) => + props.status === "running" + ? "#4caf50" + : props.status === "completed" + ? "#4caf50" + : props.status === "background" + ? "#2196f3" + : "#f44336"}; + ${(props) => + props.status === "running" ? "animation: pulse 1.5s infinite;" : ""} `; // Removed unused styled components @@ -56,7 +62,7 @@ export function RunTerminalCommand(props: RunTerminalCommandToolCallProps) { // Find the terminal output from context items if available const terminalItem = props.toolCallState.output?.find( - item => item.name === "Terminal" + (item) => item.name === "Terminal", ); const terminalContent = terminalItem?.content || ""; @@ -65,22 +71,25 @@ export function RunTerminalCommand(props: RunTerminalCommandToolCallProps) { const hasOutput = terminalContent.length > 0; // Determine status type - let statusType: 'running' | 'completed' | 'failed' | 'background' = 'completed'; + let statusType: "running" | "completed" | "failed" | "background" = + "completed"; if (isRunning) { - statusType = 'running'; - } else if (statusMessage?.includes('failed')) { - statusType = 'failed'; - } else if (statusMessage?.includes('background')) { - statusType = 'background'; + statusType = "running"; + } else if (statusMessage?.includes("failed")) { + statusType = "failed"; + } else if (statusMessage?.includes("background")) { + statusType = "background"; } return ( {(statusMessage || isRunning) && ( @@ -91,9 +100,11 @@ export function RunTerminalCommand(props: RunTerminalCommandToolCallProps) { { // Dispatch the action to move the command to the background - dispatch(moveTerminalProcessToBackground({ - toolCallId: props.toolCallId as string - })); + dispatch( + moveTerminalProcessToBackground({ + toolCallId: props.toolCallId as string, + }), + ); }} > Move to background diff --git a/gui/src/redux/selectors/selectActiveTools.ts b/gui/src/redux/selectors/selectActiveTools.ts index 82a47c158..7aae43765 100644 --- a/gui/src/redux/selectors/selectActiveTools.ts +++ b/gui/src/redux/selectors/selectActiveTools.ts @@ -12,15 +12,13 @@ export const selectActiveTools = createSelector( (mode, tools, policies, groupPolicies): Tool[] => { if (mode === "chat") { return []; - } - else if (mode === "agent") { + } else if (mode === "agent") { return tools.filter( (tool) => policies[tool.function.name] !== "disabled" && groupPolicies[tool.group] !== "exclude", ); - } - else { + } else { return []; } }, diff --git a/gui/src/redux/slices/tabsSlice.ts b/gui/src/redux/slices/tabsSlice.ts index 5c68c0b06..bceab688b 100644 --- a/gui/src/redux/slices/tabsSlice.ts +++ b/gui/src/redux/slices/tabsSlice.ts @@ -1,116 +1,140 @@ import { PayloadAction, createSlice } from "@reduxjs/toolkit"; export interface Tab { - id: string; - title: string; - isActive: boolean; - sessionId?: string; + id: string; + title: string; + isActive: boolean; + sessionId?: string; } interface TabsState { - tabs: Tab[]; + tabs: Tab[]; } const initialState: TabsState = { - tabs: [{ - id: Date.now().toString(36) + Math.random().toString(36).substring(2), - title: "Chat 1", - isActive: true - }] + tabs: [ + { + id: Date.now().toString(36) + Math.random().toString(36).substring(2), + title: "Chat 1", + isActive: true, + }, + ], }; export const tabsSlice = createSlice({ - name: "tabs", - initialState, - reducers: { - setTabs: (state, action: PayloadAction) => { - state.tabs = action.payload; - }, - updateTab: (state, action: PayloadAction<{ id: string; updates: Partial }>) => { - const { id, updates } = action.payload; - state.tabs = state.tabs.map(tab => - tab.id === id ? { ...tab, ...updates } : tab - ); - }, - addTab: (state, action: PayloadAction) => { - state.tabs = state.tabs.map(tab => ({ ...tab, isActive: action.payload.isActive ? false : tab.isActive })) - .concat(action.payload); - }, - removeTab: (state, action: PayloadAction) => { - state.tabs = state.tabs.filter(tab => tab.id !== action.payload); - }, - setActiveTab: (state, action: PayloadAction) => { - state.tabs = state.tabs.map(tab => ({ + name: "tabs", + initialState, + reducers: { + setTabs: (state, action: PayloadAction) => { + state.tabs = action.payload; + }, + updateTab: ( + state, + action: PayloadAction<{ id: string; updates: Partial }>, + ) => { + const { id, updates } = action.payload; + state.tabs = state.tabs.map((tab) => + tab.id === id ? { ...tab, ...updates } : tab, + ); + }, + addTab: (state, action: PayloadAction) => { + state.tabs = state.tabs + .map((tab) => ({ + ...tab, + isActive: action.payload.isActive ? false : tab.isActive, + })) + .concat(action.payload); + }, + removeTab: (state, action: PayloadAction) => { + state.tabs = state.tabs.filter((tab) => tab.id !== action.payload); + }, + setActiveTab: (state, action: PayloadAction) => { + state.tabs = state.tabs.map((tab) => ({ + ...tab, + isActive: tab.id === action.payload, + })); + }, + handleSessionChange: ( + state, + action: PayloadAction<{ + currentSessionId: string; + currentSessionTitle: string; + newTabId?: string; + }>, + ) => { + const { currentSessionId, currentSessionTitle, newTabId } = + action.payload; + + const activeTab = state.tabs.find((tab) => tab.isActive); + if (!activeTab) return; + + // Current session matches active tab's session + if (activeTab.sessionId === currentSessionId) { + state.tabs = state.tabs.map((tab) => + tab.id === activeTab.id + ? { ...tab, title: currentSessionTitle } + : tab, + ); + return; + } + + // Check if there's another tab with the same session ID + const existingTabWithSession = state.tabs.find( + (tab) => tab.sessionId === currentSessionId, + ); + if (existingTabWithSession) { + // Activate the existing tab and update its title + // Remove any unassigned tabs + state.tabs = state.tabs + .filter( + (tab) => tab.sessionId || tab.id === existingTabWithSession.id, + ) + .map((tab) => ({ + ...tab, + isActive: tab.id === existingTabWithSession.id, + title: + tab.sessionId === currentSessionId + ? currentSessionTitle + : tab.title, + })); + return; + } + + // Active tab has no session ID + if (!activeTab.sessionId) { + state.tabs = state.tabs.map((tab) => + tab.id === activeTab.id + ? { ...tab, - isActive: tab.id === action.payload - })); - }, - handleSessionChange: ( - state, - action: PayloadAction<{ - currentSessionId: string; - currentSessionTitle: string; - newTabId?: string; - }> - ) => { - const { currentSessionId, currentSessionTitle, newTabId } = action.payload; - - const activeTab = state.tabs.find(tab => tab.isActive); - if (!activeTab) return; - - // Current session matches active tab's session - if (activeTab.sessionId === currentSessionId) { - state.tabs = state.tabs.map(tab => - tab.id === activeTab.id - ? { ...tab, title: currentSessionTitle } - : tab - ); - return; - } - - // Check if there's another tab with the same session ID - const existingTabWithSession = state.tabs.find( - tab => tab.sessionId === currentSessionId - ); - if (existingTabWithSession) { - // Activate the existing tab and update its title - // Remove any unassigned tabs - state.tabs = state.tabs - .filter(tab => tab.sessionId || tab.id === existingTabWithSession.id) - .map(tab => ({ - ...tab, - isActive: tab.id === existingTabWithSession.id, - title: tab.sessionId === currentSessionId - ? currentSessionTitle - : tab.title, - })); - return; - } - - // Active tab has no session ID - if (!activeTab.sessionId) { - state.tabs = state.tabs.map(tab => - tab.id === activeTab.id - ? { - ...tab, - sessionId: currentSessionId, - title: currentSessionTitle, - } - : tab - ); - } else { - // Active tab has a session ID, create new tab - state.tabs = state.tabs.map(tab => ({ ...tab, isActive: false })).concat({ - id: newTabId || Date.now().toString(36) + Math.random().toString(36).substring(2), - title: currentSessionTitle, - isActive: true, - sessionId: currentSessionId, - }); - } - } - } + sessionId: currentSessionId, + title: currentSessionTitle, + } + : tab, + ); + } else { + // Active tab has a session ID, create new tab + state.tabs = state.tabs + .map((tab) => ({ ...tab, isActive: false })) + .concat({ + id: + newTabId || + Date.now().toString(36) + Math.random().toString(36).substring(2), + title: currentSessionTitle, + isActive: true, + sessionId: currentSessionId, + }); + } + }, + }, }); -export const { setTabs, updateTab, addTab, removeTab, setActiveTab, handleSessionChange } = tabsSlice.actions; +export const { + setTabs, + updateTab, + addTab, + removeTab, + setActiveTab, + handleSessionChange, +} = tabsSlice.actions; -export default tabsSlice.reducer; \ No newline at end of file +export default tabsSlice.reducer; diff --git a/gui/src/redux/thunks/streamResponseAfterToolCall.ts b/gui/src/redux/thunks/streamResponseAfterToolCall.ts index 990723f7a..4ca5c45f1 100644 --- a/gui/src/redux/thunks/streamResponseAfterToolCall.ts +++ b/gui/src/redux/thunks/streamResponseAfterToolCall.ts @@ -65,12 +65,14 @@ export const streamResponseAfterToolCall = createAsyncThunk< dispatch(setActive()); - const updatedHistory = getState().session.history; - const messageMode = getState().session.mode + const messageMode = getState().session.mode; + + const baseChatOrAgentSystemMessage = getBaseSystemMessage( + selectedChatModel, + messageMode, + ); - const baseChatOrAgentSystemMessage = getBaseSystemMessage(selectedChatModel, messageMode) - const messages = constructMessages( messageMode, [...updatedHistory], diff --git a/gui/src/util/index.ts b/gui/src/util/index.ts index b237c6e1b..ccb1be1e6 100644 --- a/gui/src/util/index.ts +++ b/gui/src/util/index.ts @@ -3,7 +3,10 @@ import { ProfileDescription } from "core/config/ProfileLifecycleManager"; import _ from "lodash"; import { KeyboardEvent } from "react"; import { getLocalStorage } from "./localStorage"; -import { DEFAULT_CHAT_SYSTEM_MESSAGE, DEFAULT_AGENT_SYSTEM_MESSAGE } from "core/llm/constructMessages"; +import { + DEFAULT_CHAT_SYSTEM_MESSAGE, + DEFAULT_AGENT_SYSTEM_MESSAGE, +} from "core/llm/constructMessages"; export type Platform = "mac" | "linux" | "windows" | "unknown"; @@ -120,12 +123,17 @@ export function isLocalProfile(profile: ProfileDescription): boolean { /** * Get the base system message for the agent or chat mode from the model description. */ -export function getBaseSystemMessage(modelDetails: ModelDescription | null, mode: MessageModes) { - let baseChatOrAgentSystemMessage: string|undefined - if(mode === 'agent') { - baseChatOrAgentSystemMessage = modelDetails?.baseAgentSystemMessage ?? DEFAULT_AGENT_SYSTEM_MESSAGE; +export function getBaseSystemMessage( + modelDetails: ModelDescription | null, + mode: MessageModes, +) { + let baseChatOrAgentSystemMessage: string | undefined; + if (mode === "agent") { + baseChatOrAgentSystemMessage = + modelDetails?.baseAgentSystemMessage ?? DEFAULT_AGENT_SYSTEM_MESSAGE; } else { - baseChatOrAgentSystemMessage = modelDetails?.baseChatSystemMessage ?? DEFAULT_CHAT_SYSTEM_MESSAGE; + baseChatOrAgentSystemMessage = + modelDetails?.baseChatSystemMessage ?? DEFAULT_CHAT_SYSTEM_MESSAGE; } - return baseChatOrAgentSystemMessage -} \ No newline at end of file + return baseChatOrAgentSystemMessage; +}