feat(web): select diagnostics environment #4486
Closedcolonelpanic8(GitHub profile, opens in a new tab)wants to merge 6 commits into
main fromrefs/pull/4486/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/components/settings/DiagnosticsSettings.tsx line 1121Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -960,0 +1014,21 @@1014+ <SettingsSection title="Environment">1015+ <SettingsRow1016+ title="Diagnostics source"1017+ description="Process, resource, and trace diagnostics are collected by a specific backend. Choose the machine you want to inspect."1018+ status={1019+ diagnosticsEnvironment ? (1020+ <>1021+ {connectionStatusText(diagnosticsEnvironment.connection)}1022+ {diagnosticsEnvironment.displayUrl1023+ ? ` · ${diagnosticsEnvironment.displayUrl}`1024+ : null}1025+ </>1026+ ) : (1027+ "Connect an environment to view diagnostics."1028+ )1029+ }1030+ control={1031+ diagnosticsEnvironment ? (1032+ <Select1033+ value={diagnosticsEnvironment.environmentId}1034+ onValueChange={(value) => setSelectedEnvironmentId(value as EnvironmentId)}apps/web/src/components/settings/DiagnosticsSettings.tsx line 885Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -809,6 +825,18 @@809825810826 export function DiagnosticsSettingsPanel() {811- const observability = useAtomValue(primaryServerObservabilityAtom);812- const availableEditors = useAtomValue(primaryServerAvailableEditorsAtom);827+ const { environments } = useEnvironments();813828 const primaryEnvironment = usePrimaryEnvironment();814- const environmentId = primaryEnvironment?.environmentId ?? null;829+ const activeEnvironmentId = useActiveEnvironmentId();830+ const [selectedEnvironmentId, setSelectedEnvironmentId] = useState<EnvironmentId | null>(null);831+ const environmentId = resolveDiagnosticsEnvironmentId({832+ selectedEnvironmentId,833+ primaryEnvironmentId: primaryEnvironment?.environmentId ?? null,834+ activeEnvironmentId,835+ availableEnvironmentIds: environments.map((environment) => environment.environmentId),836+ });837+ const diagnosticsEnvironment =838+ environments.find((environment) => environment.environmentId === environmentId) ?? null;839+ const observability = diagnosticsEnvironment?.serverConfig?.observability ?? null;840+ const availableEditors = diagnosticsEnvironment?.serverConfig?.availableEditors ?? [];841+ const environmentItems = useMemo(842+ () =>
- apps/web/src/components/settings/DiagnosticsSettings.tsx line 891Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -814 +829,20 @@814- const environmentId = primaryEnvironment?.environmentId ?? null;829+ const activeEnvironmentId = useActiveEnvironmentId();830+ const [selectedEnvironmentId, setSelectedEnvironmentId] = useState<EnvironmentId | null>(null);831+ const environmentId = resolveDiagnosticsEnvironmentId({832+ selectedEnvironmentId,833+ primaryEnvironmentId: primaryEnvironment?.environmentId ?? null,834+ activeEnvironmentId,835+ availableEnvironmentIds: environments.map((environment) => environment.environmentId),836+ });837+ const diagnosticsEnvironment =838+ environments.find((environment) => environment.environmentId === environmentId) ?? null;839+ const observability = diagnosticsEnvironment?.serverConfig?.observability ?? null;840+ const availableEditors = diagnosticsEnvironment?.serverConfig?.availableEditors ?? [];841+ const environmentItems = useMemo(842+ () =>843+ environments.map((environment) => ({844+ value: environment.environmentId,845+ label: environment.label,846+ })),847+ [environments],848+ );apps/web/src/components/settings/DiagnosticsSettings.tsx line 891Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -814 +829,20 @@814- const environmentId = primaryEnvironment?.environmentId ?? null;829+ const activeEnvironmentId = useActiveEnvironmentId();830+ const [selectedEnvironmentId, setSelectedEnvironmentId] = useState<EnvironmentId | null>(null);831+ const environmentId = resolveDiagnosticsEnvironmentId({832+ selectedEnvironmentId,833+ primaryEnvironmentId: primaryEnvironment?.environmentId ?? null,834+ activeEnvironmentId,835+ availableEnvironmentIds: environments.map((environment) => environment.environmentId),836+ });837+ const diagnosticsEnvironment =838+ environments.find((environment) => environment.environmentId === environmentId) ?? null;839+ const observability = diagnosticsEnvironment?.serverConfig?.observability ?? null;840+ const availableEditors = diagnosticsEnvironment?.serverConfig?.availableEditors ?? [];841+ const environmentItems = useMemo(842+ () =>843+ environments.map((environment) => ({844+ value: environment.environmentId,845+ label: environment.label,846+ })),847+ [environments],848+ );
- apps/web/src/components/settings/DiagnosticsSettings.tsx line 1168Resolvedby colonelpanic8(GitHub profile, opens in a new tab)@@ -961,7 +1110,20 @@1110+ ))}1111+ </SelectGroup>1112+ </SelectPopup>1113+ </Select>1114+ ) : (1115+ <Button render={<Link to="/settings/connections" />} size="xs" variant="outline">1116+ Manage connections1117+ </Button>1118+ )1119+ }1120+ />1121+ </SettingsSection>1122+9611123 <SettingsSection9621124 title="Live Processes"9631125 headerAction={9641126 <div className="flex items-center gap-1.5">9651127 <DiagnosticsLastChecked checkedAt={processData?.readAt ?? null} />9661128 <DiagnosticsRefreshButton967- isPending={isProcessPending}1129+ isPending={isProcessPending && isConnected}
- apps/web/src/components/settings/DiagnosticsSettings.tsx line 1008Resolvedby colonelpanic8(GitHub profile, opens in a new tab)@@ -886,5 +949,16 @@886- const error = squashAtomCommandFailure(result);887- setOpenLogsDirectoryError(888- error instanceof Error ? error.message : "Unable to open logs folder.",889- );890- }949+ const failure =950+ result._tag === "Failure" && !isAtomCommandInterrupted(result)951+ ? squashAtomCommandFailure(result)952+ : null;953+ const error =954+ failure === null955+ ? null956+ : failure instanceof Error957+ ? failure.message958+ : "Unable to open logs folder.";959+ // Only the request that owns the current pending state may clear it.960+ setLogsDirectoryState((current) =>961+ current !== null && current.environmentId === environmentId962+ ? { environmentId, isOpening: false, error }963+ : current,964+ );
- apps/web/src/components/settings/DiagnosticsSettings.tsx line 1221Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1009,9 +1174,10 @@10091174 ) : null}10101175 <ProcessDiagnosticsTable10111176 processes={processData?.processes ?? []}1012- signalingPid={signalingPid}1177+ signalingPids={signalingPids}10131178 onSignal={signalProcess}10141179 emptyLabel={1015- isProcessInitialLoading1180+ connectionNotice ??1181+ (isProcessInitialLoading10161182 ? "Loading live processes..."1017- : "No live descendant processes found."1183+ : "No live descendant processes found.")apps/web/src/components/settings/DiagnosticsSettings.tsx line 425Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -394,9 +417,9 @@394417395418 function ProcessDiagnosticsTable({396419 processes,397- signalingPid,420+ signalingPids,398421 onSignal,399422 emptyLabel,400423 }: {401424 processes: ReadonlyArray<ServerProcessDiagnosticsEntry>;402- signalingPid: number | null;425+ signalingPids: ReadonlySet<number>;
- apps/web/src/components/settings/DiagnosticsSettings.tsx line 1168Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -961,7 +1127,20 @@1127+ ))}1128+ </SelectGroup>1129+ </SelectPopup>1130+ </Select>1131+ ) : (1132+ <Button render={<Link to="/settings/connections" />} size="xs" variant="outline">1133+ Manage connections1134+ </Button>1135+ )1136+ }1137+ />1138+ </SettingsSection>1139+9611140 <SettingsSection9621141 title="Live Processes"9631142 headerAction={9641143 <div className="flex items-center gap-1.5">9651144 <DiagnosticsLastChecked checkedAt={processData?.readAt ?? null} />9661145 <DiagnosticsRefreshButton967- isPending={isProcessPending}1146+ isPending={isProcessPending && isConnected}
- apps/web/src/components/settings/DiagnosticsSettings.tsx line 870Resolvedby colonelpanic8(GitHub profile, opens in a new tab)@@ -809,6 +844,18 @@809844845+interface LogsDirectoryState {846+ readonly environmentId: EnvironmentId | null;847+ readonly isOpening: boolean;848+ readonly error: string | null;849+}850+810851 export function DiagnosticsSettingsPanel() {811- const observability = useAtomValue(primaryServerObservabilityAtom);812- const availableEditors = useAtomValue(primaryServerAvailableEditorsAtom);852+ const { environments } = useEnvironments();813853 const primaryEnvironment = usePrimaryEnvironment();814- const environmentId = primaryEnvironment?.environmentId ?? null;854+ const activeEnvironmentId = useActiveEnvironmentId();855+ const [selectedEnvironmentId, setSelectedEnvironmentId] = useState<EnvironmentId | null>(null);856+ const environmentId = resolveDiagnosticsEnvironmentId({857+ selectedEnvironmentId,858+ primaryEnvironmentId: primaryEnvironment?.environmentId ?? null,859+ activeEnvironmentId,860+ availableEnvironmentIds: environments.map((environment) => environment.environmentId),861+ });
juliusmarminge closed this
Sign in to join this conversation.






Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
81fe8608-f11a-4a2d-af3b-2ac3fc8aab0dYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share