Skip to content

Commit 7c699e3

Browse files
committed
fix(platform-android): keep the missing-tool hint when no adb pattern matches
Hint precedence is now the adb classification, then the xcrun missing-tool hint, then the caller's fallback, so the hint agrees with the reported reason. The adoption test asserts the exact unconfirmed-cleanup reason. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
1 parent b79d5e5 commit 7c699e3

3 files changed

Lines changed: 19 additions & 9 deletions

File tree

‎packages/capture-kit/src/durable-capture/adoption.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ test('a failed terminal transition preserves the primary error and reports it un
113113

114114
expect(context.reportUndurableCleanup).toHaveBeenCalledWith(context.device, {
115115
confirmed: false,
116-
reason: expect.stringMatching(/./),
116+
reason: 'Test capture cleanup could not be confirmed',
117117
});
118118
});
119119

‎packages/platform-android/src/adb-failure.test.ts‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,19 +142,28 @@ test('ADB discovery classifies transport failures from stderr without trusting s
142142
assert.match(String(versionMismatch.details?.hint), /Multiple adb installs conflict/);
143143
});
144144

145-
test('ADB discovery keeps its own hint when stderr also carries an xcrun-style line', () => {
146-
const error = androidDiscoveryCommandError(
145+
test('ADB discovery hint precedence: adb classification, then missing tool, then fallback', () => {
146+
const xcrunLine = 'xcrun: error: unable to find utility "adb", not a developer tool or in PATH';
147+
const missingTool = androidDiscoveryCommandError(
148+
'adb devices failed',
149+
{ stdout: '', stderr: xcrunLine, exitCode: 1 },
150+
'fallback',
151+
);
152+
const classified = androidDiscoveryCommandError(
147153
'adb devices failed',
148154
{
149155
stdout: '',
150-
stderr: 'xcrun: error: unable to find utility "adb", not a developer tool or in PATH',
156+
stderr: `${xcrunLine}\nadb server version (40) doesn't match this client (41); killing...`,
151157
exitCode: 1,
152158
},
153159
'fallback',
154160
);
155161

156-
assert.equal(error.details?.hint, 'fallback');
157-
assert.equal(error.details?.processExitError, true);
162+
assert.equal(missingTool.details?.reason, 'xcrun-tool-not-found');
163+
assert.match(String(missingTool.details?.hint), /^xcrun could not find adb/);
164+
assert.equal(missingTool.details?.processExitError, true);
165+
assert.equal(classified.details?.adbFailure, 'server_version_mismatch');
166+
assert.match(String(classified.details?.hint), /Multiple adb installs conflict/);
158167
});
159168

160169
test('attachAdbFailureHint classifies timeouts first and never overwrites a site hint', () => {

‎packages/platform-android/src/adb-failure.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,11 @@ export function androidDiscoveryCommandError(
292292
fallbackHint: string,
293293
): AppError {
294294
const failure = classifyAndroidAdbFailure(result.stderr, result.stdout);
295-
// The adb classification is spread last: an xcrun-style stderr line must not replace it.
295+
const details = execFailureDetails(result);
296+
// Precedence: the adb classification, then a missing-tool hint, then the caller's fallback.
296297
return new AppError('COMMAND_FAILED', message, {
297-
...execFailureDetails(result),
298-
hint: failure?.hint ?? fallbackHint,
298+
...details,
299+
hint: failure?.hint ?? (typeof details.hint === 'string' ? details.hint : fallbackHint),
299300
...(failure ? { adbFailure: failure.reason } : {}),
300301
...(failure?.retriable === undefined ? {} : { retriable: failure.retriable }),
301302
});

0 commit comments

Comments
 (0)