mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-17 21:10:48 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cfb634c5bd | ||
|
|
de05276613 |
No files matched your search
@@ -64,6 +64,32 @@ test("host tree tab gutter never goes negative", () => {
|
||||
assert.equal(computeHostTreeTabGutter(120, 280), 0);
|
||||
});
|
||||
|
||||
test("top tab native exclusions stay bounded to the stationary scroll viewport", () => {
|
||||
const viewport = topTabsSource.match(/<div\s+ref=\{tabsContainerRef\}[\s\S]*?onClick=/);
|
||||
assert.ok(viewport, "expected the tab scroll viewport");
|
||||
assert.match(viewport[0], /className="[^"]*\btop-tab-scroll-viewport\b[^"]*"/);
|
||||
assert.match(viewport[0], /className="[^"]*\bmin-w-0\b[^"]*"/);
|
||||
assert.doesNotMatch(viewport[0], /className="[^"]*\bflex-1\b[^"]*"/);
|
||||
assert.match(viewport[0], /className="[^"]*\boverflow-x-auto\b[^"]*\bapp-no-drag\b[^"]*"/);
|
||||
assert.doesNotMatch(viewport[0], /\bapp-drag\b/);
|
||||
// Inline no-drag keeps the viewport excluded despite the scoped CSS reset.
|
||||
assert.match(viewport[0], /style=\{\{[^}]*\.\.\.noDragRegionStyle\s*\}\}/);
|
||||
assert.match(topTabsSource, /const noDragRegionStyle = \{ WebkitAppRegion: 'no-drag' \}/);
|
||||
|
||||
const scrollContent = topTabsSource.slice(topTabsSource.indexOf(viewport[0]));
|
||||
const viewportEnd = scrollContent.indexOf("</div>");
|
||||
assert.match(scrollContent.slice(0, viewportEnd), /\{renderOrderedTabs\(\)\}/);
|
||||
assert.doesNotMatch(scrollContent.slice(0, viewportEnd), /min-w-\[20px\]/);
|
||||
assert.match(scrollContent.slice(viewportEnd), /^<\/div>\s*\{\/\*[^}]*\*\/\}\s*<div className="flex-1 app-drag" style=\{dragRegionStyle\} \/>\s*<div className="min-w-\[20px\] h-7 app-drag flex-shrink-0 self-end" style=\{dragRegionStyle\} \/>/);
|
||||
|
||||
const regionReset = indexCss.match(/\.top-tab-scroll-viewport,\s*\.top-tab-scroll-viewport \*\s*\{([^}]+)\}/);
|
||||
assert.ok(regionReset, "expected a native region reset for the viewport and every descendant");
|
||||
assert.match(regionReset[1], /-webkit-app-region:\s*none;/);
|
||||
assert.match(regionReset[1], /(?:^|[;\s])app-region:\s*none;/);
|
||||
assert.ok(indexCss.indexOf(regionReset[0]) > indexCss.indexOf(".app-no-drag * {"));
|
||||
assert.match(topTabItemsSource, /netcatty-tab[^\n]*\bapp-no-drag\b/);
|
||||
});
|
||||
|
||||
test("host tree tab surface stays mounted when root pages are active", () => {
|
||||
assert.equal(shouldKeepHostTreeToggleSurface({
|
||||
enabled: true,
|
||||
|
||||
@@ -1157,8 +1157,8 @@ const TopTabsInner: React.FC<TopTabsProps> = ({
|
||||
{/* Scrollable container */}
|
||||
<div
|
||||
ref={tabsContainerRef}
|
||||
className="flex items-end gap-0 overflow-x-auto scrollbar-none app-drag max-w-full"
|
||||
style={{ scrollbarWidth: 'none', msOverflowStyle: 'none' }}
|
||||
className="top-tab-scroll-viewport min-w-0 flex items-end gap-0 overflow-x-auto scrollbar-none app-no-drag max-w-full"
|
||||
style={{ scrollbarWidth: 'none', msOverflowStyle: 'none', ...noDragRegionStyle }}
|
||||
onClick={handleScrollableTabClick}
|
||||
onDragOver={(e) => {
|
||||
if (hasWorkspaceSessionDrag(e.dataTransfer)) {
|
||||
@@ -1187,9 +1187,10 @@ const TopTabsInner: React.FC<TopTabsProps> = ({
|
||||
<TooltipContent>{t('topTabs.openQuickSwitcher')}</TooltipContent>
|
||||
</Tooltip>
|
||||
)}
|
||||
{/* Draggable spacer - fixed width handle at the end */}
|
||||
<div className="min-w-[20px] h-7 app-drag flex-shrink-0" style={dragRegionStyle} />
|
||||
</div>
|
||||
{/* Keep unused space and the drag handle outside the scroll viewport's exclusion. */}
|
||||
<div className="flex-1 app-drag" style={dragRegionStyle} />
|
||||
<div className="min-w-[20px] h-7 app-drag flex-shrink-0 self-end" style={dragRegionStyle} />
|
||||
|
||||
{/* Right fade mask */}
|
||||
{canScrollRight && (
|
||||
|
||||
@@ -24,21 +24,6 @@ const UI_DISALLOWED_TOOLS = ["AskUserQuestion"];
|
||||
const MCP_MODE_TOOLS = [];
|
||||
const SKILLS_MODE_TOOLS = ["Bash"];
|
||||
|
||||
// Deduped built-in catalog from @tencent-ai/agent-sdk 0.3.258 cli/product.json.
|
||||
const CODEBUDDY_BUILTIN_TOOLS = [
|
||||
"Agent", "Bash", "PowerShell", "Glob", "Grep", "Read", "Edit", "Write",
|
||||
"NotebookEdit", "WebFetch", "ListMcpResources", "ReadMcpResource", "WaitForMcpServers",
|
||||
"TaskCreate", "TaskGet", "TaskUpdate", "TaskList", "WebSearch", "EnterPlanMode",
|
||||
"ExitPlanMode", "KillShell", "TaskStop", "TaskOutput", "SlashCommand", "Skill",
|
||||
"SkillManage", "AskUserQuestion", "AskUserForStructuredInput", "LSP", "StructuredOutput",
|
||||
"ToolSearch", "DeferExecuteTool", "ImageGen", "ImageEdit", "VideoGen", "Artifact",
|
||||
"ArtifactControl", "ComputerUse", "TeamCreate", "TeamDelete", "SendMessage",
|
||||
"SendUserMessage", "EnterWorktree", "LeaveWorktree", "CronCreate", "CronDelete",
|
||||
"CronList", "DelegateTool", "WeChatReply", "WeComReply", "PushNotification",
|
||||
"ReportFindings", "Workflow", "Monitor", "REPL", "A2AGetAgentCard", "A2ASendMessage",
|
||||
"A2AGetTask", "A2ACancelTask",
|
||||
];
|
||||
|
||||
const CODEBUDDY_IMAGE_MEDIA_TYPES = new Set(["image/jpeg", "image/png", "image/gif", "image/webp"]);
|
||||
|
||||
function isCodebuddyImageAttachment(attachment) {
|
||||
@@ -276,19 +261,18 @@ function buildCodebuddyQueryOptions({
|
||||
allowDangerouslySkipPermissions: true,
|
||||
extraArgs: { "dangerously-skip-permissions": null },
|
||||
mcpServers: toSdkMcpServers(injectedMcpServers),
|
||||
// Block built-ins explicitly in mcp mode: tools: [] becomes --tools "",
|
||||
// which also hides injected MCP tools in CodeBuddy CLI v2.183.0.
|
||||
// Leave allowedTools unset: an empty auto-approval list prevents MCP tool
|
||||
// calls from running under bypassPermissions.
|
||||
disallowedTools: builtinTools.length > 0
|
||||
? [...UI_DISALLOWED_TOOLS]
|
||||
: [...new Set([...UI_DISALLOWED_TOOLS, ...CODEBUDDY_BUILTIN_TOOLS])],
|
||||
tools: builtinTools,
|
||||
// `tools` is the built-in tool whitelist. In mcp mode it is [], so CodeBuddy
|
||||
// built-ins stay disabled while injected Netcatty MCP tools remain visible.
|
||||
// Do not mirror that empty list into allowedTools: the SDK treats
|
||||
// allowedTools as an auto-approval list, and allowedTools: [] prevents MCP
|
||||
// tool calls from running under bypassPermissions.
|
||||
disallowedTools: [...UI_DISALLOWED_TOOLS],
|
||||
// Keep the SDK isolated from user/project settings so local hooks, plugins,
|
||||
// or extra MCP servers cannot expand Netcatty's controlled tool boundary.
|
||||
settingSources: [],
|
||||
env,
|
||||
};
|
||||
if (builtinTools.length > 0) options.tools = builtinTools;
|
||||
const selection = splitCodebuddyModelSelection(model);
|
||||
if (selection.model) options.model = selection.model;
|
||||
if (abortController) options.abortController = abortController;
|
||||
|
||||
@@ -59,51 +59,15 @@ test("buildCodebuddyQueryOptions wires SDK options in isolated mode", () => {
|
||||
assert.equal(opts.pathToCodebuddyCode, "/opt/codebuddy/bin/codebuddy");
|
||||
assert.equal(opts.abortController, ac);
|
||||
assert.equal(opts.resume, "sess-1");
|
||||
assert.ok(!("tools" in opts));
|
||||
assert.deepEqual(opts.tools, []);
|
||||
// allowedTools must stay unset in mcp mode: tools:[] disables built-ins, while
|
||||
// allowedTools:[] would prevent injected Netcatty MCP tools from running.
|
||||
assert.ok(!("allowedTools" in opts));
|
||||
assert.ok(opts.disallowedTools.includes("Bash"));
|
||||
assert.ok(opts.disallowedTools.includes("AskUserQuestion"));
|
||||
assert.equal(opts.mcpServers["netcatty-remote-hosts"].type, "stdio");
|
||||
assert.deepEqual(opts.mcpServers["netcatty-remote-hosts"].env, { NETCATTY_MCP_PORT: "1" });
|
||||
});
|
||||
|
||||
test("mcp and default mode block built-ins while preserving injected MCP servers", () => {
|
||||
for (const toolIntegrationMode of ["mcp", undefined]) {
|
||||
const opts = buildCodebuddyQueryOptions({
|
||||
toolIntegrationMode,
|
||||
injectedMcpServers: [{ name: "netcatty", command: "/abs/electron" }],
|
||||
});
|
||||
assert.ok(!("tools" in opts));
|
||||
assert.ok(!("allowedTools" in opts));
|
||||
assert.equal(opts.permissionMode, "bypassPermissions");
|
||||
for (const name of ["Bash", "PowerShell", "Read", "Edit", "Write", "Agent", "Skill", "AskUserQuestion"]) {
|
||||
assert.ok(opts.disallowedTools.includes(name), `${name} must stay disabled`);
|
||||
}
|
||||
assert.equal(opts.mcpServers.netcatty.command, "/abs/electron");
|
||||
}
|
||||
});
|
||||
|
||||
test("mcp mode omits --tools under the SDK serialization rule", () => {
|
||||
for (const toolIntegrationMode of ["mcp", undefined]) {
|
||||
const opts = buildCodebuddyQueryOptions({ toolIntegrationMode });
|
||||
const args = [];
|
||||
// @tencent-ai/agent-sdk lib/transport/process-transport.js
|
||||
if (opts.tools !== undefined) {
|
||||
args.push("--tools", opts.tools.join(","));
|
||||
}
|
||||
assert.deepEqual(args, []);
|
||||
}
|
||||
});
|
||||
|
||||
test("skills mode keeps the Bash whitelist and UI exclusions", () => {
|
||||
const opts = buildCodebuddyQueryOptions({ toolIntegrationMode: "skills" });
|
||||
assert.deepEqual(opts.tools, ["Bash"]);
|
||||
assert.deepEqual(opts.disallowedTools, ["AskUserQuestion"]);
|
||||
assert.ok(!opts.disallowedTools.includes("Bash"));
|
||||
assert.ok(!("allowedTools" in opts));
|
||||
});
|
||||
|
||||
test("built-in tools are mode-aware", () => {
|
||||
assert.deepEqual(codebuddyBuiltinTools("mcp"), []);
|
||||
assert.deepEqual(codebuddyBuiltinTools(undefined), []);
|
||||
|
||||
@@ -820,6 +820,14 @@ html[data-theme-transition] *::after {
|
||||
-webkit-user-select: auto;
|
||||
}
|
||||
|
||||
/* Scrolled boxes export native regions beyond their scroll clip. Only the
|
||||
stationary viewport contributes an exclusion via its inline no-drag style. */
|
||||
.top-tab-scroll-viewport,
|
||||
.top-tab-scroll-viewport * {
|
||||
-webkit-app-region: none;
|
||||
app-region: none;
|
||||
}
|
||||
|
||||
/* Selected top-tab hooks. Fill and text stay on the tab's inline style so the
|
||||
unset custom properties fall through to the existing chrome colors. The
|
||||
border is a 1px inset outline and stays invisible until
|
||||
|
||||
Reference in new issue
Block a user