diff --git a/apps/vscode-extension/CHANGELOG.md b/apps/vscode-extension/CHANGELOG.md index 744d7007..cf8dcad0 100644 --- a/apps/vscode-extension/CHANGELOG.md +++ b/apps/vscode-extension/CHANGELOG.md @@ -8,6 +8,7 @@ - **Import a chat from claude.ai** in the AI Agents section: paste the claude.ai/code link and Code-XR brings the session into the folder with `claude --teleport`, branch included. - Right-click a Claude Code session of the workspace: **Continue on claude.ai** (Remote Control, after you confirm) or **Continue in the terminal**. - Remote Control needs a claude.ai sign-in, not an API key. Nothing is shared until you confirm. + - **Continue sessions on claude.ai automatically** in the AI Agents section: one switch, after one confirmation, turns on Claude Code's own `remoteControlAtStartup`, so every Claude Code session (VS Code, terminal, Claude Desktop, Code-XR IDE) is reachable from claude.ai/code and the mobile app without any extra step. Off by default. - **Agent Flow, the fifth analysis type.** Watch an AI coding agent work on the XR analysis table. - The project is a city: folders are plates, files are buildings. - Every agent is a worker. Sub-agents get their own worker and work in parallel. diff --git a/apps/vscode-extension/package.json b/apps/vscode-extension/package.json index 7f1b11b9..e9d502b7 100644 --- a/apps/vscode-extension/package.json +++ b/apps/vscode-extension/package.json @@ -382,6 +382,10 @@ "command": "codeXR.claudeSessions.continueOnClaudeAi", "title": "Code-XR: Continue a Claude Code Chat on claude.ai (Remote Control)" }, + { + "command": "codeXR.claudeSessions.toggleAutoRemoteControl", + "title": "Code-XR: Continue Claude Code Sessions on claude.ai Automatically (On/Off)" + }, { "command": "codeXR.claudeSessions.continueInTerminal", "title": "Code-XR: Continue a Claude Code Chat in the Terminal" diff --git a/apps/vscode-extension/src/core/claude-sessions/claudeSessionContinuity.ts b/apps/vscode-extension/src/core/claude-sessions/claudeSessionContinuity.ts index e491c6ac..0ed797a3 100644 --- a/apps/vscode-extension/src/core/claude-sessions/claudeSessionContinuity.ts +++ b/apps/vscode-extension/src/core/claude-sessions/claudeSessionContinuity.ts @@ -122,3 +122,75 @@ export const REMOTE_CONTROL_CONSENT = export const TELEPORT_HINT = 'Claude Code copies the claude.ai/code session into this folder (its conversation and its branch). It needs the same repository, a clean git tree and the branch pushed. ' + 'When it is done, quit Claude Code in the terminal; the chat is then in this folder\'s Claude Code history.'; + +// ---- #456: automatic continuity (Remote Control at startup) ----------------- + +/** How a host treats Remote Control for its Claude Code chats: ask once, always on, or never. */ +export const AUTO_REMOTE_CONTROL_MODES = ['ask', 'always', 'never'] as const; +export type AutoRemoteControlMode = (typeof AUTO_REMOTE_CONTROL_MODES)[number]; + +export function isAutoRemoteControlMode(value: unknown): value is AutoRemoteControlMode { + return typeof value === 'string' && (AUTO_REMOTE_CONTROL_MODES as readonly string[]).includes(value); +} + +/** Claude Code's own setting: start Remote Control with every session. */ +export const REMOTE_CONTROL_AT_STARTUP = 'remoteControlAtStartup'; + +/** + * The ACP `_meta` that makes Claude Code's adapter start Remote Control with + * this session only (`session/new` and `session/load`), as the setting would + * for all of them. The adapter then sends a `Remote Control connected` notice + * with the claude.ai link. Null when Remote Control is not wanted. + */ +export function remoteControlSessionMeta(on: boolean): { claudeCode: { options: { settings: Record } } } | null { + return on ? { claudeCode: { options: { settings: { [REMOTE_CONTROL_AT_STARTUP]: true } } } } : null; +} + +/** The one-time question a host asks before it shares chats automatically. */ +export const AUTO_REMOTE_CONTROL_QUESTION = 'Continue your Claude Code chats on claude.ai automatically?'; + +export const AUTO_REMOTE_CONTROL_CONSENT = + 'Every Claude Code chat will start with Remote Control, so you can open it from claude.ai/code or the Claude mobile app, signed in with the same Claude account, without pressing anything. ' + + 'The code keeps running on this computer; messages and tool results travel through Anthropic\'s servers. It needs a claude.ai sign-in (Pro, Max, Team or Enterprise), not an API key. ' + + 'You can change it at any time in the settings, and stop sharing any single chat.'; + +/** + * #456: Claude Code's `settings.json` with `remoteControlAtStartup` set (`on`) + * or removed, every other key kept. `text` is the file's content, or null when + * it does not exist. Throws on a file that is not a JSON object, so a host + * never overwrites settings it could not read. + */ +export function withRemoteControlAtStartup(text: string | null, on: boolean): string { + let settings: Record = {}; + if (text !== null && text.trim() !== '') { + let parsed: unknown; + try { + parsed = JSON.parse(text); + } catch { + throw new Error('Claude Code\'s settings.json is not valid JSON; fix it first.'); + } + if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) { + throw new Error('Claude Code\'s settings.json is not a JSON object; fix it first.'); + } + settings = { ...(parsed as Record) }; + } + if (on) { + settings[REMOTE_CONTROL_AT_STARTUP] = true; + } else { + delete settings[REMOTE_CONTROL_AT_STARTUP]; + } + return `${JSON.stringify(settings, null, 2)}\n`; +} + +/** Whether Claude Code's `settings.json` text turns Remote Control on for every session. */ +export function remoteControlAtStartupIn(text: string | null): boolean { + if (!text) { + return false; + } + try { + const parsed: unknown = JSON.parse(text); + return !!parsed && typeof parsed === 'object' && (parsed as Record)[REMOTE_CONTROL_AT_STARTUP] === true; + } catch { + return false; + } +} diff --git a/apps/vscode-extension/src/features/ai-agents/commands/claudeSessionCommands.ts b/apps/vscode-extension/src/features/ai-agents/commands/claudeSessionCommands.ts index 546cbb56..23f0b72b 100644 --- a/apps/vscode-extension/src/features/ai-agents/commands/claudeSessionCommands.ts +++ b/apps/vscode-extension/src/features/ai-agents/commands/claudeSessionCommands.ts @@ -1,7 +1,14 @@ +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; import * as vscode from 'vscode'; import { ExtensionCommandRegistration } from '../../../platform/commands/commandRegistry'; import { + AUTO_REMOTE_CONTROL_CONSENT, + AUTO_REMOTE_CONTROL_QUESTION, REMOTE_CONTROL_CONSENT, + remoteControlAtStartupIn, + withRemoteControlAtStartup, TELEPORT_HINT, commandLine, isLocalSessionId, @@ -23,6 +30,52 @@ import { agentFlowWorkspaceRoot, describeAge, listWorkspaceAgentSessions } from export const IMPORT_FROM_WEB_COMMAND = 'codeXR.claudeSessions.importFromWeb'; export const CONTINUE_ON_CLAUDE_AI_COMMAND = 'codeXR.claudeSessions.continueOnClaudeAi'; export const CONTINUE_IN_TERMINAL_COMMAND = 'codeXR.claudeSessions.continueInTerminal'; +export const TOGGLE_AUTO_REMOTE_CONTROL_COMMAND = 'codeXR.claudeSessions.toggleAutoRemoteControl'; + +/** + * #456: Claude Code's user settings file. Its `remoteControlAtStartup` is the + * single source of truth for "every Claude Code session continues on + * claude.ai": the extension does not host chats, so it turns Claude Code's own + * switch on or off rather than keeping a setting of its own. + */ +export function claudeSettingsFile(env: NodeJS.ProcessEnv = process.env, home = os.homedir()): string { + return path.join(env['CLAUDE_CONFIG_DIR'] || path.join(home, '.claude'), 'settings.json'); +} + +function readClaudeSettings(file: string): string | null { + try { + return fs.readFileSync(file, 'utf8'); + } catch { + return null; + } +} + +/** Whether every Claude Code session starts with Remote Control (Claude Code's own setting). */ +export function autoRemoteControlEnabled(file = claudeSettingsFile()): boolean { + return remoteControlAtStartupIn(readClaudeSettings(file)); +} + +/** Turns Claude Code's `remoteControlAtStartup` on (after consent) or off, keeping every other setting. */ +export async function toggleAutoRemoteControl(file = claudeSettingsFile()): Promise { + const on = !autoRemoteControlEnabled(file); + if (on) { + const go = await vscode.window.showWarningMessage( + AUTO_REMOTE_CONTROL_QUESTION, + { modal: true, detail: `${AUTO_REMOTE_CONTROL_CONSENT}\n\nCode-XR turns on Claude Code's own "remoteControlAtStartup" in ${file}, so it applies to every Claude Code session: in this editor, the terminal, Claude Desktop and the Code-XR IDE.` }, + 'Turn on', + ); + if (go !== 'Turn on') { + return; + } + } + const next = withRemoteControlAtStartup(readClaudeSettings(file), on); + fs.mkdirSync(path.dirname(file), { recursive: true }); + fs.writeFileSync(file, next, 'utf8'); + void vscode.commands.executeCommand('codeXR.modularTree.refresh'); + void vscode.window.showInformationMessage(on + ? 'Claude Code sessions now start with Remote Control: open them from claude.ai/code or the Claude mobile app. Sessions already running pick it up when they start again.' + : 'Claude Code sessions no longer start with Remote Control.'); +} const CLAUDE_SOURCE_PREFIX = 'claude-code:'; @@ -162,6 +215,13 @@ export function getClaudeSessionCommandRegistrations(): ExtensionCommandRegistra handler: (arg?: unknown) => continueOnClaudeAi(arg), errorMessage: 'The chat could not be shared with claude.ai', }, + { + id: TOGGLE_AUTO_REMOTE_CONTROL_COMMAND, + module: 'AI_AGENTS', + description: 'Turn Claude Code\'s Remote Control at startup on or off, so every session continues on claude.ai automatically', + handler: () => toggleAutoRemoteControl(), + errorMessage: 'Remote Control at startup could not be changed', + }, { id: CONTINUE_IN_TERMINAL_COMMAND, module: 'AI_AGENTS', diff --git a/apps/vscode-extension/src/features/ai-agents/views/AiAgentsSectionProvider.ts b/apps/vscode-extension/src/features/ai-agents/views/AiAgentsSectionProvider.ts index 5e7e67b4..c35547fc 100644 --- a/apps/vscode-extension/src/features/ai-agents/views/AiAgentsSectionProvider.ts +++ b/apps/vscode-extension/src/features/ai-agents/views/AiAgentsSectionProvider.ts @@ -5,11 +5,13 @@ import { AiAgentsTreeItem, createAgentSessionItem, createComingSoonItem, + createAutoRemoteControlItem, createImportFromWebItem, createNoAgentSessionsItem, createWatchAgentFlowItem, } from './aiAgentsItems'; import { describeAge, listWorkspaceAgentSessions } from '../commands/agentFlowCommands'; +import { autoRemoteControlEnabled } from '../commands/claudeSessionCommands'; /** Recent sessions listed under the entry point; the quick pick offers all of them. */ const RECENT_SESSIONS = 5; @@ -50,6 +52,7 @@ export class AiAgentsSectionProvider extends BaseSectionProvider createAgentSessionItem(session, describeAge(session.updatedAt, now))) : [createNoAgentSessionsItem()]), createImportFromWebItem(), + createAutoRemoteControlItem(autoRemoteControlEnabled()), createComingSoonItem(), ]; } diff --git a/apps/vscode-extension/src/features/ai-agents/views/aiAgentsItems.ts b/apps/vscode-extension/src/features/ai-agents/views/aiAgentsItems.ts index 989ed399..5e28cc72 100644 --- a/apps/vscode-extension/src/features/ai-agents/views/aiAgentsItems.ts +++ b/apps/vscode-extension/src/features/ai-agents/views/aiAgentsItems.ts @@ -7,7 +7,7 @@ import * as vscode from 'vscode'; * (epic #189, stories #214-#216). No row makes a network call: the sessions * are read from the local agents' own history files. */ -export type AiAgentsItemType = 'coming-soon' | 'agent-flow-watch' | 'agent-flow-session' | 'agent-flow-empty' | 'claude-import'; +export type AiAgentsItemType = 'coming-soon' | 'agent-flow-watch' | 'agent-flow-session' | 'agent-flow-empty' | 'claude-import' | 'claude-auto-remote'; /** The positional arguments ModularTreeDataProvider's section adapter passes. */ type AiAgentsItemArgs = [ @@ -82,6 +82,22 @@ export function createImportFromWebItem(): AiAgentsTreeItem { ); } +/** #456: whether every Claude Code session continues on claude.ai on its own; a click toggles it. */ +export function createAutoRemoteControlItem(enabled: boolean): AiAgentsTreeItem { + return new AiAgentsTreeItem( + enabled ? 'Sessions continue on claude.ai' : 'Continue sessions on claude.ai automatically', + vscode.TreeItemCollapsibleState.None, + 'claude-auto-remote', + { command: 'codeXR.claudeSessions.toggleAutoRemoteControl', title: 'Continue sessions on claude.ai automatically' }, + new vscode.ThemeIcon(enabled ? 'broadcast' : 'circle-slash'), + enabled + ? 'Every Claude Code session starts with Remote Control (Claude Code\'s own remoteControlAtStartup), so you can open it from claude.ai/code or the Claude mobile app. Click to turn it off.' + : 'Turn on Claude Code\'s Remote Control at startup, so every Claude Code session can be opened from claude.ai/code or the Claude mobile app without any action. Asks first.', + enabled ? 'On' : 'Off', + 'codeXR.aiAgents.claude.autoRemote', + ); +} + /** Shown when the workspace has no agent session yet. */ export function createNoAgentSessionsItem(): AiAgentsTreeItem { return new AiAgentsTreeItem( diff --git a/apps/vscode-extension/test/analysis/claudeSessionContinuity.test.cjs b/apps/vscode-extension/test/analysis/claudeSessionContinuity.test.cjs index ef3b67e8..4c75a222 100644 --- a/apps/vscode-extension/test/analysis/claudeSessionContinuity.test.cjs +++ b/apps/vscode-extension/test/analysis/claudeSessionContinuity.test.cjs @@ -54,3 +54,19 @@ test('CLI arguments are validated', () => { assert.throws(() => resumeArgs('x; y')); assert.equal(commandLine(resumeArgs(UUID, { remoteControl: true })), `claude --resume ${UUID} --remote-control`); }); + +test('#456: automatic Remote Control (session _meta and Claude Code settings.json)', () => { + const core = require(path.join(projectRoot, 'out', 'core', 'claude-sessions', 'claudeSessionContinuity.js')); + assert.deepEqual(core.remoteControlSessionMeta(true), { claudeCode: { options: { settings: { remoteControlAtStartup: true } } } }); + assert.equal(core.remoteControlSessionMeta(false), null); + assert.ok(core.isAutoRemoteControlMode('ask') && core.isAutoRemoteControlMode('always') && !core.isAutoRemoteControlMode('yes')); + const before = '{\n "model": "opus",\n "permissions": { "allow": ["Bash(ls)"] }\n}\n'; + const on = core.withRemoteControlAtStartup(before, true); + assert.deepEqual(JSON.parse(on), { model: 'opus', permissions: { allow: ['Bash(ls)'] }, remoteControlAtStartup: true }); + assert.ok(core.remoteControlAtStartupIn(on)); + assert.deepEqual(JSON.parse(core.withRemoteControlAtStartup(on, false)), { model: 'opus', permissions: { allow: ['Bash(ls)'] } }); + assert.deepEqual(JSON.parse(core.withRemoteControlAtStartup(null, true)), { remoteControlAtStartup: true }); + assert.throws(() => core.withRemoteControlAtStartup('{ nope', true), /not valid JSON/); + assert.throws(() => core.withRemoteControlAtStartup('[1]', true), /not a JSON object/); + assert.equal(core.remoteControlAtStartupIn('{ nope'), false); +}); diff --git a/apps/vscode-extension/test/baseline/featureBaseline.snapshot.json b/apps/vscode-extension/test/baseline/featureBaseline.snapshot.json index 5608d86a..d7077b0d 100644 --- a/apps/vscode-extension/test/baseline/featureBaseline.snapshot.json +++ b/apps/vscode-extension/test/baseline/featureBaseline.snapshot.json @@ -55,6 +55,7 @@ "codeXR.claudeSessions.continueInTerminal | Code-XR: Continue a Claude Code Chat in the Terminal", "codeXR.claudeSessions.continueOnClaudeAi | Code-XR: Continue a Claude Code Chat on claude.ai (Remote Control)", "codeXR.claudeSessions.importFromWeb | Code-XR: Import a Claude Code Chat from claude.ai", + "codeXR.claudeSessions.toggleAutoRemoteControl | Code-XR: Continue Claude Code Sessions on claude.ai Automatically (On/Off)", "codeXR.collaboration.joinRemote | Code-XR: Join Remote Session", "codeXR.collaboration.selectAvatar | Code-XR: Select Avatar Color", "codeXR.collaboration.selectIdentity | Code-XR: Select Collaboration Identity", @@ -297,6 +298,7 @@ "codeXR.claudeSessions.continueInTerminal", "codeXR.claudeSessions.continueOnClaudeAi", "codeXR.claudeSessions.importFromWeb", + "codeXR.claudeSessions.toggleAutoRemoteControl", "codeXR.collaboration.joinRemote", "codeXR.collaboration.selectAvatar", "codeXR.collaboration.selectIdentity", diff --git a/apps/vscode-extension/test/views/modularTreeSnapshot.golden.json b/apps/vscode-extension/test/views/modularTreeSnapshot.golden.json index a2e5324f..6255ebb9 100644 --- a/apps/vscode-extension/test/views/modularTreeSnapshot.golden.json +++ b/apps/vscode-extension/test/views/modularTreeSnapshot.golden.json @@ -61,6 +61,7 @@ {"item":{"$class":"ModularTreeItem","activeServer":"","activeServerItemType":"","aiAgentsItemType":"agent-flow-watch","analysisItemType":"","babiaExample":"","babiaItemType":"","collapsibleState":0,"command":{"command":"codeXR.agentFlow.watch","title":"Watch an agent in XR"},"contextValue":"codeXR.aiAgents.agentFlow.watch","description":"Agent Flow","iconPath":{"$class":"ThemeIcon","color":"","id":"pulse"},"itemType":"agent-flow-watch","label":"Watch an agent in XR","originalAnalysisItem":"","originalSettingsItem":"","sectionType":"aiAgents","serverItemType":"","tooltip":"Agent Flow: pick a Claude Code or Codex session of this workspace and watch it on the XR analysis table, live while it runs.","visualizationSettingsItemType":"","visualizeDataItem":"","visualizeDataItemType":""},"path":"AI AGENTS > Watch an agent in XR","sectionItem":{"$class":"AiAgentsTreeItem","aiAgentsItemType":"agent-flow-watch","collapsibleState":0,"command":{"command":"codeXR.agentFlow.watch","title":"Watch an agent in XR"},"contextValue":"codeXR.aiAgents.agentFlow.watch","description":"Agent Flow","iconPath":{"$class":"ThemeIcon","color":"","id":"pulse"},"label":"Watch an agent in XR","tooltip":"Agent Flow: pick a Claude Code or Codex session of this workspace and watch it on the XR analysis table, live while it runs."}}, {"item":{"$class":"ModularTreeItem","activeServer":"","activeServerItemType":"","aiAgentsItemType":"agent-flow-empty","analysisItemType":"","babiaExample":"","babiaItemType":"","collapsibleState":0,"command":"","contextValue":"codeXR.aiAgents.agentFlow.empty","description":"","iconPath":{"$class":"ThemeIcon","color":"","id":"info"},"itemType":"agent-flow-empty","label":"No agent sessions in this workspace yet","originalAnalysisItem":"","originalSettingsItem":"","sectionType":"aiAgents","serverItemType":"","tooltip":"Run Claude Code or Codex in this folder: its sessions appear here and can be watched in XR.","visualizationSettingsItemType":"","visualizeDataItem":"","visualizeDataItemType":""},"path":"AI AGENTS > No agent sessions in this workspace yet","sectionItem":{"$class":"AiAgentsTreeItem","aiAgentsItemType":"agent-flow-empty","collapsibleState":0,"command":"","contextValue":"codeXR.aiAgents.agentFlow.empty","description":"","iconPath":{"$class":"ThemeIcon","color":"","id":"info"},"label":"No agent sessions in this workspace yet","tooltip":"Run Claude Code or Codex in this folder: its sessions appear here and can be watched in XR."}}, {"item":{"$class":"ModularTreeItem","activeServer":"","activeServerItemType":"","aiAgentsItemType":"claude-import","analysisItemType":"","babiaExample":"","babiaItemType":"","collapsibleState":0,"command":{"command":"codeXR.claudeSessions.importFromWeb","title":"Import a chat from claude.ai"},"contextValue":"codeXR.aiAgents.claude.import","description":"Claude Code","iconPath":{"$class":"ThemeIcon","color":"","id":"cloud-download"},"itemType":"claude-import","label":"Import a chat from claude.ai","originalAnalysisItem":"","originalSettingsItem":"","sectionType":"aiAgents","serverItemType":"","tooltip":"Bring a Claude Code on the web session (claude.ai/code) into this folder with its branch, to continue it here and watch it in XR. Runs claude --teleport in a terminal after you confirm.","visualizationSettingsItemType":"","visualizeDataItem":"","visualizeDataItemType":""},"path":"AI AGENTS > Import a chat from claude.ai","sectionItem":{"$class":"AiAgentsTreeItem","aiAgentsItemType":"claude-import","collapsibleState":0,"command":{"command":"codeXR.claudeSessions.importFromWeb","title":"Import a chat from claude.ai"},"contextValue":"codeXR.aiAgents.claude.import","description":"Claude Code","iconPath":{"$class":"ThemeIcon","color":"","id":"cloud-download"},"label":"Import a chat from claude.ai","tooltip":"Bring a Claude Code on the web session (claude.ai/code) into this folder with its branch, to continue it here and watch it in XR. Runs claude --teleport in a terminal after you confirm."}}, +{"item":{"$class":"ModularTreeItem","activeServer":"","activeServerItemType":"","aiAgentsItemType":"claude-auto-remote","analysisItemType":"","babiaExample":"","babiaItemType":"","collapsibleState":0,"command":{"command":"codeXR.claudeSessions.toggleAutoRemoteControl","title":"Continue sessions on claude.ai automatically"},"contextValue":"codeXR.aiAgents.claude.autoRemote","description":"Off","iconPath":{"$class":"ThemeIcon","color":"","id":"circle-slash"},"itemType":"claude-auto-remote","label":"Continue sessions on claude.ai automatically","originalAnalysisItem":"","originalSettingsItem":"","sectionType":"aiAgents","serverItemType":"","tooltip":"Turn on Claude Code's Remote Control at startup, so every Claude Code session can be opened from claude.ai/code or the Claude mobile app without any action. Asks first.","visualizationSettingsItemType":"","visualizeDataItem":"","visualizeDataItemType":""},"path":"AI AGENTS > Continue sessions on claude.ai automatically","sectionItem":{"$class":"AiAgentsTreeItem","aiAgentsItemType":"claude-auto-remote","collapsibleState":0,"command":{"command":"codeXR.claudeSessions.toggleAutoRemoteControl","title":"Continue sessions on claude.ai automatically"},"contextValue":"codeXR.aiAgents.claude.autoRemote","description":"Off","iconPath":{"$class":"ThemeIcon","color":"","id":"circle-slash"},"label":"Continue sessions on claude.ai automatically","tooltip":"Turn on Claude Code's Remote Control at startup, so every Claude Code session can be opened from claude.ai/code or the Claude mobile app without any action. Asks first."}}, {"item":{"$class":"ModularTreeItem","activeServer":"","activeServerItemType":"","aiAgentsItemType":"coming-soon","analysisItemType":"","babiaExample":"","babiaItemType":"","collapsibleState":0,"command":"","contextValue":"codeXR.aiAgents.comingSoon","description":"","iconPath":{"$class":"ThemeIcon","color":"","id":"sparkle"},"itemType":"coming-soon","label":"Chat with AI agents: coming soon","originalAnalysisItem":"","originalSettingsItem":"","sectionType":"aiAgents","serverItemType":"","tooltip":"Chat with AI agents about your code and its Code-XR analyses, with your own provider keys. Coming soon.","visualizationSettingsItemType":"","visualizeDataItem":"","visualizeDataItemType":""},"path":"AI AGENTS > Chat with AI agents: coming soon","sectionItem":{"$class":"AiAgentsTreeItem","aiAgentsItemType":"coming-soon","collapsibleState":0,"command":"","contextValue":"codeXR.aiAgents.comingSoon","description":"","iconPath":{"$class":"ThemeIcon","color":"","id":"sparkle"},"label":"Chat with AI agents: coming soon","tooltip":"Chat with AI agents about your code and its Code-XR analyses, with your own provider keys. Coming soon."}}, {"item":{"$class":"ModularTreeItem","activeServer":"","activeServerItemType":"","analysisItemType":"","babiaExample":"","babiaItemType":"","collapsibleState":1,"command":"","contextValue":"pythonEnv.section","description":"Environment missing","iconPath":{"$class":"ThemeIcon","color":"","id":"warning"},"itemType":"section","label":"PYTHON ENV","originalAnalysisItem":"","originalSettingsItem":"","sectionType":"pythonEnv","serverItemType":"","tooltip":"Python environment has not been configured yet.","visualizationSettingsItemType":"","visualizeDataItem":"","visualizeDataItemType":""},"path":"PYTHON ENV","sectionItem":null}, {"item":{"$class":"ModularTreeItem","activeServer":"","activeServerItemType":"","analysisItemType":"","babiaExample":"","babiaItemType":"","collapsibleState":0,"command":"","contextValue":"pythonEnv.notExists","description":"Environment missing","iconPath":{"$class":"ThemeIcon","color":"","id":"warning"},"itemType":"warning","label":"No Python environment configured","originalAnalysisItem":"","originalSettingsItem":"","pythonEnvItemType":"warning","sectionType":"pythonEnv","serverItemType":"","tooltip":"Create the Code-XR virtual environment to enable code analysis.","visualizationSettingsItemType":"","visualizeDataItem":"","visualizeDataItemType":""},"path":"PYTHON ENV > No Python environment configured","sectionItem":{"$class":"PythonEnvModularTreeItem","collapsibleState":0,"command":"","contextValue":"pythonEnv.notExists","description":"Environment missing","iconPath":{"$class":"ThemeIcon","color":"","id":"warning"},"label":"No Python environment configured","pythonEnvItemType":"warning","tooltip":"Create the Code-XR virtual environment to enable code analysis."}}, diff --git a/docs/agents/claude-session-continuity.md b/docs/agents/claude-session-continuity.md index b661f443..aa9b6a0b 100644 --- a/docs/agents/claude-session-continuity.md +++ b/docs/agents/claude-session-continuity.md @@ -35,6 +35,15 @@ So no fallback is needed in the IDE. The fallback that remains for hosts that do The shared rules (prompts, reply parsing, id validation, CLI arguments, consent text) are in `apps/vscode-extension/src/core/claude-sessions/claudeSessionContinuity.ts`; each host only adds its UI. +## Automatic continuity (#456) + +Sharing chat by chat is still there, but the default way is that every Claude Code chat is on claude.ai without pressing anything. Claude Code already has the switch: `remoteControlAtStartup` in its user `settings.json` starts Remote Control with every session, and the ACP adapter honours it for a single session too when the client passes `_meta.claudeCode.options.settings.remoteControlAtStartup: true` on `session/new` or `session/load`. The adapter then sends a `Remote Control connected` notice with the claude.ai link, which `parseRemoteControlReply` already reads. + +- **VS Code extension**: AI Agents > **Continue sessions on claude.ai automatically** (On/Off). Turning it on asks once, then writes `remoteControlAtStartup: true` into Claude Code's own `settings.json` (`$CLAUDE_CONFIG_DIR` or `~/.claude`), keeping every other key; turning it off removes the key. The extension keeps no setting of its own: Claude Code's file is the single source of truth, so the switch covers the terminal, Claude Desktop and the IDE as well. +- **Code-XR IDE**: setting `agents.claude.remoteControl` (`ask`, `always`, `never`; default `ask`). On the first Claude Code chat with `ask`, a native dialog asks once and stores `always` or `never`. With `always`, every Claude Code chat (new or reopened) starts with Remote Control through the session `_meta`, and shows the **On claude.ai** badge with the link as soon as it connects. **Stop sharing** still ends it for one chat. + +The shared helpers (`remoteControlSessionMeta`, `withRemoteControlAtStartup`, `remoteControlAtStartupIn`, the consent text) live in the same core module. + ## Requirements and limits - A claude.ai sign-in (Pro, Max, Team or Enterprise). API keys, Bedrock, Vertex, Foundry and a custom `ANTHROPIC_BASE_URL` do not support Remote Control or teleport. Team and Enterprise need an owner to allow Remote Control; ZDR and HIPAA organizations cannot use it. `disableRemoteControl` turns it off. @@ -63,3 +72,8 @@ VS Code extension: 1. AI Agents > **Import a chat from claude.ai**: paste the link, confirm; the terminal runs `claude --teleport ...`. 2. Right-click a Claude Code session row > **Continue on claude.ai (Remote Control)**: confirm; the terminal runs `claude --resume --remote-control` and prints the claude.ai link. 3. Right-click > **Continue in the Terminal** resumes it. + +Automatic continuity (#456): + +1. VS Code extension: AI Agents > **Continue sessions on claude.ai automatically**: confirm. The row shows On and `~/.claude/settings.json` has `"remoteControlAtStartup": true`. Run `claude` in a terminal: it prints the claude.ai link without any flag. Press the row again: Off, and the key is gone. +2. IDE: with the setting on `ask`, open a new Claude Code chat: the dialog asks once. Answer Yes: the chat shows **On claude.ai** with the link after the first connection, without pressing Share. Open another chat: no question, also shared. Set the setting to `never`: new chats are not shared.