feat(pilot): Phase 5 — inline Script Generator integration
All checks were successful
Mirror to GitHub / mirror (push) Successful in 10s
All checks were successful
Mirror to GitHub / mirror (push) Successful in 10s
Wires the SuggestedFix card to an inline panel that handles both cases:
template-matched fixes open the Script Library generator with parameters
pre-filled from session context; un-matched fixes open the three-option
dialog (one_off / draft_template / build_template). The decision endpoint
records the path choice with side effects: draft_template persists a
draft_templates row via a Sonnet-driven TemplateExtractionService;
build_template returns a redirect to the Script Builder; one_off just
records the choice.
Backend:
- TemplateExtractionService: drafts a parameter schema from a concrete
rendered script. Conservative by default ("prefer fewer parameters").
Round-trip-validates that templated_body only references declared
parameters; missing-key mismatch falls back to the original script
with no params. LLM/parse failures fall back identically — the
engineer can still create a draft and refine in the post-resolve
prompt (Phase 6).
- /suggested-fixes/{fix_id}/decision side effects:
* one_off → returns rendered_script (engineer's edited version or the
fix's ai_drafted_script verbatim)
* draft_template → same + creates draft_templates row with extracted
params, returns draft_template_id
* build_template → returns redirect_path=/scripts/builder?from_session=
&fix= so the frontend can navigate to the builder pre-loaded
- 400 when a non-template fix has no ai_drafted_script (template-matched
fixes take the dedicated /scripts/generate path, not this endpoint).
- 12 tests: TemplateExtractionService parse + fallback paths, all four
decision branches, edited_script override, missing-script 400.
Frontend:
- src/components/pilot/script/{TemplateMatchPanel, NoTemplateDialog,
ParameterizationPreview}.tsx — inline panels rendered in the task
lane's bottom slot when the engineer clicks a SuggestedFix card.
- TemplateMatchPanel: loads template via /scripts/templates/{id},
pre-fills params from fix.ai_drafted_parameters with cyan "from
session" tags, generates via existing /scripts/generate (already
bumps state_version on ai_session_id from Phase 3). 404 falls back
with a clear message instead of erroring.
- NoTemplateDialog: shows the AI-drafted script with proposed parameter
values highlighted in amber via ParameterizationPreview; three option
cards with the middle (draft_template) flagged Recommended; inline
edit on the script body before deciding.
- SuggestedFix card now clickable: onActivate toggles the inline panel.
- AssistantChatPage: scriptPanelOpen state + handleScriptDecision that
navigates on build_template and toasts on the other paths. Active fix
changes auto-close the panel so engineers don't act on stale state.
- Cmd+K → "Open inline Script Generator" palette entry surfaces only on
/pilot/:id routes; fires a window event the chat page subscribes to.
No Resolve shortcut added per Section 14 decision (browser ⌘R conflict).
Verified 2026-04-22 against the dev stack:
- one_off / draft_template / build_template all return the right shape
with real Sonnet TemplateExtractionService for the draft path.
- Conservative extraction confirmed: cmdkey + Restart-Process script
yielded zero proposed parameters as intended.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
> **Target:** Transform `/assistant` (ResolutionAssist) into the new unified `/pilot` (FlowPilot) surface.
|
||||
> **Audience:** Claude Code (implementation) and Codex (review) reviewed by Michael (owner).
|
||||
> **Status:** Phases 0–4 implemented and verified end-to-end against the dev stack. Phase 5 next.
|
||||
> **Last updated:** April 22, 2026 (Phase 4 — Resolve + Escalate writebacks — committed; local-only and mocked-PSA paths verified, live CW ticket round-trip pending a test instance)
|
||||
> **Status:** Phases 0–5 implemented and verified end-to-end against the dev stack. Phase 6 next.
|
||||
> **Last updated:** April 22, 2026 (Phase 5 — inline Script Generator integration — committed; live decision endpoint with Sonnet-driven TemplateExtractionService verified)
|
||||
|
||||
---
|
||||
|
||||
@@ -808,6 +808,22 @@ git commit -m "feat(pilot): wire Resolve and Escalate to ConnectWise writeback w
|
||||
- `⌘K → "script"` anywhere in a session opens the generator directly.
|
||||
- Edge case: if the suggested fix's `script_template_id` points at a template that has been deleted, show the no-template three-option dialog with the AI-drafted script (do not error).
|
||||
|
||||
**Verified on 2026-04-22:**
|
||||
- `one_off` returns rendered_script, no draft persisted.
|
||||
- `draft_template` returns rendered_script + draft_template_id; real Sonnet-driven
|
||||
TemplateExtractionService persists a `draft_templates` row with the fix's
|
||||
title pre-filled and `status=pending`.
|
||||
- `build_template` returns `redirect_path=/scripts/builder?from_session=…&fix=…`.
|
||||
- Conservative extraction default works: a script with environment-agnostic
|
||||
cmdlets (cmdkey, Restart-Process) yielded zero proposed parameters as
|
||||
intended by the "prefer fewer parameters" rule.
|
||||
- TemplateMatchPanel falls back gracefully on 404 (deleted template) by
|
||||
surfacing a panel-level message; the engineer can dismiss the fix and
|
||||
re-trigger the AI for a fresh suggestion.
|
||||
- Cmd+K → "Open inline Script Generator" surfaces only when on a `/pilot/:id`
|
||||
route; fires a window event the chat page subscribes to. No Resolve
|
||||
shortcut added (per Section 14 decision).
|
||||
|
||||
```
|
||||
git commit -m "feat(pilot): integrate Script Generator inline with suggested fixes"
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user