fix(tui): carry the region override through a resource's whole flow - #2239
fix(tui): carry the region override through a resource's whole flow#2239AlexanderRichey wants to merge 1 commit into
Conversation
A detail page opened through project status or a harness's linked rows fetches in the region named by ?region=, but its actions are routes of their own: enter on `detail`, `endpoints`, `events` and the rest dropped the query, so the next screen fell back to the ambient region and failed to find a resource deployed elsewhere. useRegionNavigate wraps useNavigate for the runtime, memory, gateway, harness and identity screens: string routes carry the current screen's ?region= forward (withRegion, which leaves a route that already names a region alone), history moves pass through untouched. Every TUI screen and picker now resolves its Core options through useCoreOpts rather than coreOptsFromCtx, so the destination honours the override wherever the flow goes — a hub's actions, the lists they open, the rows those lists forward to, and the JSON views. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016KnHdxcPYTnQiDY7Y1PY6s
|
Claude Security Review: no high-confidence findings. (run) |
There was a problem hiding this comment.
AgentCore Harness Review
Verdict: Looks good
Nice, focused fix. useRegionNavigate + withRegion is a clean way to keep the region override flowing through a resource's forward routes while leaving navigate(-1) untouched, and the change is exercised end‑to‑end (harness hub, memory hub, runtime hub, project status) rather than through hand‑mocked router internals. Options are correctly forwarded on the string‑route path, withRegion respects a route that already names a region, and the useCoreOpts/useRegionNavigate split is applied consistently on every path that's reachable via a ?region= link (project‑status detail routes and the harness linked resources).
Two small, non‑blocking observations:
src/handlers/harness/get/screen.tsx:261builds the region query manually (${link.route}?region=${encodeURIComponent(region)}) instead of going throughwithRegion. Same result today, but the helper exists — worth threading through so there's one place that knows the query‑string shape.- The eval
getscreens (e.g.src/handlers/eval/dataset/get/screen.tsx,.../evaluator/get/screen.tsx, etc.) were switched touseCoreOptsbut still use plainuseNavigatefor their JSON action. Nothing currently links to these routes with?region=, so it's a latent inconsistency rather than a live bug — but if a future linked view ever forwards to one of them, the JSON action will silently fetch in the ambient region. Cheap to pre‑empt by usinguseRegionNavigatein those screens too.
Neither of those needs to block this PR.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## refactor #2239 +/- ##
=========================================
Coverage 97.02% 97.02%
=========================================
Files 564 564
Lines 39233 39260 +27
=========================================
+ Hits 38064 38092 +28
+ Misses 1169 1168 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
) A bare `project status` links each deployed row to its detail page with ?region=<target>, but the actions those pages open in turn (endpoints, events, detail JSON, …) run in the ambient region, so a project deployed anywhere else breaks one step past the tree (#2239 tried to thread the region through every flow instead). The headless report has the same problem one step later: the ids it prints only work with the same --region. Compare the resolved target's region with the context's before rendering. The CLI throws a ProjectStateError naming both regions; the screen shows the same message in place of the tree and keeps esc as the way out. Rerun with --region <target region> to see the report. The headless tests pin AWS_REGION to the default target's region, since withRegion would otherwise read the developer's shell, and the screen tests pin RegionKey to the target's so the tree still renders; each suite gains a mismatch case of its own. Claude-Session: https://claude.ai/code/session_016KnHdxcPYTnQiDY7Y1PY6s Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
What
A detail page opened through project status or a harness's linked rows fetches in the region named by
?region=, but its actions are routes of their own. Enter ondetail,endpoints,events,targetsand the rest dropped the query, so the next screen fell back to the ambient region and failed to find a resource deployed elsewhere. The region now follows the resource through its whole flow.How
useRegionNavigate(src/handlers/utils.tsx) wrapsuseNavigatefor the runtime, memory, gateway, harness and identity screens and the two wizards that navigate: string routes carry the current screen's?region=forward, history moves (navigate(-1)) pass through untouched. The purewithRegionhelper does the query-string work and leaves a route that already names a region alone, so a harness's linked rows (which link with the region from each resource's own ARN) still win over the hub's region.useCoreOptsinstead ofcoreOptsFromCtx, so the destination honours the override wherever the flow goes: a hub's actions, the lists they open, the rows those lists forward to, the JSON views, invoke/shell/exec, and the wizards. The CLI handlers keepcoreOptsFromCtx. The eval screens and pickers are switched too so the rule is uniform; nothing links to them with a region today, so it is a no-op there.Checks
bun test src— 3164 pass. The 11 failures are all insrc/io/exec.test.ts, which spawnsnode, not installed in the verification environment (same 11 fail onrefactor).bun run typecheck,bun run lint:check,bun run format:check— clean.refactorat 6731091; the two conflicts with fix(tui): esc from a deep-linked harness wizard returns to the menu #2234 (the harness wizard no longer navigates, the update screen now does) resolved by hand.Tests
withRegionunit tests (append, join an existing query, keep an explicit region, no-op without one).detailJSON refetches in the target's region; Runtime →endpointslists in the target's region; Memory →eventslists actors in the target's region.?region=: runtime (endpoints, thendetailJSON), memory (events→ actors), gateway (targets), harness (endpoints), and a harness → linked runtime →detailJSON chain, each asserting the region on the resulting Core call.Verification in a terminal
Driven in a pseudo-terminal against a local stub replaying live-captured
GetHarnessresponses and logging the SigV4 signing region of every request (live credentials had expired; the same setup as #2215):synthetic-linked→ gateway row (aus-west-2ARN on aus-east-1harness) →targetslisted targets with the stub signing forus-west-2;MyPDXHarness-rhkXkAE1ISopened with--region us-west-2→ runtime row →detailandendpointsfetched the JSON and the endpoint list inus-west-2. Before the change the second request in each pair signed for the ambient region.🤖 Generated with Claude Code
https://claude.ai/code/session_016KnHdxcPYTnQiDY7Y1PY6s