chore(canvas): review nits on ConsoleModal + Peers empty state

Post-review cleanup for the #1178 / #1189 bootstrap-watcher flow:

- ConsoleModal status-code matching uses \b regex anchors instead of
  raw substrings. Before, any error message containing "501" inside
  a longer digit run ("15012") would false-match into the self-hosted
  branch. Unlikely in practice but cheap to tighten.

- Peers empty-state copy now explains WHY the list is empty on
  offline / failed / provisioning workspaces instead of rendering the
  same "No reachable peers" text used for healthy workspaces with
  zero siblings. Online workspaces unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hongming Wang 2026-04-20 18:02:22 -07:00
parent 23788f5cba
commit c033f3b051
2 changed files with 10 additions and 4 deletions

View File

@ -45,12 +45,14 @@ export function ConsoleModal({ workspaceId, workspaceName, open, onClose }: Prop
})
.catch((e) => {
if (ignore) return;
// 501 = deployment without a control plane (local docker-compose);
// we render a friendlier message than "501 Not Implemented".
// 501 = deployment without a control plane (local docker-compose).
// 404 = EC2 instance has been terminated. Match with word-boundary
// regex so a status code appearing inside an unrelated number
// ("15012") doesn't false-match.
const msg = e instanceof Error ? e.message : "Failed to load console output";
if (/501/.test(msg)) {
if (/\b501\b/.test(msg)) {
setError("Console output is only available on cloud (SaaS) deployments.");
} else if (/404/.test(msg)) {
} else if (/\b404\b/.test(msg)) {
setError("No EC2 instance found for this workspace — it may have been terminated.");
} else {
setError(msg);

View File

@ -268,6 +268,10 @@ export function DetailsTab({ workspaceId, data }: Props) {
<Section title={`Peers (${peers.length})`}>
{peersError ? (
<p className="text-xs text-red-400">{peersError}</p>
) : peers.length === 0 && data.status !== "online" && data.status !== "degraded" ? (
<p className="text-xs text-zinc-500">
Peers are only discoverable while the workspace is online.
</p>
) : peers.length === 0 ? (
<p className="text-xs text-zinc-500">No reachable peers</p>
) : (