← Back to Pull requests

fix(desktop): settle the Skill draft's preconditions before it sends #5565

Closed
unknown closed this pull request without merging on Sep 21, 2026 08:20 UTC
View on GitHub
unknown unknown commented on Sep 21, 2026 08:03 UTC
Author

Summary

skill-draft-lifecycle.spec.ts fails intermittently on most branches right now, including main. The assertion that times out is always the same one:

Error: expect(locator).toBeVisible() failed
Locator: getByText('Skill 调用失败,消息未发送')

That banner only renders when a send is rejected because the invoked Skill cannot resolve (skill-invocation-feedback.ts shows it when skillInvocation.failed is non-empty and loaded is empty). So the flake is not the banner — it is that the send sometimes succeeds instead of being rejected, because the rejection depends on a state the test has not settled yet.

Two independent races sit between window.maka.skills.setEnabled('workspace-only', false) and the Enter that follows it:

1. The composer's / source is not refetched. The toggle goes through the raw bridge, not the Skills page, so it never runs the controller's refreshSkills() — the only path that bumps skillCatalogRevision and causes composer-mentions-provider to re-list invocables. Until Runtime's projection drops the Skill it is still invocable, the send resolves it, and the send succeeds.
2. Picking the Skill leaves the / menu open. composer.tsx's onInputKeyDown swallows Enter while the editable reports aria-expanded === 'true', treating it as menu acceptance rather than a send. If Enter lands in that window the draft is never submitted at all and no banner can appear.

The fix waits for both preconditions before pressing Enter: the editable back to aria-expanded="false", and the Skill gone from the invocable projection. The second uses a new waitForSkillNotInvocable helper sitting beside the existing waitForInvocableSkills, which already polls the same authoritative projection for the opposite transition.

Why this is a test fix, not a product fix

The journeys here are about revision drafts surviving a rejected send. The product does reject a disabled Skill correctly once its projection has settled — the test simply asserted the outcome without waiting for the input to that outcome. retries: 0 is deliberate in this suite ("flakes should fail loudly"), so the answer is to remove the race rather than mask it.

Verification

  • @maka/desktop builds; the two changed files typecheck and pass biome.

  • The aria-expanded contract is real, not assumed: useTriggerMenu emits aria-expanded: false on the editable whenever triggers are configured and no menu is open.

  • The catalog wait polls the same window.maka.skills.listInvocable projection the fixture's existing readiness wait uses, so it converges on the same source of truth the composer reads.
  • What I could not do: reproduce the failure locally. Electron will not launch in my environment (it fails with The requested module 'electron' does not provide an export named 'app', and there is no display — CI uses xvfb-run), so the evidence above is a code-path reading plus the failure distribution across branches, not a local repro or a local green run.

    Evidence it is not this branch's change

    The same spec fails the same way on branches unrelated to the provider removal, and on main itself:

    | branch | failing spec |
    | --- | --- |
    | main (b48ae6c21) | skill-draft-lifecycle.ts:77/86/93 |
    | feat/composer-steer-shortcut | skill-draft-lifecycle.ts:77/86/110/120 |
    | perf/reasoning-shimmer-steps | skill-draft-lifecycle.ts:77/86/93 |
    | feat/pricing-overrides-only | workhub-layout.ts:26/99 |

    I did not run the suite. CI on this PR is the first real check of the fix, and it is the honest signal for whether both races are closed — if the banner still fails to appear, one of the two preconditions is not the whole story and I would want the next number rather than another retry.

    AI use

  • No generative tool made a substantive contribution

  • Generative tooling made a substantive contribution
  • Tool(s) and scope: Maka (DeepSeek V4.1 Flash) — traced the failing assertion to its renderer, identified the two unsynchronised preconditions, and wrote the waits.

    Checklist

  • Tests cover the change and fail without it

  • Lint, format, typecheck and the affected suites pass locally
  • Does this PR entail a change in behavior?

  • Yes — described under Summary above

  • No
  • Diff: 537 lines (+402 / -135) across 6 files Reviewer: M4n5ter Review duration: 16m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 537 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.376
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5565"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.9% (MEDIUM) · Higher = larger blast radius
    47.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.9% · Safe to merge
    18.9%
    Repository