Skip to content

fix: avoid provider config probe races - #683

Draft
Dante-dan wants to merge 1 commit into
LodyAI:mainfrom
Dante-dan:fix/652-provider-probe-race
Draft

Dante-dan wants to merge 1 commit into
LodyAI:mainfrom
Dante-dan:fix/652-provider-probe-race

Conversation

@Dante-dan

Copy link
Copy Markdown

Related issue

Closes #652

Problem / pressure

Provider config validation could race with the daemon's replicated config view. A freshly saved config could therefore be reported as missing, while the configuration dialog also allowed probes with an empty required name and surfaced the daemon error instead of the actual input problem.

Summary

  • Re-sync provider configs once and reread before returning provider_config_not_found.
  • Persist valid dialog drafts before launching the machine-backed probe.
  • Treat the required provider name as inline validation and disable probing until it is present.
  • Add focused CLI and component regressions plus bilingual implementation notes.

Visual explanation

sequenceDiagram
    participant UI as Config dialog
    participant CLI as CLI daemon
    participant Store as Replicated config
    UI->>Store: persist valid draft
    UI->>CLI: probe provider
    CLI->>Store: read provider
    alt first read misses
        CLI->>Store: sync + reread once
    end
    Store-->>CLI: provider config
    CLI-->>UI: probe result
Loading

Before / after

Before After
A recently persisted provider could transiently fail the first daemon lookup. The CLI performs one bounded sync and reread before reporting the config missing.
An empty required name could reach the machine probe and produce a misleading not-found result. The dialog reports the required-name error inline and keeps the probe disabled.

Test plan

  • pnpm --dir packages/components test -- --run tests/agent-config-dialog.test.tsx — 30 tests passed.
  • pnpm --dir apps/cli test -- --run tests/session-execution-service.test.ts — 110 tests passed.
  • pnpm --dir packages/components run typecheck — passed.
  • pnpm --dir apps/cli run typecheck — passed.
  • pnpm exec prettier --check <changed files> — passed.
  • pnpm run docs check — passed with existing repository warnings only.
  • pnpm run lint:fast — 0 errors (473 existing warnings).
  • git diff --check upstream/main...HEAD — passed.

Context handoff

Instructions for reviewing agents

  • Review focus: Check the bounded CLI reread in session-execution-service.ts and the dialog's persist-before-probe/name-validation flow.
  • Decisions to challenge: Verify that one explicit config sync is the right bounded recovery and that an empty name should block both create and edit probes.
  • Plausible failures / evidence gaps: The race is covered with deterministic repository and UI tests rather than a live multi-process timing reproduction.

Authoring context

  • User goal / directives: Save configuration before probing, avoid a false missing-config report, and add tests for this straightforward bug.
  • Constraints / non-goals: Keep the change focused on provider config visibility and required-name validation; do not redesign config replication or machine lifecycle.
  • Risk-bearing decisions: Recovery performs exactly one sync and reread so a true missing config still returns the established typed error without an unbounded retry.
  • Destructive or irreversible behavior: None; the only write is the existing dialog persistence path, and failed probes do not delete or migrate data.
  • Deliberately not done or tested: No live desktop/daemon timing test was run; deterministic CLI and component regressions exercise the relevant ordering and failure paths.
  • Unknowns / confidence: Confidence is high for the covered race and validation paths; unusual external storage delays beyond one completed sync remain governed by the existing error.

Original user prompt

Show original prompt
#652:应该保存配置后再探测,避免误报配置不存在。这是一个简单的问题,处理完做好测试。先看看整体的方案,如果有问题请问我

Model: gpt-5.6-sol
Signed-off-by: Dante <duanjl.china@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] New provider dialog shows misleading 'Provider config not found' (probe race + silent Name requirement)

1 participant