-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
TL;DR
Remove legacy client-side patch orchestration and "self-heal" helpers. Move retry logic server-side for single source of truth.
Context
During PER-19 extraction work, we identified that use-patch-application.ts contains retryWithValidationErrors logic (lines 114-265) that duplicates server-side capabilities. The server's assistant-service.ts already validates patches, but the client still carries legacy retry orchestration.
Current state:
- Server validates patches in
assistant-service.ts - Client has
retryWithValidationErrorsin extracteduse-patch-application.ts - Invalid responses surface as UI text but don't trigger server-side repair
- Dead code and duplicated logic between client and server
Goals
- Single source of truth for patch generation/validation/retry on server
- Client reduced to: display + apply + stale/expired handling
- No loss of current behaviors (retry on invalid, stale detection, apply-time validation)
Plan
- Server: add auto-repair loop in
assistant-service.ts- When
buildPatchTransactionFromResponsereturns invalid, re-prompt with repair prompt - Cap retries (1 pass), surface second invalid as-is with reasons
- When
- Server: standardize error payloads
- Structured errors (type/message/fix) compatible with existing UI
- Client: trim legacy orchestration
- Remove
retryWithValidationErrorsfromuse-patch-application.ts - Keep UI messaging for invalid/noop/missing-target
- Retain apply-time stale handling only
- Remove
- Contracts & types
- Update shared types if repair path adds fields (e.g.,
attempt: "initial" | "repair")
- Update shared types if repair path adds fields (e.g.,
- Tests
- Unit tests for server repair flow
- Integration tests for client handling of invalid payloads
Acceptance Criteria
- Invalid responses trigger exactly one server-side repair attempt
- Client no longer issues generation-time retries
- Stale/expired handling still works
- No unused self-heal helpers in
apps/webpatch flows - Tests cover repair success/fail and client handling
References
docs/projects/slides-v0/issues/remove-legacy-client-patch-flow.mdapps/web/src/features/slideshow/hooks/use-patch-application.tspackages/api/src/slideshow/assistant-service.ts
Reactions are currently unavailable