Skip to content

Commit 8abc88d

Browse files
committed
fix(shell): address coderabbit oauth review
1 parent bc1da97 commit 8abc88d

5 files changed

Lines changed: 25 additions & 32 deletions

File tree

‎.github/actions/setup/action.yml‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,25 @@ runs:
5858
- name: Install dependencies
5959
shell: bash
6060
run: |
61+
run_bun_install() {
62+
local timeout_seconds=$((20 * 60))
63+
bun install --frozen-lockfile &
64+
local install_pid="$!"
65+
(
66+
sleep "$timeout_seconds"
67+
echo "bun install exceeded 20 minutes; terminating" >&2
68+
kill "$install_pid" 2>/dev/null || true
69+
) &
70+
local timeout_pid="$!"
71+
local status=0
72+
wait "$install_pid" || status="$?"
73+
kill "$timeout_pid" 2>/dev/null || true
74+
wait "$timeout_pid" 2>/dev/null || true
75+
return "$status"
76+
}
77+
6178
for attempt in 1 2 3; do
62-
if bun install --frozen-lockfile; then
79+
if run_bun_install; then
6380
exit 0
6481
fi
6582
if [[ "$attempt" == "3" ]]; then

‎packages/lib/src/shell/claude-oauth-env.ts‎

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎packages/lib/src/usecases/auth-claude-oauth.ts‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,21 +203,15 @@ export const runClaudeOauthLoginWithPrompt = (
203203
cwd: string,
204204
accountPath: string,
205205
options: {
206-
readonly envToken: string | null
207206
readonly image: string
208207
readonly containerPath: string
209208
}
210-
): Effect.Effect<string, AuthError | CommandFailedError | PlatformError, CommandExecutor.CommandExecutor> => {
211-
if (options.envToken !== null) {
212-
return Effect.succeed(options.envToken)
213-
}
214-
215-
return Effect.scoped(
209+
): Effect.Effect<string, AuthError | CommandFailedError | PlatformError, CommandExecutor.CommandExecutor> =>
210+
Effect.scoped(
216211
Effect.gen(function*(_) {
217212
const executor = yield* _(CommandExecutor.CommandExecutor)
218213
const hostPath = yield* _(resolveDockerVolumeHostPath(cwd, accountPath))
219214
const result = yield* _(runClaudeDockerOauthEffect(cwd, accountPath, hostPath, options, executor))
220215
return yield* _(resolveClaudeDockerOauthTokenResult(result))
221216
})
222217
)
223-
}

‎packages/lib/src/usecases/auth-claude.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { Effect } from "effect"
1212

1313
import type { AuthClaudeLoginCommand, AuthClaudeLogoutCommand, AuthClaudeStatusCommand } from "../core/domain.js"
1414
import { defaultTemplateConfig } from "../core/domain.js"
15-
import { readDockerGitClaudeOauthTokenFromProcessEnv } from "../shell/claude-oauth-env.js"
1615
import { runDockerAuth, runDockerAuthExitCode } from "../shell/docker-auth.js"
1716
import type { AuthError } from "../shell/errors.js"
1817
import { CommandFailedError } from "../shell/errors.js"
@@ -284,7 +283,6 @@ export const authClaudeLogin = (
284283
runClaudeLoginFlow({
285284
accountLabel,
286285
captureToken: runClaudeOauthLoginWithPrompt(cwd, accountPath, {
287-
envToken: readDockerGitClaudeOauthTokenFromProcessEnv(),
288286
image: claudeImageName,
289287
containerPath: claudeContainerHomeDir
290288
}),

‎packages/lib/tests/usecases/auth-claude-login.test.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,14 @@ describe("authClaudeLogin", () => {
227227
)
228228
).pipe(Effect.provide(NodeContext.layer)))
229229

230-
it.effect("uses a decoded docker-git OAuth env token without running setup-token", () =>
230+
it.effect("ignores docker-git OAuth env token and captures setup-token output", () =>
231231
withTempDir((root) =>
232232
withPatchedEnv(
233233
{
234234
HOME: root,
235235
DOCKER_GIT_STATE_AUTO_SYNC: "0",
236236
DOCKER_GIT_PROJECTS_ROOT: undefined,
237-
[dockerGitClaudeOauthTokenEnvKey]: ` ${oauthToken} `
237+
[dockerGitClaudeOauthTokenEnvKey]: "ENV_CLAUDE_OAUTH_TOKEN_SHOULD_NOT_WIN"
238238
},
239239
Effect.gen(function*(_) {
240240
const fs = yield* _(FileSystem.FileSystem)
@@ -248,13 +248,14 @@ describe("authClaudeLogin", () => {
248248
label: null,
249249
claudeAuthPath
250250
}).pipe(
251-
Effect.provideService(CommandExecutor.CommandExecutor, makeFakeExecutor(null, 0, invocations))
251+
Effect.provideService(CommandExecutor.CommandExecutor, makeFakeExecutor(oauthToken, 0, invocations))
252252
)
253253
)
254254

255255
const tokenText = yield* _(fs.readFileString(path.join(claudeAuthPath, "default", ".oauth-token")))
256256
expect(tokenText.trim()).toBe(oauthToken)
257-
expect(invocations.some((invocation) => isSetupToken(invocation.args))).toBe(false)
257+
expect(tokenText.trim()).not.toBe("ENV_CLAUDE_OAUTH_TOKEN_SHOULD_NOT_WIN")
258+
expect(invocations.some((invocation) => isSetupToken(invocation.args))).toBe(true)
258259
expect(invocations.some((invocation) => isPingProbe(invocation.args))).toBe(true)
259260
})
260261
)

0 commit comments

Comments
 (0)