Skip to content

Commit 032b5a4

Browse files
authored
Merge pull request #502 from Mng-dev-ai/fix/skip-github-token-desktop-mode
Skip GitHub token injection in desktop mode
2 parents e72c1fc + 2141af8 commit 032b5a4

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

backend/app/services/agent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,8 @@ async def _build_acp_config(
396396
) -> AcpSessionConfig:
397397
env: dict[str, str] = {}
398398

399-
if user_settings.github_personal_access_token:
399+
# Skip in desktop mode — host git credentials handle auth natively
400+
if user_settings.github_personal_access_token and not settings.DESKTOP_MODE:
400401
env["GITHUB_TOKEN"] = user_settings.github_personal_access_token
401402
env["GIT_ASKPASS"] = SANDBOX_GIT_ASKPASS_PATH
402403
if settings.GIT_AUTHOR_NAME and settings.GIT_AUTHOR_EMAIL:

backend/app/services/sandbox.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ def build_env_vars(
4545
if custom_env_vars:
4646
for ev in custom_env_vars:
4747
envs[ev["key"]] = ev["value"]
48-
if github_token:
48+
# Desktop mode uses the host's native git credentials; only inject
49+
# token-based auth inside Docker containers.
50+
if github_token and not settings.DESKTOP_MODE:
4951
envs["GITHUB_TOKEN"] = github_token
5052
envs["GIT_ASKPASS"] = str(SANDBOX_GIT_ASKPASS_PATH)
5153
return envs

backend/app/services/workspace.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ async def create_workspace(self, user: User, data: WorkspaceCreate) -> Workspace
5858
user_workspace_dir = (self._base_dir / str(user.id)).resolve()
5959
user_workspace_dir.mkdir(parents=True, exist_ok=True)
6060

61+
# Desktop mode uses the host's native git credentials; token-based
62+
# auth is only needed inside Docker containers.
63+
github_token: str | None = (
64+
None
65+
if settings.DESKTOP_MODE
66+
else user_settings.github_personal_access_token
67+
)
68+
6169
if data.source_type == "git":
6270
if not data.git_url:
6371
raise WorkspaceException(
@@ -69,7 +77,7 @@ async def create_workspace(self, user: User, data: WorkspaceCreate) -> Workspace
6977
workspace_path = await self._clone_git_workspace(
7078
user_workspace_dir,
7179
normalized_url,
72-
github_token=user_settings.github_personal_access_token,
80+
github_token=github_token,
7381
)
7482
source_url = normalized_url
7583
elif data.source_type == "local":
@@ -97,7 +105,7 @@ async def create_workspace(self, user: User, data: WorkspaceCreate) -> Workspace
97105
resolved_provider = data.sandbox_provider or user_settings.sandbox_provider
98106
env_vars = SandboxService.build_env_vars(
99107
user_settings.custom_env_vars,
100-
user_settings.github_personal_access_token,
108+
github_token,
101109
)
102110
provider = SandboxProvider.create_provider(
103111
SandboxProviderType(resolved_provider),
@@ -111,7 +119,7 @@ async def create_workspace(self, user: User, data: WorkspaceCreate) -> Workspace
111119

112120
await sandbox_service.initialize_sandbox(
113121
sandbox_id=sandbox_id,
114-
has_github_token=bool(user_settings.github_personal_access_token),
122+
has_github_token=bool(github_token),
115123
auto_compact_disabled=user_settings.auto_compact_disabled,
116124
attribution_disabled=user_settings.attribution_disabled,
117125
)

0 commit comments

Comments
 (0)