Skip to content

fix(agent-config): make effect dependencies explicit - #688

Open
beruro wants to merge 2 commits into
developfrom
junyu/fix-agent-config-effect-deps
Open

fix(agent-config): make effect dependencies explicit#688
beruro wants to merge 2 commits into
developfrom
junyu/fix-agent-config-effect-deps

Conversation

@beruro

@beruro beruro commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Problem

Agent configuration hooks suppressed React dependency lint in four places. The shared loader accepted a caller-managed dependency array, SDE load/save callbacks hid workspacePath behind a ref, and OS credential checks reacted only to loaded while reading config. This obscured the actual scope lifecycle and allowed a slow credential response for an old model to overwrite the current model's status.

Solution

Make callback identity the configuration-scope contract: useAgentConfigBase reloads when its stable load callback changes, and OS/SDE callers declare their real dependencies. Derive OS credential synchronization from the current model and guard async results with a monotonically increasing generation so stale or unmounted requests cannot write state. Remove all four dependency suppressions in this group and add focused lifecycle tests for reload, save, and stale-response behavior.

Potential risks

The load contract now requires callers to memoize load; both production callers do so and are covered. UI behavior was not manually exercised in a live Tauri/WebView session, so backend-command integration remains an unverified path. Rollback is a normal commit revert; there are no schema, persistence-format, dependency, or public IPC changes.

Verification

  • ./node_modules/.bin/vitest run src/modules/MainApp/AgentOrgs/config/osAgent/useAgentConfigBase.test.ts src/modules/MainApp/AgentOrgs/config/osAgent/useOSAgentConfig.credentials.test.ts src/modules/MainApp/AgentOrgs/config/sdeAgent/useSdeAgentConfig.dependencies.test.ts — 3 files and 4 tests passed.
  • ./node_modules/.bin/eslint on all six changed files — passed.
  • ./node_modules/.bin/prettier --check on all six changed files — passed.
  • npm run typecheck — passed.
  • Repository pre-commit hook (lint-staged, scoped TypeScript check, commit stats) — passed.
  • git diff --check origin/develop...HEAD — passed.

Effects

  • The config-load Effect synchronizes with Tauri config reads and ignores stale or unmounted resolutions.
  • Save and credential timers retain symmetric unmount cleanup.
  • The credential-check Effect synchronizes the current model with the external key check; a generation guard rejects stale responses.

No rendered markup or styling changed, so screenshots are not useful for this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants