Repository navigation
Conversation
72b1b88 to
a75a5c2
Compare
305ba71 to
54d0151
Compare
| if (!isAbsolute(expected) || await realpath(app) !== await realpath(expected)) return 'needs_user_action' | ||
| const name = (await command('/usr/libexec/PlistBuddy', ['-c', 'Print :CFBundleExecutable', join(app, 'Contents', 'Info.plist')], env, signal)).trim() | ||
| if (!name || name.includes('/') || name === '.' || name === '..') return 'unknown' | ||
| return await realpath(join(app, 'Contents', 'MacOS', name)) === await realpath(executable) ? 'ready' : 'needs_user_action' |
There was a problem hiding this comment.
[P2] Bind readiness to the currently selected terminal
After qualification, starting Claude in another supported terminal changes where deep links open (documented behavior), but this check still accepts the same handler executable and the configuration fingerprint omits terminal selection. Re-observe and bind the selected terminal so a switch invalidates qualification instead of validating the captured environment for a different receiver.
| manifest, mcp, settings, Object.fromEntries(Object.entries(targetEnv).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)), | ||
| credentials, clients, roots, parsed, promptHooks, receiverHash, options.environmentEvidence])).digest('hex') | ||
| return { effectiveCwd: cwd, serverIdentity: parsed.serverIdentity, scopeId: parsed.scopeId, | ||
| configurationGeneration: generation, newSession: true, unsentPrefill: true, packageAccess: roots.length > 0 } |
There was a problem hiding this comment.
[P2] Validate effective Read permissions before claiming package access
On a new preflight with a user-level permissions.deny rule blocking the package root, this still reports package access and canReadPackage checks only host filesystem access, although Claude's Read rules prevent the receiver from reading the package. Bind access qualification to the effective permission configuration or reject unverified permissions before declaring readiness.
There was a problem hiding this comment.
[P2] The linked-worktree permission case still passes at 779b08cabbb49bacc53d6a4392bbf74707895889. The direct user-settings deny case is now rejected, but observeSettings() only checks cwd and git rev-parse --show-toplevel, which both identify the linked worktree root. Claude Code v2.1.211+ reads .claude/settings.local.json from the main checkout. In an adapter probe using a real linked Git worktree, adding {"permissions":{"deny":["Read"]}} there left receiver.environment() ready with the same configuration generation, and canReadPackage() still returned true. Resolve the effective local-settings location (or reject linked worktrees that cannot be qualified) so an inherited deny cannot pass package-access preflight. This reproduces the adapter behavior with fixture CLI/Server responses; it is not a macOS receiving-session acceptance result.
| export async function createClaudeCodeCliTarget(options: ClaudeCodeCliTargetOptions = {}): Promise<ClaudeCliAdapter> { | ||
| const { integrationOptions = {}, ...adapterOptions } = options | ||
| const inherited = integrationOptions.environment ?? process.env | ||
| const configDir = integrationOptions.configDir ?? inherited.CLAUDE_CONFIG_DIR ?? join(homedir(), '.claude') |
There was a problem hiding this comment.
[P2] Derive the default profile from the supplied HOME
When the supplied environment has a different HOME and no explicit configuration directory, this selects the host process's home; createClaudeIntegration then sets CLAUDE_CONFIG_DIR, causing doctor and setup to target a different profile from the receiving terminal. Derive the default directory from inherited.HOME and preserve the default profile's unset CLAUDE_CONFIG_DIR.
hidb4ai
left a comment
There was a problem hiding this comment.
Two receiver-readiness gaps remain on this head: a project-disabled PowerContext MCP server still passes preflight, and linked worktrees omit the main checkout's effective local permission settings (details in the existing permission thread).
| ? join(options.configDir, '.claude.json') : join(env.HOME ?? homedir(), '.claude.json') | ||
| const qualifiedTerminal = options.environmentEvidence.terminal | ||
| const observeTerminal = async () => { | ||
| const { deepLinkTerminal } = await readObject(terminalPreferenceFile) |
There was a problem hiding this comment.
[P2] Honor the receiver project's disabled MCP servers
This reads only deepLinkTerminal from the Claude global configuration. With projects[cwd].disabledMcpServers = ["plugin:powercontext:powercontext"] in that same file, receiver.environment() still returns a ready environment with the identical configurationGeneration; the direct Python MCP probe bypasses Claude's disabled-server state. Claude does not connect to plugin servers disabled through /mcp, so the receiving session cannot perform Continue/ACK despite passing preflight. Check the effective project MCP enablement and include it in the binding, or reject this configuration before preparation/launch.
hidb4ai
left a comment
There was a problem hiding this comment.
Both previous counterexamples now reject correctly: a disabled PowerContext MCP server and a Read denial inherited from the main checkout. One new non-Git workspace regression remains in project discovery; see the inline finding.
| '--git-dir', '--git-common-dir'], gitEnv, signal, cwd) | ||
| } catch (error) { | ||
| signal.throwIfAborted() | ||
| if ((error as { stderr?: string }).stderr?.trim() !== 'fatal: not a git repository (or any of the parent directories): .git') throw error |
There was a problem hiding this comment.
[P2] Recognize non-repositories at filesystem boundaries
Git does not always emit this exact message for a valid non-Git directory. When discovery reaches a filesystem boundary, it returns fatal: not a git repository (or any parent up to mount point /) followed by Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). This branch rethrows that normal non-repository result, so environment() returns undefined and handoff is rejected for an otherwise qualified directory. A same-fixture comparison returned ready on 779b08ca and unavailable on this head; the two supplied runtime tests that use non-Git workspaces also fail at their readiness assertions in this environment. Recognize this non-repository outcome while continuing to reject corrupt or indeterminate Git layouts. Reproduced with real Git 2.43.7 on Linux and fixture CLI/Server responses; no native macOS launch was exercised.
* feat(dsh): add the Codex Desktop handoff adapter * fix(dsh): ship Codex Desktop diagnostics in the default Host * fix(dsh): recover Codex probes and isolate target discovery
| if (!qualified || !buildReceiverPrompt) throw new HandoffError('integration_unavailable') | ||
| if (bundle.binding.targetId !== 'claude-desktop' | ||
| || bundle.binding.targetVersion !== target.version) throw new HandoffError('binding_mismatch') | ||
| return { draft: buildReceiverPrompt(bundle, locale) } |
There was a problem hiding this comment.
[P2] launchIntent 未校验 buildReceiverPrompt 的返回值
这里直接 return { draft: buildReceiverPrompt(bundle, locale) }。同 PR 的 CLI 适配器(claude-code-cli.ts 的 launchIntent)对同一契约做了 typeof draft !== 'string' || !draft.trim() 校验并抛 HandoffError('payload_invalid')。可复现:qualified Desktop adapter + 返回空串/非字符串的 buildReceiverPrompt → launchIntent 返回 { draft: '' },空 draft 会被当作合法预填内容交付,两个同批适配器行为不一致。
* feat(dsh): add the Claude Desktop Code handoff adapter * feat(dsh): connect the reply menu and one-click handoff * feat(dsh): enable Codex Desktop and Claude CLI handoff by default * fix(dsh): preserve the original objective and recover rejected input * fix(dsh): allow explicit retry of unacknowledged handoffs
| }).catch(() => { if (active) setError('integration_unavailable') }) | ||
| return () => { active = false } | ||
| }, [api, ports, sessionId, messageId, visited]) |
There was a problem hiding this comment.
[P2] Allow initial discovery to recover after a transient failure
If either the boundary request or target-list request fails once, this effect leaves replySource unset and the targets empty. Closing and reopening the menu never retries because visited stays true and none of these dependencies changes. I reproduced both cases with a one-time 503 followed by healthy responses: after reopening, each read had still run only once and every target remained disabled. Installation checks cannot recover either, because they also depend on the missing target list. Allow retrying these read-only discovery requests, on reopening or through an explicit retry control, without requiring a component remount/page reload or replaying preparation/launch.
| const result = await probeClaudeCodeCli(signal, path) | ||
| if (result.state !== 'present') return result | ||
| if (!integration.configurationKey) return { state: 'unknown' } | ||
| if (qualified && result.version !== qualification!.targetVersion) return { state: 'unsupported' } |
There was a problem hiding this comment.
[P3] Preserve installed-version information in diagnostics
The default registry now supplies a qualification for 2.1.323. With the CLI probe reporting an installed 2.1.324, TargetCatalog.diagnose() returns only { state: "unsupported" }, which the new Installation checks UI renders as "Installation check is not supported on this platform" and hides the installed version. The qualified Codex detection branch has the same version-gate behavior. Keep installation detection separate from launch eligibility, or distinguish an unqualified version from an unsupported platform, while retaining the exact-version restriction on handoff.
| if (event.type === 'user/message' && event.data?.source?.kind === 'user') { | ||
| const human = text(event.data, 8000) | ||
| // Scanning backwards, even an omitted earlier request supersedes a later instruction. | ||
| objective = human ?? null |
There was a problem hiding this comment.
[P2] Preserve the active objective after a task change
When a user explicitly finishes task A and switches to task B in the same session, this backward scan overwrites B's objective with the earliest request for A, so both preparation paths produce a handoff with a superseded canonical objective. Resolve the active objective from the bounded evidence or require user confirmation when it cannot be established.
There was a problem hiding this comment.
Confirmed at cc53dc1738e45956988afb76702d00dec8e37cc7 through the real Server. I supplied a bounded DSH event fixture containing “Task A: add a CSV export button”, its completion, then “Task A is finished. Now switch to task B: fix the login timeout” and selected B's completed reply. Automatic preparation returned prepared, but both the preview and exported package retained A as objective. After reopening the local delivery, continue_handoff also resolved that same stale objective. B survives only as an observation. This verifies the durable no-model path; the generation path also passes materials.objective as its canonical objective.
hidb4ai
left a comment
There was a problem hiding this comment.
Re-reviewed cc53dc17. The transient discovery and installed-version diagnostic issues are fixed. The active-objective issue remains reproducible through Server persistence (evidence added to its existing thread), and a separate credential-filtering issue is detailed below.
| events.push({ sessionId: source.sessionId, seq: result.seq, kind: 'check', command, status: 'unknown', | ||
| ...(output ? { details: output } : {}) }) | ||
| omissions.add(label('Shell check outcomes require review; model-visible output alone does not prove an exit status.', 'Shell 检查结果需核对;模型可见的输出不能证明退出状态。')) | ||
| } else if (output) observe(result, label(`Shell command: ${command}\nResult (unverified): ${output}`, `Shell 命令:${command}\n结果(未经核实):${output}`)) |
There was a problem hiding this comment.
[P1] Filter credential arguments from non-check shell observations
This branch embeds the raw shell command in an observation, bypassing the CREDENTIAL_OPTION filter that collectMaterials() applies only to kind: 'check'. With a synthetic event for python3 publish.py --api_key review_synthetic_credential_12345 and ordinary output, automatic preparation against the real Server persisted that argument in the Handoff state and exported package; after reopening the delivery, continue_handoff returned it unchanged. The equivalent pytest --api_key ... event is correctly omitted. Filter credential-bearing arguments before recording shell evidence, including non-check commands, so a one-click handoff does not copy source credentials into persisted or receiving-agent context.
| }) | ||
| return [createHostCodexDesktopAdapter({ | ||
| appPath: options.codexAppPath, codexHome, deliveryStorage: options.deliveryStorage, | ||
| setup, buildReceiverPrompt, qualification: CODEX, |
There was a problem hiding this comment.
[P2] Serialize setup writes to shared client settings
Concurrent Codex and Claude installation decisions use different installer keys, but both setup commands rewrite the shared clients.json through setup_transport_updates() and publish(), allowing the last writer to discard the other host's saved connection. Serialize this shared configuration write across both adapters or make the read-modify-write atomic.
| } | ||
| if (plugin.status !== 'failed' || typeof plugin.detail !== 'string') return { state: 'unknown' } | ||
| if (plugin.detail === 'PowerContext plugin is not installed') return { state: 'missing', repairable: true } | ||
| if (plugin.detail.includes('enabled=False')) return { state: 'disabled', repairable: true } |
There was a problem hiding this comment.
[P2] Enable disabled plugins during the consented repair
For an installed plugin disabled in user settings, this branch offers automatic repair, but install() invokes powercontext setup claude-code, whose existing-plugin path updates the plugin while preserving its disabled setting, leaving handoff blocked. Enable the plugin under the same consent and profile, or require manual action using the documented enable command.
Which issue or RFC does this PR close?
Refs #2514 and RFC #2528. This PR builds on #2602, which includes the receipt and initial Codex Desktop work from #2651 and #2652. It includes the Claude Desktop adapter from #2654 and the reply handoff menu from #2655.
Rationale for this change
An installed agent does not establish that a new session can read the package and acknowledge the exact handoff. The DSH menu needs to show installation status independently of launch eligibility and recover when a read temporarily fails.
What changes are included in this PR?
How was this change tested?
make check, the DSH package build, andmake docs-testpassed.d093opened Claude Code CLI, which read the requested proof, called Continue and ACK, and produced the exact verified receipt. The credential compatibility tests use an isolated fixture Server.AI usage statement
OpenAI Codex assisted with implementation, tests, local validation, and preparing this PR.