npx prettier --check "gui/**/*.{js,jsx,ts,tsx,json,css,md}" --ignore-pa

th .gitignore --ignore-path .prettierignore --write
This commit is contained in:
Nate 2025-05-25 18:35:42 -07:00
parent 83cc4b8736
commit a26a374ad8
21 changed files with 442 additions and 356 deletions

View file

@ -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");
});
});
});

View file

@ -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, ' ');
}
return result.trim().replace(/\s+/g, " ");
}

View file

@ -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
});
});
});

View file

@ -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"
);
}
}

View file

@ -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);
});
});

View file

@ -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");

View file

@ -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(() => {

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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<RuleCardProps> = ({ rule }) => {
<HeaderButtonWithToolTip onClick={onClickExpand} text="Expand">
<ArrowsPointingOutIcon className="h-3 w-3 text-gray-400" />
</HeaderButtonWithToolTip>{" "}
{rule.source === "default-chat" || rule.source === "default-agent" ? (
{rule.source === "default-chat" ||
rule.source === "default-agent" ? (
<HeaderButtonWithToolTip onClick={handleOpen} text="View">
<EyeIcon className="h-3 w-3 text-gray-400" />
</HeaderButtonWithToolTip>
@ -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",
})
});
}
}

View file

@ -28,7 +28,12 @@ export function ErrorSection() {
) : (
<ExclamationTriangleIcon className="mr-2 mt-1 h-3.5 w-3.5" />
)}
<p className="m-0 whitespace-pre-wrap text-wrap" style={{wordBreak: 'break-word'}}>{error.message}</p>
<p
className="m-0 whitespace-pre-wrap text-wrap"
style={{ wordBreak: "break-word" }}
>
{error.message}
</p>
</li>
))}
</ul>

View file

@ -13,7 +13,9 @@ export function useWebviewListener<T extends keyof ToWebviewProtocol>(
useEffect(
() => {
let listener: (event: { data: Message<ToWebviewProtocol[T][0]>}) => Promise<void>;
let listener: (event: {
data: Message<ToWebviewProtocol[T][0]>;
}) => Promise<void>;
if (!skip) {
listener = async (event) => {

View file

@ -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",

View file

@ -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",
},
};

View file

@ -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 (
<div className="my-2 h-1.5 w-full rounded-md border border-solid border-gray-400">

View file

@ -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 (
<ListboxOption
key={idx}
value={option.title}
disabled={showMissingApiKeyMsg}
onMouseEnter={() => setHoveredIdx(idx)}
onMouseLeave={() => setHoveredIdx(null)}
onClick={(e: any) =>
handleOptionClick(showMissingApiKeyMsg, e)
}
className={""}
>
<div className="flex flex-col gap-0.5">
<div className="flex flex-1 flex-row items-center justify-between gap-2">
<div className="flex flex-1 flex-row items-center gap-2">
<CubeIcon className="h-3 w-3 flex-shrink-0" />
<span
className="line-clamp-1 flex-1"
style={{ fontSize: fontSize(-3) }}
>
{option.title}
{showMissingApiKeyMsg && (
<span className="ml-2 text-[10px] italic">
(Missing API key)
</span>
return (
<ListboxOption
key={idx}
value={option.title}
disabled={showMissingApiKeyMsg}
onMouseEnter={() => setHoveredIdx(idx)}
onMouseLeave={() => setHoveredIdx(null)}
onClick={(e: any) =>
handleOptionClick(showMissingApiKeyMsg, e)
}
className={""}
>
<div className="flex flex-col gap-0.5">
<div className="flex flex-1 flex-row items-center justify-between gap-2">
<div className="flex flex-1 flex-row items-center gap-2">
<CubeIcon className="h-3 w-3 flex-shrink-0" />
<span
className="line-clamp-1 flex-1"
style={{ fontSize: fontSize(-3) }}
>
{option.title}
{showMissingApiKeyMsg && (
<span className="ml-2 text-[10px] italic">
(Missing API key)
</span>
)}
</span>
</div>
<div className="flex flex-shrink-0 flex-row items-center gap-1">
{hoveredIdx === idx && (
<Cog6ToothIcon
className="h-3 w-3 flex-shrink-0"
onClick={onClickGear}
/>
)}
</span>
</div>
<div className="flex flex-shrink-0 flex-row items-center gap-1">
{hoveredIdx === idx && (
<Cog6ToothIcon
className="h-3 w-3 flex-shrink-0"
onClick={onClickGear}
/>
)}
{option.title === selectedModel?.title && (
<CheckIcon className="h-3 w-3 flex-shrink-0" />
)}
{option.title === selectedModel?.title && (
<CheckIcon className="h-3 w-3 flex-shrink-0" />
)}
</div>
</div>
</div>
</div>
</ListboxOption>
);
})}
</ListboxOption>
);
})}
</ListboxOptions>
</Transition>
</div>

View file

@ -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 (
<Fragment>
<StyledMarkdownPreview
isRenderingInStepContainer
source={`\`\`\`bash .sh\n$ ${props.command ?? ""}${(hasOutput || isRunning) ?
`\n${terminalContent || "Waiting for output..."}`
: ""}\n\`\`\``}
source={`\`\`\`bash .sh\n$ ${props.command ?? ""}${
hasOutput || isRunning
? `\n${terminalContent || "Waiting for output..."}`
: ""
}\n\`\`\``}
/>
{(statusMessage || isRunning) && (
@ -91,9 +100,11 @@ export function RunTerminalCommand(props: RunTerminalCommandToolCallProps) {
<BackgroundLink
onClick={() => {
// 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

View file

@ -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 [];
}
},

View file

@ -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<Tab[]>) => {
state.tabs = action.payload;
},
updateTab: (state, action: PayloadAction<{ id: string; updates: Partial<Tab> }>) => {
const { id, updates } = action.payload;
state.tabs = state.tabs.map(tab =>
tab.id === id ? { ...tab, ...updates } : tab
);
},
addTab: (state, action: PayloadAction<Tab>) => {
state.tabs = state.tabs.map(tab => ({ ...tab, isActive: action.payload.isActive ? false : tab.isActive }))
.concat(action.payload);
},
removeTab: (state, action: PayloadAction<string>) => {
state.tabs = state.tabs.filter(tab => tab.id !== action.payload);
},
setActiveTab: (state, action: PayloadAction<string>) => {
state.tabs = state.tabs.map(tab => ({
name: "tabs",
initialState,
reducers: {
setTabs: (state, action: PayloadAction<Tab[]>) => {
state.tabs = action.payload;
},
updateTab: (
state,
action: PayloadAction<{ id: string; updates: Partial<Tab> }>,
) => {
const { id, updates } = action.payload;
state.tabs = state.tabs.map((tab) =>
tab.id === id ? { ...tab, ...updates } : tab,
);
},
addTab: (state, action: PayloadAction<Tab>) => {
state.tabs = state.tabs
.map((tab) => ({
...tab,
isActive: action.payload.isActive ? false : tab.isActive,
}))
.concat(action.payload);
},
removeTab: (state, action: PayloadAction<string>) => {
state.tabs = state.tabs.filter((tab) => tab.id !== action.payload);
},
setActiveTab: (state, action: PayloadAction<string>) => {
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;
export default tabsSlice.reducer;

View file

@ -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],

View file

@ -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
}
return baseChatOrAgentSystemMessage;
}