Skip to content

Commit d772206

Browse files
fix(server): probe %APPDATA% for devin cli credentials
The Devin CLI stores its user credentials under %APPDATA%\devin on Windows; only %LOCALAPPDATA% was checked, so a signed-in Windows user could get a spurious devin-browser prompt. APPDATA is now a candidate alongside LOCALAPPDATA, and the signed-out test fixtures redirect it. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent e507e00 commit d772206

3 files changed

Lines changed: 34 additions & 5 deletions

File tree

‎apps/server/src/provider/acp/DevinAcpSupport.test.ts‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,21 +297,45 @@ it.layer(NodeServices.layer)("DevinAcpSupport", (it) => {
297297
]);
298298
});
299299

300-
it("honours XDG_DATA_HOME and LOCALAPPDATA credential locations", () => {
300+
it("honours XDG_DATA_HOME, APPDATA and LOCALAPPDATA credential locations", () => {
301301
assert.deepEqual(
302302
devinCredentialsFilePaths({
303303
HOME: "/home/tester",
304304
XDG_DATA_HOME: "/data/xdg",
305+
APPDATA: "C:/Users/tester/AppData/Roaming",
305306
LOCALAPPDATA: "C:/Users/tester/AppData/Local",
306307
}),
307308
[
308309
"/data/xdg/devin/credentials.toml",
310+
"C:/Users/tester/AppData/Roaming/devin/credentials.toml",
309311
"C:/Users/tester/AppData/Local/devin/credentials.toml",
310312
"/home/tester/.local/share/devin/credentials.toml",
311313
],
312314
);
313315
});
314316

317+
it.effect("finds credentials stored under %APPDATA% on Windows", () =>
318+
Effect.gen(function* () {
319+
const fs = yield* FileSystem.FileSystem;
320+
const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3code-devin-appdata-" });
321+
const appData = NodePath.join(dir, "AppData", "Roaming");
322+
yield* fs.makeDirectory(NodePath.join(appData, "devin"), { recursive: true });
323+
yield* fs.writeFileString(
324+
NodePath.join(appData, "devin", "credentials.toml"),
325+
'token = "x"\n',
326+
);
327+
328+
// No HOME/USERPROFILE fallback dir should exist; APPDATA must carry it.
329+
const environment = {
330+
HOME: NodePath.join(dir, "missing-home"),
331+
USERPROFILE: NodePath.join(dir, "missing-profile"),
332+
APPDATA: appData,
333+
};
334+
assert.isTrue(yield* devinHasAmbientCredentials(environment));
335+
assert.isUndefined(yield* resolveDevinAuthMethodId({ environment, browserAuth: true }));
336+
}).pipe(Effect.scoped),
337+
);
338+
315339
it.effect("builds prompt blocks for text and attachments", () =>
316340
Effect.gen(function* () {
317341
const fs = yield* FileSystem.FileSystem;

‎apps/server/src/provider/acp/DevinAcpSupport.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ type DevinAcpRuntimeDevinSettings = Pick<DevinSettings, "binaryPath">;
4747
/**
4848
* Candidate locations for the `devin auth login` credentials file. The CLI's
4949
* documented path is `$XDG_DATA_HOME/devin/credentials.toml`, defaulting to
50-
* `~/.local/share`; on Windows it lives under `%LOCALAPPDATA%`. Checking every
51-
* candidate keeps the auth skip honest on non-default setups — a false
52-
* negative here sends `devin-browser` and opens a browser for a signed-in
53-
* user.
50+
* `~/.local/share`; on Windows its user config lives under `%APPDATA%` (with
51+
* `%LOCALAPPDATA%` checked as a fallback). Checking every candidate keeps the
52+
* auth skip honest on non-default setups — a false negative here sends
53+
* `devin-browser` and opens a browser for a signed-in user.
5454
*/
5555
export function devinCredentialsFilePaths(
5656
environment: NodeJS.ProcessEnv | undefined,
@@ -60,6 +60,10 @@ export function devinCredentialsFilePaths(
6060
if (xdgDataHome) {
6161
candidates.add([xdgDataHome, "devin", "credentials.toml"].join("/"));
6262
}
63+
const appData = environment?.APPDATA?.trim();
64+
if (appData) {
65+
candidates.add([appData, "devin", "credentials.toml"].join("/"));
66+
}
6367
const localAppData = environment?.LOCALAPPDATA?.trim();
6468
if (localAppData) {
6569
candidates.add([localAppData, "devin", "credentials.toml"].join("/"));

‎apps/server/src/textGeneration/DevinTextGeneration.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ it.layer(DevinTextGenerationTestLayer)("DevinTextGeneration", (it) => {
9191
WINDSURF_API_KEY: "",
9292
DEVIN_API_KEY: "",
9393
XDG_DATA_HOME: NodePath.join(fakeHome, "xdg"),
94+
APPDATA: NodePath.join(fakeHome, "appdata"),
9495
LOCALAPPDATA: NodePath.join(fakeHome, "localappdata"),
9596
},
9697
(textGeneration) =>

0 commit comments

Comments
 (0)