Skip to content

Document config wizard auto-detect and migration#293

Closed
clcollins wants to merge 14 commits into
mainfrom
worktree-phase4-silent-policy
Closed

Document config wizard auto-detect and migration#293
clcollins wants to merge 14 commits into
mainfrom
worktree-phase4-silent-policy

Conversation

@clcollins

Copy link
Copy Markdown
Owner

Summary

  • Add note about auto-entering config wizard when no config file exists on first launch
  • Document automatic migration from deprecated service_escalation_policies format

Test plan

  • Verify README renders correctly on GitHub

🤖 Generated with Claude Code

clcollins and others added 14 commits June 6, 2026 11:55
Re-escalation uses the incident's own policy — no config needed. Only
silencing needs a target policy. Replace the full service-to-policy
mapping with a single default_silent_escalation_policy key (1 API call
at startup) plus optional custom_service_escalation_policies overrides.

--pick-teams now auto-discovers silent policies via
ListEscalationPoliciesWithContext and presents them for selection.
Old service_escalation_policies config still works with deprecation
warning.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ListEscalationPolicies(TeamIDs) misses silent policies not directly
tagged on the team. Replace auto-discovery with explicit user prompts:
text input for default silent policy ID (validated via API) and optional
comma-separated service:policy custom mappings. Remove launchTUI() call
after setup to avoid terminal glitch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Work in progress — merging token/teams/policies into single huh.Form
using OptionsFunc for dynamic team loading. Still needs the two-form
merge completed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the standalone huh form in cmd/config.go with an inline
config mode inside the srepd TUI, following the existing team picker
pattern. The wizard now renders inside the same tea.Program with
srepd's styles, header, footer, and help system.

Key changes:
- Extract pure config functions to pkg/config/ package
- Add configMode to TUI model with full huh form (token, teams,
  silent policy, custom mappings, summary+confirm)
- Simplify cmd/config.go to thin launcher that sets configMode flag
- Auto-detect missing config file in cmd/root.go and enter wizard
- Initialize PD client asynchronously after config save
- Forward non-key messages to huh form for proper rendering
- Defer config form creation until WindowSizeMsg arrives

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use pointer-based configFormState struct so huh form Value() bindings
survive bubbletea's model copying. Previously form writes went to stale
model copies, causing teams/silent/custom values to be lost on save.

Also fix form completion detection: check StateCompleted in the
catch-all message forwarding path, not just the key message handler,
since the form may complete on non-key messages.

Additionally initialize PD client asynchronously after config save
and trigger window resize to render the incident table.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Show "(unchanged)" label on all summary fields, not just token
- Uppercase custom policy keys from Viper (which lowercases map keys)
- Remove "No config file found" stdout message (invisible under alt-screen)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fetch team names eagerly in prepareConfigWizardCmd so they display
  in the summary even when teams are kept (bug #24)
- Add token validation via PD API on the token input field — prevents
  advancing to team selection with an invalid token (bug #27)
- Detect old-format config (service_escalation_policies) and force
  writing new-format keys on save even when values are unchanged,
  triggering migration to default_silent_escalation_policy and
  custom_service_escalation_policies (bug #28)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fetch escalation policy names from PD API during wizard preparation.
Display team and policy names alongside IDs in keep prompts and
summary (e.g., "Silent Test (PCGXUDY)" instead of bare "PCGXUDY").

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Show "Loading configuration..." instead of the incident table while
configModeRequested is true but the config form hasn't been built yet.
This prevents a brief flash of the empty table view before the wizard
appears.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The completion handler cleared configMode but not configModeRequested,
causing View() to show "Loading configuration..." permanently after
the wizard saved. Now both flags are cleared on completion and abort.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- CommentOutOldPolicies() comments out service_escalation_policies
  block with a deprecation note when new-format keys are written
- BuildSummary shows policy names in custom mappings display
  (e.g., "P5LAB5Y → DMS Silent Test (PVBANNN)")

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace default huh keymap with one that removes misleading "esc back"
help text (esc is disabled in huh) and adds ctrl+q to quit binding.
Only shift+tab for back, enter for next — matches actual behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Suppress srepd's own help bar (with "esc back", "h help") while in
config mode. The huh form renders its own contextual help internally.
After the wizard exits, srepd's normal help bar returns.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Each wizard prompt now includes guidance on where to find the required
data in PagerDuty:
- Token: how to create an API key
- Teams: select teams whose incidents you monitor
- Silent policy: where to find escalation policy IDs
- Custom mappings: where to find service and policy IDs

Also set form width to windowSize.Width for proper text wrapping.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@clcollins clcollins closed this Jun 7, 2026
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.

1 participant