mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Improve permission dialog UI and update Python package documentation
This commit is contained in:
1 parent
a500d2ce55
commit
f1557fba5d
5 files changed
+90
-57
No files matched your search
+24
-6
@@ -68,12 +68,30 @@ Prefer **pnpm** or **bun** over npm for installing dependencies to save disk spa
|
||||
- Use \`bun install\` as an alternative
|
||||
- Both are pre-installed in the container
|
||||
|
||||
### Python Packages
|
||||
Prefer **uv** for Python package management:
|
||||
- Use \`uv venv\` to create virtual environments instead of \`python -m venv\`
|
||||
- Use \`uv pip install\` to install packages instead of \`pip install\`
|
||||
- Use \`uv pip\` for all pip operations
|
||||
- uv is pre-installed in the container and provides faster package installation
|
||||
### Python Packages
|
||||
Always create a virtual environment in the repository directory before installing packages:
|
||||
|
||||
1. Create virtual environment in repo:
|
||||
\`cd \`<repo_path>\`
|
||||
\`uv venv .venv\`
|
||||
|
||||
2. Activate the virtual environment:
|
||||
\`source .venv/bin/activate\` # or \`uv pip sync\` for project-based workflows
|
||||
|
||||
3. Install packages into activated environment:
|
||||
\`uv pip install \`<package>\`
|
||||
\`uv pip install -r requirements.txt\`
|
||||
|
||||
4. Run Python commands:
|
||||
\`python script.py\` # Uses activated .venv
|
||||
|
||||
Alternative: Use \`uv run python script.py\` to skip explicit activation
|
||||
|
||||
**Important:**
|
||||
- Always create .venv in the repository directory (not workspace root)
|
||||
- Activate the environment before running pip operations
|
||||
- uv is pre-installed in the container and provides faster package installation
|
||||
- .venv directories created in repos will persist but can be removed safely
|
||||
|
||||
## General Guidelines
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ function PermissionDialogWrapper() {
|
||||
respondToPermission,
|
||||
showDialog,
|
||||
setShowDialog,
|
||||
currentRepoDirectory,
|
||||
} = usePermissionContext()
|
||||
|
||||
return (
|
||||
@@ -64,6 +65,7 @@ function PermissionDialogWrapper() {
|
||||
onRespond={respondToPermission}
|
||||
open={showDialog}
|
||||
onOpenChange={setShowDialog}
|
||||
repoDirectory={currentRepoDirectory}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ interface PermissionRequestDialogProps {
|
||||
pendingCount: number
|
||||
isFromDifferentSession?: boolean
|
||||
sessionTitle?: string
|
||||
repoDirectory?: string | null
|
||||
onRespond: (permissionID: string, sessionID: string, response: PermissionResponse) => Promise<void>
|
||||
open?: boolean
|
||||
onOpenChange?: (open: boolean) => void
|
||||
@@ -113,6 +114,7 @@ export function PermissionRequestDialog({
|
||||
pendingCount,
|
||||
isFromDifferentSession,
|
||||
sessionTitle,
|
||||
repoDirectory,
|
||||
onRespond,
|
||||
open: parentOpen,
|
||||
onOpenChange,
|
||||
@@ -144,22 +146,22 @@ export function PermissionRequestDialog({
|
||||
|
||||
return (
|
||||
<Dialog open={parentOpen ?? true} onOpenChange={onOpenChange ?? (() => {})}>
|
||||
<DialogContent className="max-w-[calc(100vw-2rem)] sm:max-w-md">
|
||||
<DialogContent className="max-w-[calc(100vw-2rem)] sm:max-w-md p-4 sm:p-6">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="flex items-center gap-2">
|
||||
Permission Request
|
||||
<DialogTitle className="flex items-center gap-2 flex-wrap">
|
||||
<span>Permission Request</span>
|
||||
{hasMultiple && (
|
||||
<span className="text-xs font-normal text-muted-foreground bg-muted px-2 py-0.5 rounded-full">
|
||||
<span className="text-xs font-normal text-muted-foreground bg-muted px-2 py-0.5 rounded-full whitespace-nowrap">
|
||||
+{pendingCount - 1} more
|
||||
</span>
|
||||
)}
|
||||
</DialogTitle>
|
||||
<DialogDescription>
|
||||
<DialogDescription className="break-all">
|
||||
{permission.title || `Allow ${typeLabel.toLowerCase()}?`}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="space-y-3">
|
||||
<div className="space-y-3 overflow-hidden">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs font-medium text-muted-foreground uppercase tracking-wide">
|
||||
{typeLabel}
|
||||
@@ -167,39 +169,46 @@ export function PermissionRequestDialog({
|
||||
</div>
|
||||
|
||||
{details.primary && (
|
||||
<div className="bg-muted/50 border rounded-md p-3 max-h-32 overflow-x-auto overflow-y-auto">
|
||||
<pre className="text-sm font-mono whitespace-pre-wrap break-words max-w-full">
|
||||
<div className="bg-muted/50 border rounded-md p-2 sm:p-3 max-h-32 overflow-y-auto overflow-x-hidden">
|
||||
<pre className="text-xs sm:text-sm font-mono whitespace-pre-wrap break-all w-full">
|
||||
{details.primary}
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{details.secondary && (
|
||||
<div className="bg-muted/30 border rounded-md p-3 max-h-24 overflow-x-auto overflow-y-auto">
|
||||
<pre className="text-xs font-mono whitespace-pre-wrap break-words max-w-full text-muted-foreground">
|
||||
<div className="bg-muted/30 border rounded-md p-2 sm:p-3 max-h-24 overflow-y-auto overflow-x-hidden">
|
||||
<pre className="text-xs font-mono whitespace-pre-wrap break-all w-full text-muted-foreground">
|
||||
{details.secondary}
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isFromDifferentSession ? (
|
||||
<div className="text-xs bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20 rounded-md px-2 py-1.5">
|
||||
From another session: <span className="font-medium">{displaySessionName}</span>
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-xs text-muted-foreground">
|
||||
Session: <span className="font-medium">{displaySessionName}</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="text-xs text-muted-foreground space-y-1">
|
||||
{repoDirectory && (
|
||||
<div className="truncate">
|
||||
Repo: <span className="font-medium">{repoDirectory.split('/').pop() || repoDirectory}</span>
|
||||
</div>
|
||||
)}
|
||||
{isFromDifferentSession ? (
|
||||
<div className="bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20 rounded-md px-2 py-1.5 truncate">
|
||||
From another session: <span className="font-medium">{displaySessionName}</span>
|
||||
</div>
|
||||
) : (
|
||||
<div className="truncate">
|
||||
Session: <span className="font-medium">{displaySessionName}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DialogFooter className="flex-col-reverse gap-2 sm:flex-row sm:justify-between">
|
||||
<DialogFooter className="flex-col-reverse gap-2 sm:flex-row sm:gap-2 mt-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => handleResponse('reject')}
|
||||
disabled={isLoading}
|
||||
className={cn(
|
||||
"w-full sm:flex-1",
|
||||
"w-full sm:flex-1 text-sm h-9 sm:h-10",
|
||||
loadingAction === 'reject' && "opacity-70"
|
||||
)}
|
||||
>
|
||||
@@ -207,26 +216,26 @@ export function PermissionRequestDialog({
|
||||
</Button>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => handleResponse('once')}
|
||||
disabled={isLoading}
|
||||
className={cn(
|
||||
"w-full sm:flex-1",
|
||||
loadingAction === 'once' && "opacity-70"
|
||||
)}
|
||||
>
|
||||
{loadingAction === 'once' ? 'Allowing...' : 'Allow Once'}
|
||||
</Button>
|
||||
<Button
|
||||
variant="default"
|
||||
onClick={() => handleResponse('always')}
|
||||
disabled={isLoading}
|
||||
className={cn(
|
||||
"w-full sm:flex-1",
|
||||
"w-full sm:flex-1 text-sm h-9 sm:h-10",
|
||||
loadingAction === 'always' && "opacity-70"
|
||||
)}
|
||||
>
|
||||
{loadingAction === 'always' ? 'Allowing...' : 'Allow Always'}
|
||||
</Button>
|
||||
<Button
|
||||
variant="default"
|
||||
onClick={() => handleResponse('once')}
|
||||
disabled={isLoading}
|
||||
className={cn(
|
||||
"w-full sm:flex-1 text-sm h-9 sm:h-10",
|
||||
loadingAction === 'once' && "opacity-70"
|
||||
)}
|
||||
>
|
||||
{loadingAction === 'once' ? 'Allowing...' : 'Allow Once'}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
@@ -29,6 +29,8 @@ interface PermissionContextValue {
|
||||
currentSessionId: string | null
|
||||
getPermissionForCallID: (callID: string, sessionID: string) => Permission | null
|
||||
hasPermissionsForSession: (sessionID: string) => boolean
|
||||
currentRepoDirectory: string | null
|
||||
getRepoForSession: (sessionID: string) => ActiveRepo | null
|
||||
}
|
||||
|
||||
const PermissionContext = createContext<PermissionContextValue | null>(null)
|
||||
@@ -321,6 +323,21 @@ prevPendingCountRef.current = pendingCount
|
||||
[getClient, dismiss],
|
||||
)
|
||||
|
||||
const getRepoForSession = useCallback((sessionID: string): ActiveRepo | null => {
|
||||
for (const repo of activeRepos) {
|
||||
if (repo.sessions.some((s) => s.id === sessionID)) {
|
||||
return repo
|
||||
}
|
||||
}
|
||||
return null
|
||||
}, [activeRepos])
|
||||
|
||||
const currentRepoDirectory = useMemo(() => {
|
||||
if (!currentPermission) return null
|
||||
const repo = getRepoForSession(currentPermission.sessionID)
|
||||
return repo?.directory ?? null
|
||||
}, [currentPermission, getRepoForSession])
|
||||
|
||||
const value: PermissionContextValue = useMemo(
|
||||
() => ({
|
||||
currentPermission,
|
||||
@@ -333,6 +350,8 @@ prevPendingCountRef.current = pendingCount
|
||||
currentSessionId,
|
||||
getPermissionForCallID,
|
||||
hasPermissionsForSession,
|
||||
currentRepoDirectory,
|
||||
getRepoForSession,
|
||||
}),
|
||||
[
|
||||
currentPermission,
|
||||
@@ -344,6 +363,8 @@ prevPendingCountRef.current = pendingCount
|
||||
currentSessionId,
|
||||
getPermissionForCallID,
|
||||
hasPermissionsForSession,
|
||||
currentRepoDirectory,
|
||||
getRepoForSession,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ set -e
|
||||
|
||||
export HOME=/home/node
|
||||
export BUN_INSTALL="$HOME/.bun"
|
||||
export PATH="$BUN_INSTALL/bin:$HOME/.opencode/bin:$HOME/.local/bin:/usr/local/bin:$PATH"
|
||||
export PATH="$BUN_INSTALL/bin:$HOME/.opencode/bin:/usr/local/bin:$PATH"
|
||||
|
||||
echo "🔍 Checking Bun installation..."
|
||||
|
||||
@@ -22,23 +22,6 @@ else
|
||||
echo "✅ Bun is installed (version: $BUN_VERSION)"
|
||||
fi
|
||||
|
||||
echo "🔍 Checking uv installation..."
|
||||
|
||||
if ! command -v uv >/dev/null 2>&1; then
|
||||
echo "❌ uv not found. Installing..."
|
||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
|
||||
if ! command -v uv >/dev/null 2>&1; then
|
||||
echo "❌ Failed to install uv. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ uv installed successfully"
|
||||
else
|
||||
UV_VERSION=$(uv --version 2>&1 || echo "unknown")
|
||||
echo "✅ uv is installed (version: $UV_VERSION)"
|
||||
fi
|
||||
|
||||
echo "🔍 Checking OpenCode installation..."
|
||||
|
||||
MIN_OPENCODE_VERSION="1.0.137"
|
||||
|
||||
Reference in new issue
Block a user