-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: improve GLM presets, ideation auth, and Insights env #648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AndyMik90
merged 9 commits into
AndyMik90:develop
from
StillKnotKnown:local/glm-insights-debug
Jan 5, 2026
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
16d7818
fix: improve api profile presets and ideation auth
StillKnotKnown a9ac6e2
github: pass api profile env to python runners
StillKnotKnown 38db0e7
test: clean up github runner env temp dirs
StillKnotKnown 249a845
Merge branch 'develop' into local/glm-insights-debug
StillKnotKnown 3e098c6
refactor: centralize Claude.md env helper
StillKnotKnown f86c8f7
Merge branch 'develop' into local/glm-insights-debug
AndyMik90 b551023
fix: repair insights env return
StillKnotKnown 837903a
test: fix typecheck and vitest sentry mocks
StillKnotKnown c8c50a5
refactor: share sentry mocks and types
StillKnotKnown File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| export type ErrorEvent = Record<string, unknown>; | ||
|
|
||
| export type Scope = { | ||
| setContext: (key: string, value: Record<string, unknown>) => void; | ||
| }; | ||
|
|
||
| export type InitOptions = { | ||
| beforeSend?: (event: ErrorEvent) => ErrorEvent | null; | ||
| tracesSampleRate?: number; | ||
| profilesSampleRate?: number; | ||
| dsn?: string; | ||
| environment?: string; | ||
| release?: string; | ||
| debug?: boolean; | ||
| enabled?: boolean; | ||
| }; | ||
|
|
||
| export function init(_options: InitOptions): void {} | ||
|
|
||
| export function captureException(_error: Error): void {} | ||
|
|
||
| export function withScope(callback: (scope: Scope) => void): void { | ||
| callback({ | ||
| setContext: () => {} | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| export type ErrorEvent = Record<string, unknown>; | ||
|
|
||
| export type Scope = { | ||
| setContext: (key: string, value: Record<string, unknown>) => void; | ||
| }; | ||
|
|
||
| export type InitOptions = { | ||
| beforeSend?: (event: ErrorEvent) => ErrorEvent | null; | ||
| tracesSampleRate?: number; | ||
| profilesSampleRate?: number; | ||
| dsn?: string; | ||
| environment?: string; | ||
| release?: string; | ||
| debug?: boolean; | ||
| enabled?: boolean; | ||
| }; | ||
|
|
||
| export function init(_options: InitOptions): void {} | ||
|
|
||
| export function captureException(_error: Error): void {} | ||
|
|
||
| export function withScope(callback: (scope: Scope) => void): void { | ||
| callback({ | ||
| setContext: () => {} | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /** | ||
| * @vitest-environment node | ||
| */ | ||
| import path from 'path'; | ||
| import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; | ||
| import { InsightsConfig } from '../insights/config'; | ||
|
|
||
| vi.mock('electron', () => ({ | ||
| app: { | ||
| getAppPath: () => '/app', | ||
| getPath: () => '/tmp', | ||
| isPackaged: false | ||
| } | ||
| })); | ||
|
|
||
| vi.mock('../rate-limit-detector', () => ({ | ||
| getProfileEnv: () => ({ CLAUDE_CODE_OAUTH_TOKEN: 'oauth-token' }) | ||
| })); | ||
|
|
||
| const mockGetApiProfileEnv = vi.fn(); | ||
| vi.mock('../services/profile', () => ({ | ||
| getAPIProfileEnv: (...args: unknown[]) => mockGetApiProfileEnv(...args) | ||
| })); | ||
|
|
||
| const mockGetPythonEnv = vi.fn(); | ||
| vi.mock('../python-env-manager', () => ({ | ||
| pythonEnvManager: { | ||
| getPythonEnv: () => mockGetPythonEnv() | ||
| } | ||
| })); | ||
|
|
||
| describe('InsightsConfig', () => { | ||
| const originalEnv = { ...process.env }; | ||
|
|
||
| beforeEach(() => { | ||
| process.env = { ...originalEnv, TEST_ENV: 'ok' }; | ||
| mockGetApiProfileEnv.mockResolvedValue({ | ||
| ANTHROPIC_BASE_URL: 'https://api.z.ai', | ||
| ANTHROPIC_AUTH_TOKEN: 'key' | ||
| }); | ||
| mockGetPythonEnv.mockReturnValue({ PYTHONPATH: '/site-packages' }); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| process.env = { ...originalEnv }; | ||
| vi.clearAllMocks(); | ||
| vi.restoreAllMocks(); | ||
| }); | ||
|
|
||
| it('should build process env with python and profile settings', async () => { | ||
| const config = new InsightsConfig(); | ||
| vi.spyOn(config, 'loadAutoBuildEnv').mockReturnValue({ CUSTOM_ENV: '1' }); | ||
| vi.spyOn(config, 'getAutoBuildSourcePath').mockReturnValue('/backend'); | ||
|
|
||
| const env = await config.getProcessEnv(); | ||
|
|
||
| expect(env.TEST_ENV).toBe('ok'); | ||
| expect(env.CUSTOM_ENV).toBe('1'); | ||
| expect(env.CLAUDE_CODE_OAUTH_TOKEN).toBe('oauth-token'); | ||
| expect(env.ANTHROPIC_BASE_URL).toBe('https://api.z.ai'); | ||
| expect(env.ANTHROPIC_AUTH_TOKEN).toBe('key'); | ||
| expect(env.PYTHONPATH).toBe(['/site-packages', '/backend'].join(path.delimiter)); | ||
| }); | ||
|
|
||
| it('should clear ANTHROPIC env vars in OAuth mode when no API profile is set', async () => { | ||
| const config = new InsightsConfig(); | ||
| mockGetApiProfileEnv.mockResolvedValue({}); | ||
| process.env = { | ||
| ...originalEnv, | ||
| ANTHROPIC_AUTH_TOKEN: 'stale-token', | ||
| ANTHROPIC_BASE_URL: 'https://stale.example' | ||
| }; | ||
|
|
||
| const env = await config.getProcessEnv(); | ||
|
|
||
| expect(env.ANTHROPIC_AUTH_TOKEN).toBe(''); | ||
| expect(env.ANTHROPIC_BASE_URL).toBe(''); | ||
| }); | ||
|
|
||
| it('should set PYTHONPATH only to auto-build path when python env has none', async () => { | ||
| const config = new InsightsConfig(); | ||
| mockGetPythonEnv.mockReturnValue({}); | ||
| vi.spyOn(config, 'getAutoBuildSourcePath').mockReturnValue('/backend'); | ||
|
|
||
| const env = await config.getProcessEnv(); | ||
|
|
||
| expect(env.PYTHONPATH).toBe('/backend'); | ||
| }); | ||
|
|
||
| it('should keep PYTHONPATH from python env when auto-build path is missing', async () => { | ||
| const config = new InsightsConfig(); | ||
| mockGetPythonEnv.mockReturnValue({ PYTHONPATH: '/site-packages' }); | ||
| vi.spyOn(config, 'getAutoBuildSourcePath').mockReturnValue(null); | ||
|
|
||
| const env = await config.getProcessEnv(); | ||
|
|
||
| expect(env.PYTHONPATH).toBe('/site-packages'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.