initialPermissionMode not applied when resuming sessions in VSCode extension
Bug Description
The claudeCode.initialPermissionMode VSCode setting is not applied when resuming existing sessions. It only works for newly created sessions.
Expected Behavior
When claudeCode.initialPermissionMode is set to "bypassPermissions" (with claudeCode.allowDangerouslySkipPermissions: true), resuming a session should start with Bypass Permissions mode enabled.
Actual Behavior
Resumed sessions always start with "default" permission mode ("Ask before edits"), ignoring the initialPermissionMode setting.
Root Cause Analysis
In webview/index.js, the fromServer static method creates session objects without setting permissionMode:
static fromServer(e,t,n) {
let o = new i(t,n);
return o.sessionId.value = e.id,
o.lastModifiedTime.value = e.lastModified,
o.summary.value = e.summary,
o.worktree.value = e.worktree,
o.isExplicit.value = !0,
o // permissionMode not set, defaults to "default"
}
Meanwhile, initialPermissionMode is only applied for new sessions:
let o = n.config.value?.initialPermissionMode;
if (o) { t.permissionMode.value = o } // Only runs for new sessions
Proposed Fix
Apply initialPermissionMode when creating sessions from server in both activateSessionFromServer and the session listing loop:
// In activateSessionFromServer:
let s = Vk.fromServer(r, ()=>this.getConnection(), this.context);
let pm = this.comms?.connection?.value?.config?.value?.initialPermissionMode;
if (pm) s.permissionMode.value = pm;
// Similarly in listSessions loop:
let a = Vk.fromServer(r, ()=>this.getConnection(), this.context);
let pm = this.comms?.connection?.value?.config?.value?.initialPermissionMode;
if (pm) a.permissionMode.value = pm;
Environment
- VSCode Extension Version: 2.1.11
- Platform: macOS (darwin-arm64)
- VSCode Settings:
``json``
{
"claudeCode.allowDangerouslySkipPermissions": true,
"claudeCode.initialPermissionMode": "bypassPermissions"
}
Workaround
Users can manually patch ~/.vscode/extensions/anthropic.claude-code-*/webview/index.js with the fix above, then restart VSCode.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗