feat: add multi-project support (#110)
* feat: Implement project management store with project path validation and synchronization - Added `useProjectsStore` for managing projects, including adding, removing, renaming, and validating project paths. - Implemented persistence for projects and active project ID using safe storage. - Introduced synchronization from desktop settings to keep project data consistent. - Enhanced session store to manage sessions by directory and added new methods for session management. - Updated todo store to fetch session todos based on the directory context. - Refactored server code to validate and resolve project directories for various API endpoints. - Added project entry validation and sanitization to ensure data integrity. * feat(settings): migrate legacy project settings and update settings loading logic * feat: enhance project management with directory-aware settings and improved agent/command source handling * feat: enhance session and project management with directory-aware settings and improved configuration refresh logic * feat: enhance project management with worktree manager integration and project directory resolution * feat: enhance agent groups store with project directory resolution and loading logic * feat: add heartbeat management and global wrapping for SSE blocks in agent and chat providers * feat: refactor command and project handling in useCommandsStore - Replaced useDirectoryStore with useProjectsStore to manage project paths. - Introduced getRequestDirectory function to determine the active project directory. - Updated command fetching to respect project-level scoping. - Enhanced error handling and logging for command configuration fetching. - Improved command configuration saving and updating to utilize project directory context. feat: enhance project path normalization in useProjectsStore - Added resolveTildePath function to expand paths starting with ~. - Updated normalizeProjectPath to utilize home directory for path expansion. fix: update permission handling in useSessionStore - Changed Permission type to PermissionRequest for clarity. - Updated respondToPermission method to use requestId instead of permissionId. refactor: improve permission utilities - Introduced types for PermissionAction and PermissionRule. - Enhanced getAgentDefinition and resolveConfigStore functions for better type safety. - Added resolvePermissionAction to streamline permission resolution logic. feat: add agent configuration retrieval endpoint - Implemented new API endpoint to fetch agent configuration based on project directory. - Enhanced getAgentPermissionSource to prioritize project-level permissions. chore: update SDK version in package.json files - Bumped @opencode-ai/sdk version to ^1.1.1 across all relevant package.json files. refactor: streamline bridge message handling - Updated handleBridgeMessage to accept directory parameter for agent and command requests. - Improved local API request handling to extract directory from query parameters and headers. feat: enhance project configuration management - Added functions to retrieve and merge project configuration paths. - Improved handling of existing project configuration files for agents and commands. * feat: enhance VSCode integration and session management - Added support for a sticky sidebar header background in light and dark themes. - Introduced functions to read VSCode workspace directory and check if running in VSCode. - Implemented detailed logging for session loading and creation processes. - Enhanced session filtering based on directory structure and canonical paths. - Added a new method to reorder projects and prevent modifications in VSCode workspace. - Improved error handling and logging for app initialization and markdown file parsing. - Updated API checks and health checks to ensure readiness before proceeding. - Refactored code for better readability and maintainability across various modules. * feat: improve agent and branch selection logic, enhance session management, and update multi-run creation response * feat: add worktree management actions in agent group detail and sidebar, including delete and keep only options * fix(ui): share IME guard and cover multi-run * fix(session): reduce maximum visible sessions in group from 7 to 5
This commit is contained in:
committed by
GitHub
parent
8aa379e313
commit
18c5b4c7b5
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { RiCheckLine, RiCloseLine, RiFileEditLine, RiGlobalLine, RiPencilAiLine, RiQuestionLine, RiTerminalBoxLine, RiTimeLine, RiToolsLine } from '@remixicon/react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import type { Permission, PermissionResponse } from '@/types/permission';
|
||||
import type { PermissionRequest, PermissionResponse } from '@/types/permission';
|
||||
import { useSessionStore } from '@/stores/useSessionStore';
|
||||
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
||||
import { useThemeSystem } from '@/contexts/useThemeSystem';
|
||||
@@ -10,7 +10,7 @@ import { ScrollableOverlay } from '@/components/ui/ScrollableOverlay';
|
||||
import { DiffPreview, WritePreview } from './DiffPreview';
|
||||
|
||||
interface PermissionCardProps {
|
||||
permission: Permission;
|
||||
permission: PermissionRequest;
|
||||
onResponse?: (response: 'once' | 'always' | 'reject') => void;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ export const PermissionCard: React.FC<PermissionCardProps> = ({
|
||||
return null;
|
||||
}
|
||||
|
||||
const toolName = permission.type || 'Unknown Tool';
|
||||
const toolName = permission.permission || 'unknown';
|
||||
const tool = toolName.toLowerCase();
|
||||
|
||||
const getMeta = (key: string, fallback: string = ''): string => {
|
||||
@@ -106,9 +106,7 @@ export const PermissionCard: React.FC<PermissionCardProps> = ({
|
||||
const description = getMeta('description');
|
||||
const workingDir = getMeta('cwd') || getMeta('working_directory') || getMeta('directory') || getMeta('path');
|
||||
const timeout = getMetaNum('timeout');
|
||||
|
||||
const commandInTitle = permission.title === command;
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
{description && (
|
||||
@@ -125,7 +123,7 @@ export const PermissionCard: React.FC<PermissionCardProps> = ({
|
||||
</div>
|
||||
)}
|
||||
{}
|
||||
{command && !commandInTitle && (
|
||||
{command && (
|
||||
<div>
|
||||
<SyntaxHighlighter
|
||||
language="bash"
|
||||
@@ -329,110 +327,15 @@ export const PermissionCard: React.FC<PermissionCardProps> = ({
|
||||
|
||||
{}
|
||||
<div className="px-2 py-2">
|
||||
{/* Show patterns being requested */}
|
||||
{(permission.patterns as string[]) && (permission.patterns as string[]).length > 0 && (
|
||||
{permission.patterns.length > 0 && (
|
||||
<div className="mb-2">
|
||||
<div className="typography-meta text-muted-foreground mb-1">Patterns:</div>
|
||||
<code className="typography-meta px-2 py-1 bg-muted/30 rounded block break-all">
|
||||
{(permission.patterns as string[]).join(", ")}
|
||||
{permission.patterns.join(", ")}
|
||||
</code>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!((permission.patterns as string[]) && (permission.patterns as string[]).length > 0) &&
|
||||
(permission.pattern as string | string[]) &&
|
||||
<div className="mb-2">
|
||||
<div className="typography-meta text-muted-foreground mb-1">Pattern:</div>
|
||||
<code className="typography-meta px-2 py-1 bg-muted/30 rounded block break-all">
|
||||
{Array.isArray(permission.pattern) ? permission.pattern.join(", ") : permission.pattern}
|
||||
</code>
|
||||
</div>
|
||||
}
|
||||
|
||||
{(() => {
|
||||
|
||||
let primaryContent = '';
|
||||
let primaryLanguage = 'text';
|
||||
let shouldHighlight = false;
|
||||
|
||||
if (tool === 'bash' || tool === 'shell' || tool === 'shell_command') {
|
||||
primaryContent = getMeta('command') || getMeta('cmd') || getMeta('script');
|
||||
primaryLanguage = 'bash';
|
||||
shouldHighlight = true;
|
||||
}
|
||||
|
||||
else if (tool === 'edit' || tool === 'multiedit' || tool === 'str_replace' || tool === 'str_replace_based_edit_tool' || tool === 'write' || tool === 'create' || tool === 'file_write') {
|
||||
primaryContent = getMeta('path') || getMeta('file_path') || getMeta('filename') || getMeta('filePath');
|
||||
shouldHighlight = false;
|
||||
}
|
||||
|
||||
else if (tool === 'webfetch' || tool === 'fetch') {
|
||||
primaryContent = getMeta('url') || getMeta('uri') || getMeta('endpoint');
|
||||
shouldHighlight = false;
|
||||
}
|
||||
|
||||
const titleMatchesContent = permission.title === primaryContent;
|
||||
|
||||
if (titleMatchesContent && primaryContent && shouldHighlight) {
|
||||
return (
|
||||
<div className="mb-3">
|
||||
<SyntaxHighlighter
|
||||
language={primaryLanguage}
|
||||
style={syntaxTheme}
|
||||
PreTag="div"
|
||||
customStyle={{
|
||||
margin: 0,
|
||||
padding: '0.5rem',
|
||||
fontSize: 'var(--text-meta)',
|
||||
lineHeight: '1.25rem',
|
||||
background: 'rgb(var(--muted) / 0.3)',
|
||||
borderRadius: '0.25rem',
|
||||
whiteSpace: 'pre-wrap',
|
||||
wordBreak: 'break-word',
|
||||
overflowWrap: 'break-word',
|
||||
overflow: 'visible'
|
||||
}}
|
||||
codeTagProps={{
|
||||
style: {
|
||||
whiteSpace: 'pre-wrap',
|
||||
wordBreak: 'break-word',
|
||||
overflowWrap: 'break-word'
|
||||
}
|
||||
}}
|
||||
wrapLongLines={true}
|
||||
>
|
||||
{primaryContent}
|
||||
</SyntaxHighlighter>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (titleMatchesContent && primaryContent && !shouldHighlight) {
|
||||
return (
|
||||
<div className="mb-3">
|
||||
<code className="typography-ui-label px-2 py-1 bg-muted/30 rounded block break-all">
|
||||
{primaryContent}
|
||||
</code>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (permission.title) {
|
||||
return (
|
||||
<div className={cn(
|
||||
"typography-ui-label text-foreground mb-3",
|
||||
|
||||
(shouldHighlight || primaryContent) && "font-mono"
|
||||
)}>
|
||||
{permission.title}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
})()}
|
||||
|
||||
{}
|
||||
{renderToolContent()}
|
||||
</div>
|
||||
|
||||
@@ -460,7 +363,7 @@ export const PermissionCard: React.FC<PermissionCardProps> = ({
|
||||
Allow Once
|
||||
</button>
|
||||
|
||||
{(permission.always as string[]) && (permission.always as string[]).length > 0 ? (
|
||||
{permission.always.length > 0 ? (
|
||||
<button
|
||||
onClick={() => handleResponse('always')}
|
||||
disabled={isResponding}
|
||||
|
||||
Reference in New Issue
Block a user