Fix Pack creation: correct API path, signal-based reactivity, null-safe sort

Three root causes for "create does nothing":

1. Wrong API base path: PolicyApiService used /api/policy (routed to
   platform service via /api/ catch-all) instead of /policy/api (routed
   to policy-gateway via nginx regex). Fixed API_BASE.

2. OnPush + plain fields: loading/packs/refreshing were plain booleans
   and arrays. OnPush change detection ignored their mutations. Converted
   all three to signals so template reactivity works automatically.

3. sortPacks crash: API returns packs with undefined modifiedAt/id
   fields. localeCompare on undefined threw TypeError, preventing the
   empty state from rendering. Added nullish coalescing fallbacks.

Also removed hardcoded fallback "Core Policy Pack" from the store —
it masked API failures and prevented the create form from appearing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
master
2026-03-29 00:24:21 +02:00
parent d8e6a2a53d
commit 39e1bf0bd4
3 changed files with 30 additions and 36 deletions

View File

@@ -217,7 +217,7 @@ public sealed class TopologyLayoutService
var deployingCount = envPaths.Count(p => p.Status is "running" or "deploying");
var pendingCount = envPaths.Count(p => p.Status is "pending" or "awaiting_approval" or "gates_running");
var failedCount = envPaths.Count(p => p.Status is "failed");
var totalDeployments = envPaths.Count;
var totalDeployments = env?.TargetCount ?? 0;
var agentStatus = ResolveAgentStatus(envId, targetsByEnv);