Repository navigation
fix: map runtime modes to correct permission levels #1587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
d9ec964
7c6a958
364cd56
b4a130b
7a3d964
215e57f
a4f6644
f0d471c
3d31280
394c195
c6cdbcd
6707b61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2693,7 +2693,11 @@ const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( | |
| ? modelSelection.options.thinking | ||
| : undefined; | ||
| const effectiveEffort = getEffectiveClaudeCodeEffort(effort); | ||
| const permissionMode = input.runtimeMode === "full-access" ? "bypassPermissions" : undefined; | ||
| const runtimeModeToPermission: Record<string, PermissionMode> = { | ||
| "auto-accept-edits": "acceptEdits", | ||
| "full-access": "bypassPermissions", | ||
| }; | ||
| const permissionMode = runtimeModeToPermission[input.runtimeMode]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implicit undefined for approval-required lacks exhaustiveness safetyLow Severity The Reviewed by Cursor Bugbot for commit 6707b61. Configure here. |
||
| const settings = { | ||
| ...(typeof thinking === "boolean" ? { alwaysThinkingEnabled: thinking } : {}), | ||
| ...(fastMode ? { fastMode: true } : {}), | ||
|
|
@@ -2881,8 +2885,7 @@ const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* ( | |
| }); | ||
| } else if (input.interactionMode === "default") { | ||
| yield* Effect.tryPromise({ | ||
| try: () => | ||
| context.query.setPermissionMode(context.basePermissionMode ?? "bypassPermissions"), | ||
| try: () => context.query.setPermissionMode(context.basePermissionMode ?? "default"), | ||
| catch: (cause) => toRequestError(input.threadId, "turn/setPermissionMode", cause), | ||
| }); | ||
| } | ||
|
|
||
|
macroscopeapp[bot] marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,6 +102,7 @@ import { | |
| ListTodoIcon, | ||
| LockIcon, | ||
| LockOpenIcon, | ||
| PenLineIcon, | ||
| XIcon, | ||
| } from "lucide-react"; | ||
| import { Button } from "./ui/button"; | ||
|
|
@@ -332,6 +333,30 @@ interface PendingPullRequestSetupRequest { | |
| scriptId: string; | ||
| } | ||
|
|
||
| const runtimeModeConfig: Record< | ||
| RuntimeMode, | ||
| { label: string; title: string; icon: React.ReactNode; next: RuntimeMode } | ||
| > = { | ||
| "approval-required": { | ||
| label: "Supervised", | ||
| title: "Supervised - click for auto-accept edits", | ||
| icon: <LockIcon />, | ||
| next: "auto-accept-edits", | ||
| }, | ||
| "auto-accept-edits": { | ||
| label: "Auto-accept edits", | ||
| title: "Auto-accept edits - click for full access", | ||
| icon: <PenLineIcon />, | ||
| next: "full-access", | ||
| }, | ||
| "full-access": { | ||
| label: "Full access", | ||
| title: "Full access - click for supervised", | ||
| icon: <LockOpenIcon />, | ||
| next: "approval-required", | ||
| }, | ||
| }; | ||
|
|
||
| function useLocalDispatchState(input: { | ||
| activeThread: Thread | undefined; | ||
| activeLatestTurn: Thread["latestTurn"] | null; | ||
|
|
@@ -1811,10 +1836,8 @@ export default function ChatView({ threadId }: ChatViewProps) { | |
| const toggleInteractionMode = useCallback(() => { | ||
| handleInteractionModeChange(interactionMode === "plan" ? "default" : "plan"); | ||
| }, [handleInteractionModeChange, interactionMode]); | ||
| const toggleRuntimeMode = useCallback(() => { | ||
| void handleRuntimeModeChange( | ||
| runtimeMode === "full-access" ? "approval-required" : "full-access", | ||
| ); | ||
| const cycleRuntimeMode = useCallback(() => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is a toggle button the best way? A select with a short description might be better? https://coss.com/ui/docs/components/select#with-object-values
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah maybe, let me check how it would look and I'll post a screenshot here so we can decide.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could work, wdyt? |
||
| void handleRuntimeModeChange(runtimeModeConfig[runtimeMode].next); | ||
| }, [handleRuntimeModeChange, runtimeMode]); | ||
| const togglePlanSidebar = useCallback(() => { | ||
| setPlanSidebarOpen((open) => { | ||
|
|
@@ -4015,7 +4038,7 @@ export default function ChatView({ threadId }: ChatViewProps) { | |
| traitsMenuContent={providerTraitsMenuContent} | ||
| onToggleInteractionMode={toggleInteractionMode} | ||
| onTogglePlanSidebar={togglePlanSidebar} | ||
| onToggleRuntimeMode={toggleRuntimeMode} | ||
| onRuntimeModeChange={handleRuntimeModeChange} | ||
| /> | ||
| ) : ( | ||
| <> | ||
|
|
@@ -4062,22 +4085,12 @@ export default function ChatView({ threadId }: ChatViewProps) { | |
| className="shrink-0 whitespace-nowrap px-2 text-muted-foreground/70 hover:text-foreground/80 sm:px-3" | ||
| size="sm" | ||
| type="button" | ||
| onClick={() => | ||
| void handleRuntimeModeChange( | ||
| runtimeMode === "full-access" | ||
| ? "approval-required" | ||
| : "full-access", | ||
| ) | ||
| } | ||
| title={ | ||
| runtimeMode === "full-access" | ||
| ? "Full access — click to require approvals" | ||
| : "Approval required — click for full access" | ||
| } | ||
| onClick={cycleRuntimeMode} | ||
| title={runtimeModeConfig[runtimeMode].title} | ||
| > | ||
| {runtimeMode === "full-access" ? <LockOpenIcon /> : <LockIcon />} | ||
| {runtimeModeConfig[runtimeMode].icon} | ||
| <span className="sr-only sm:not-sr-only"> | ||
| {runtimeMode === "full-access" ? "Full access" : "Supervised"} | ||
| {runtimeModeConfig[runtimeMode].label} | ||
| </span> | ||
| </Button> | ||
|
|
||
|
|
||



There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it.eachor similarThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 🙌