Skip to content

[codex] Enhance host service unavailable errors#4613

Merged
Kitenite merged 3 commits into
mainfrom
enhance-service-error-toa
May 16, 2026
Merged

[codex] Enhance host service unavailable errors#4613
Kitenite merged 3 commits into
mainfrom
enhance-service-error-toa

Conversation

@Kitenite

@Kitenite Kitenite commented May 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

This updates host-service unavailable errors in the desktop renderer so they include actionable context instead of only saying the host service is unavailable.

What changed

  • Added a shared host-service unavailable message/toast helper that includes the attempted action, active organization, device id, host-service status, and a recovery hint.
  • Exposed host-service process status and active organization metadata through LocalHostServiceProvider and command palette context.
  • Replaced generic unavailable errors across workspace creation, open-in actions, project import/clone/settings flows, agent settings, and task workspace flows.
  • Preserved short inline submit blockers while showing the richer diagnostic when users click blocked local-host actions.

Why

The previous toast did not tell users whether the service was starting, stopped, tied to a specific organization/device, or what they could do next. These paths now surface enough detail to retry or restart the host service from the tray menu.

Validation

  • bun run lint -- apps/desktop/src/renderer/lib/host-service-unavailable.ts
  • bun run lint -- <touched files>
  • bun run --cwd apps/desktop typecheck
  • bun run lint

@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR establishes a centralized host-service-unavailable messaging system by introducing helper functions and types in a new library, expanding LocalHostServiceProvider to expose organization and service status data, and systematically replacing generic error toasts with context-aware messages across the renderer codebase.

Changes

Host service unavailability messaging

Layer / File(s) Summary
Host service unavailability library foundation
apps/desktop/src/renderer/lib/host-service-unavailable.ts
New module exports HostServiceAvailabilityStatus type and HostServiceUnavailableContext interface; provides getHostServiceUnavailableMessage and showHostServiceUnavailableToast helpers that build messages with optional action prefixes and status-based recovery guidance.
LocalHostServiceProvider expansion
apps/desktop/src/renderer/routes/_authenticated/providers/LocalHostServiceProvider/LocalHostServiceProvider.tsx
Context interface extended with activeOrganizationId, activeOrganizationName, and hostServiceStatus. Provider now fetches process status and derives service status from connection port availability or process state, defaulting to "unknown".
CommandContext updates and command palette error handling
apps/desktop/src/renderer/commandPalette/core/types.ts, apps/desktop/src/renderer/commandPalette/core/ContextProvider.tsx, apps/desktop/src/renderer/commandPalette/modules/openIn/commands.ts
CommandContext interface gains org and status fields. CommandContextProvider reads these from expanded host service provider. openIn/commands.ts replaces generic toast with showHostServiceUnavailableToast helper.
Hook and store error message standardization
apps/desktop/src/renderer/hooks/useEnsureV2Project/useEnsureV2Project.ts, apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/AddRepositoryModals/hooks/useFolderFirstImport/useFolderFirstImport.ts, apps/desktop/src/renderer/stores/workspace-creates/useWorkspaceCreates.ts, apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarWorkspaceItem/hooks/useDashboardSidebarWorkspaceItemActions/useDashboardSidebarWorkspaceItemActions.ts, apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/useSubmitWorkspace.ts
Hooks replace generic error strings with getHostServiceUnavailableMessage when throwing. useSubmitWorkspace enhances failure toasts with error details from mutations.
Dashboard and repository modal error handling
apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/AddRepositoryModals/components/NewProjectModal/NewProjectModal.tsx
NewProjectModal clone flow uses showHostServiceUnavailableToast instead of generic error toast when activeHostUrl is missing.
Workspace and task operation error handling
apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/$taskId/components/PropertiesSidebar/components/OpenInWorkspaceV2/OpenInWorkspaceV2.tsx, apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/PromptGroup.tsx, apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/components/TasksView/components/TasksTopBar/components/RunInWorkspacePopoverV2/RunInWorkspacePopoverV2.tsx, apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/components/TasksView/components/TasksTopBar/components/RunIssuesInWorkspacePopover/RunIssuesInWorkspacePopover.tsx
Task/workspace operation components branch on local-host unavailability to call showHostServiceUnavailableToast. Also enhance workspace creation failure messages with error details from first failed result.
Settings and agent management error handling
apps/desktop/src/renderer/routes/_authenticated/settings/agents/components/V2AgentsSettings/V2AgentsSettings.tsx, apps/desktop/src/renderer/routes/_authenticated/settings/agents/components/V2AgentsSettings/components/AgentDetail/AgentDetail.tsx, apps/desktop/src/renderer/routes/_authenticated/settings/v2-project/$projectId/components/V2ProjectSettings/components/ProjectLocationSection/ProjectLocationSection.tsx, apps/desktop/src/renderer/routes/_authenticated/settings/v2-project/$projectId/components/V2ProjectSettings/components/DeleteProjectSection/DeleteProjectSection.tsx
Settings components use helper functions for add/update/remove/delete operations. ProjectLocationSection consolidates five unavailability checks across setup, clone, path picking, import, and relocation flows.
Miscellaneous component error handling
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/components/RenameBranchDialog/RenameBranchDialog.tsx
RenameBranchDialog rename flow uses showHostServiceUnavailableToast when host service is unavailable.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • superset-sh/superset#4488: Introduces the command-palette framework and CommandContextProvider that this PR extends with new host-organization context fields and error handling.

Poem

🐰 A rabbit hops through error messages today,
Consolidating toasts in a cleaner way.
Where host services fail, we'll now explain,
With org names and status—no generic pain.
From provider to component, the pattern's unified,
One library to guide them all. Hoorah, clarified!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.17% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title '[codex] Enhance host service unavailable errors' clearly and specifically describes the main change: improving error messages for host service unavailability.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description includes all required template sections with clear, detailed information about changes, rationale, and validation steps.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch enhance-service-error-toa

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@capy-ai

capy-ai Bot commented May 16, 2026

Copy link
Copy Markdown

Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

@stage-review

stage-review Bot commented May 16, 2026

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 6 individual chapters for you:

Title
1 Define host service availability types and helpers
2 Expose host status in LocalHostServiceProvider
3 Wire host status into command palette context
4 Enhance workspace creation and import errors
5 Update task and project action errors
6 Enhance agent and project settings errors
Open in Stage

Chapters generated by Stage for commit 1dd188d on May 16, 2026 12:31am UTC.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/desktop/src/renderer/routes/_authenticated/settings/agents/components/V2AgentsSettings/V2AgentsSettings.tsx (1)

184-189: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Make the inline error message selectable.

This error surface contains diagnostic text users may need to copy, but it is missing select-text cursor-text.

Suggested fix
-			<div className="p-6 text-sm text-destructive">
+			<div className="p-6 text-sm text-destructive select-text cursor-text">

As per coding guidelines, apps/desktop/**/*.{tsx,jsx}: Error text must be selectable by users with explicit select-text cursor-text classes; renderer sets user-select: none on body.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/desktop/src/renderer/routes/_authenticated/settings/agents/components/V2AgentsSettings/V2AgentsSettings.tsx`
around lines 184 - 189, The error message in V2AgentsSettings is not selectable
because the div's className lacks the required select-text and cursor-text
classes; update the div that renders the fallback error (the element that uses
configsQuery.error and hostServiceUnavailableMessage) to include "select-text
cursor-text" in its className so users can copy diagnostic text.
apps/desktop/src/renderer/routes/_authenticated/settings/v2-project/$projectId/components/V2ProjectSettings/components/DeleteProjectSection/DeleteProjectSection.tsx (1)

91-91: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

The host-unavailable toast path is currently unreachable.

AlertDialogAction is disabled when !activeHostUrl, so users can’t trigger handleDelete and see the new contextual toast.

Suggested fix
-							disabled={isDeleting || !activeHostUrl}
+							disabled={isDeleting}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/desktop/src/renderer/routes/_authenticated/settings/v2-project/`$projectId/components/V2ProjectSettings/components/DeleteProjectSection/DeleteProjectSection.tsx
at line 91, AlertDialogAction is currently disabled when !activeHostUrl so
handleDelete never runs and the "host-unavailable" toast can't be shown; remove
the dependency on activeHostUrl from the disabled prop (use
disabled={isDeleting} instead) and add an early check inside handleDelete (or
its wrapper) that if !activeHostUrl calls the contextual toast and returns
without attempting deletion; update references to AlertDialogAction and
handleDelete to reflect this behavior so the toast path is reachable while still
preventing duplicate deletes via isDeleting.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/components/TasksView/components/TasksTopBar/components/RunInWorkspacePopoverV2/RunInWorkspacePopoverV2.tsx`:
- Around line 217-223: handleRun currently returns early when submitBlocker is
set, so the new local-host unavailable toast path is never reached; change the
early-return logic so the local-host diagnostic toast is shown even when
submitBlocker is true: inside handleRun, before returning for submitBlocker,
check if hostId === machineId && !activeHostUrl and call
showHostServiceUnavailableToast(hostService, { action: "run tasks in workspaces"
}) then return; apply the same adjustment to the other handleRun-like block at
the second occurrence (around the 379-381 area) so the toast is reachable even
when submitBlocker disables the action.

In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/components/TasksView/components/TasksTopBar/components/RunIssuesInWorkspacePopover/RunIssuesInWorkspacePopover.tsx`:
- Around line 214-223: The current flow in handleRun makes the submitBlocker
check prevent the local-host unavailable branch from ever running because the
button is disabled when submitBlocker is set; change the logic so the local-host
unavailable diagnostic toast can be shown even when submitBlocker is
truthy—either by moving the hostId/machineId && !activeHostUrl check to run
before the submitBlocker guard within handleRun (call
showHostServiceUnavailableToast(hostService, { action: "run issues in
workspaces" }) and return) or by adjusting the button disabled condition to
allow clicks when host service is unavailable; update references: handleRun,
submitBlocker, hostId, machineId, activeHostUrl,
showHostServiceUnavailableToast, and toast.error.

In
`@apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/useSubmitWorkspace.ts`:
- Around line 142-144: In useSubmitWorkspace.ts, sanitize any backend error text
before passing it into toast.error (the occurrences where toast.error(...) is
called with result.error) to avoid leaking internal SQL/query details to users;
replace the raw result.error in the toast description with a user-friendly,
generic message (e.g. "Workspace creation failed. Please try again.") and send
the full result.error to an internal logger or attach it to a non-UI debug
context for developers; ensure both places that reference result.error for the
toast (the current toast.error calls) are updated to use the sanitized/generic
message while preserving the original error for internal logs.

---

Outside diff comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/settings/agents/components/V2AgentsSettings/V2AgentsSettings.tsx`:
- Around line 184-189: The error message in V2AgentsSettings is not selectable
because the div's className lacks the required select-text and cursor-text
classes; update the div that renders the fallback error (the element that uses
configsQuery.error and hostServiceUnavailableMessage) to include "select-text
cursor-text" in its className so users can copy diagnostic text.

In
`@apps/desktop/src/renderer/routes/_authenticated/settings/v2-project/`$projectId/components/V2ProjectSettings/components/DeleteProjectSection/DeleteProjectSection.tsx:
- Line 91: AlertDialogAction is currently disabled when !activeHostUrl so
handleDelete never runs and the "host-unavailable" toast can't be shown; remove
the dependency on activeHostUrl from the disabled prop (use
disabled={isDeleting} instead) and add an early check inside handleDelete (or
its wrapper) that if !activeHostUrl calls the contextual toast and returns
without attempting deletion; update references to AlertDialogAction and
handleDelete to reflect this behavior so the toast path is reachable while still
preventing duplicate deletes via isDeleting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e812d024-44e6-4b42-8e3d-07b004e28832

📥 Commits

Reviewing files that changed from the base of the PR and between da0282c and 26c5399.

📒 Files selected for processing (20)
  • apps/desktop/src/renderer/commandPalette/core/ContextProvider.tsx
  • apps/desktop/src/renderer/commandPalette/core/types.ts
  • apps/desktop/src/renderer/commandPalette/modules/openIn/commands.ts
  • apps/desktop/src/renderer/hooks/useEnsureV2Project/useEnsureV2Project.ts
  • apps/desktop/src/renderer/lib/host-service-unavailable.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/AddRepositoryModals/components/NewProjectModal/NewProjectModal.tsx
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/AddRepositoryModals/hooks/useFolderFirstImport/useFolderFirstImport.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/components/DashboardSidebarWorkspaceItem/hooks/useDashboardSidebarWorkspaceItemActions/useDashboardSidebarWorkspaceItemActions.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/$taskId/components/PropertiesSidebar/components/OpenInWorkspaceV2/OpenInWorkspaceV2.tsx
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/components/TasksView/components/TasksTopBar/components/RunInWorkspacePopoverV2/RunInWorkspacePopoverV2.tsx
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/components/TasksView/components/TasksTopBar/components/RunIssuesInWorkspacePopover/RunIssuesInWorkspacePopover.tsx
  • apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/PromptGroup.tsx
  • apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/useSubmitWorkspace.ts
  • apps/desktop/src/renderer/routes/_authenticated/providers/LocalHostServiceProvider/LocalHostServiceProvider.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/agents/components/V2AgentsSettings/V2AgentsSettings.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/agents/components/V2AgentsSettings/components/AgentDetail/AgentDetail.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/v2-project/$projectId/components/V2ProjectSettings/components/DeleteProjectSection/DeleteProjectSection.tsx
  • apps/desktop/src/renderer/routes/_authenticated/settings/v2-project/$projectId/components/V2ProjectSettings/components/ProjectLocationSection/ProjectLocationSection.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/components/RenameBranchDialog/RenameBranchDialog.tsx
  • apps/desktop/src/renderer/stores/workspace-creates/useWorkspaceCreates.ts

Comment on lines 217 to +223
const handleRun = () => {
if (!selectedProjectId || !hostId) return;
if (submitBlocker) {
toast.error(submitBlocker);
if (hostId === machineId && !activeHostUrl) {
showHostServiceUnavailableToast(hostService, {
action: "run tasks in workspaces",
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Blocked-action diagnostic toast is unreachable from the UI.

handleRun now includes a local-host unavailable toast path, but the button is disabled whenever submitBlocker is set, so users can’t trigger the new blocked-action diagnostic.

💡 Proposed fix
+	const isLocalHostServiceUnavailable =
+		!!selectedProjectId && !!hostId && hostId === machineId && !activeHostUrl;
+
 	const handleRun = () => {
 		if (!selectedProjectId || !hostId) return;
 		if (submitBlocker) {
-			if (hostId === machineId && !activeHostUrl) {
+			if (isLocalHostServiceUnavailable) {
 				showHostServiceUnavailableToast(hostService, {
 					action: "run tasks in workspaces",
 				});
 			} else {
 				toast.error(submitBlocker);
 			}
 			return;
 		}
@@
 					<Button
 						size="sm"
 						className="w-full h-8"
-						disabled={!!submitBlocker}
+						disabled={!!submitBlocker && !isLocalHostServiceUnavailable}
 						onClick={handleRun}
 					>

Also applies to: 379-381

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/components/TasksView/components/TasksTopBar/components/RunInWorkspacePopoverV2/RunInWorkspacePopoverV2.tsx`
around lines 217 - 223, handleRun currently returns early when submitBlocker is
set, so the new local-host unavailable toast path is never reached; change the
early-return logic so the local-host diagnostic toast is shown even when
submitBlocker is true: inside handleRun, before returning for submitBlocker,
check if hostId === machineId && !activeHostUrl and call
showHostServiceUnavailableToast(hostService, { action: "run tasks in workspaces"
}) then return; apply the same adjustment to the other handleRun-like block at
the second occurrence (around the 379-381 area) so the toast is reachable even
when submitBlocker disables the action.

Comment on lines 214 to +223
const handleRun = () => {
if (!selectedProjectId || !hostId) return;
if (submitBlocker) {
toast.error(submitBlocker);
if (hostId === machineId && !activeHostUrl) {
showHostServiceUnavailableToast(hostService, {
action: "run issues in workspaces",
});
} else {
toast.error(submitBlocker);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Blocked-action diagnostic toast is unreachable from the UI here as well.

This component has the same behavior: submitBlocker disables the button, so the new local-host unavailable toast branch in handleRun cannot be reached via user interaction.

💡 Proposed fix
+	const isLocalHostServiceUnavailable =
+		!!selectedProjectId && !!hostId && hostId === machineId && !activeHostUrl;
+
 	const handleRun = () => {
 		if (!selectedProjectId || !hostId) return;
 		if (submitBlocker) {
-			if (hostId === machineId && !activeHostUrl) {
+			if (isLocalHostServiceUnavailable) {
 				showHostServiceUnavailableToast(hostService, {
 					action: "run issues in workspaces",
 				});
 			} else {
 				toast.error(submitBlocker);
 			}
 			return;
 		}
@@
 					<Button
 						size="sm"
 						className="w-full h-8"
-						disabled={!!submitBlocker}
+						disabled={!!submitBlocker && !isLocalHostServiceUnavailable}
 						onClick={handleRun}
 					>

Also applies to: 379-381

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/components/TasksView/components/TasksTopBar/components/RunIssuesInWorkspacePopover/RunIssuesInWorkspacePopover.tsx`
around lines 214 - 223, The current flow in handleRun makes the submitBlocker
check prevent the local-host unavailable branch from ever running because the
button is disabled when submitBlocker is set; change the logic so the local-host
unavailable diagnostic toast can be shown even when submitBlocker is
truthy—either by moving the hostId/machineId && !activeHostUrl check to run
before the submitBlocker guard within handleRun (call
showHostServiceUnavailableToast(hostService, { action: "run issues in
workspaces" }) and return) or by adjusting the button disabled condition to
allow clicks when host service is unavailable; update references: handleRun,
submitBlocker, hostId, machineId, activeHostUrl,
showHostServiceUnavailableToast, and toast.error.

Comment on lines +142 to +144
toast.error("Workspace creation failed", {
description: result.error,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Sanitize backend error text before showing toast descriptions.

Line 143 and Line 168 now display raw backend error messages; this can leak internal SQL/query details to end users (same leak pattern already guarded elsewhere in this PR).

Suggested patch
+const sanitizeWorkspaceCreateError = (message: string) =>
+	message.startsWith("Failed query:")
+		? "Could not create workspace. Please retry or check logs."
+		: message;
...
 						toast.error("Workspace creation failed", {
-							description: result.error,
+							description: sanitizeWorkspaceCreateError(result.error),
 						});
...
 					toast.error("Workspace creation failed", {
-						description: error instanceof Error ? error.message : String(error),
+						description: sanitizeWorkspaceCreateError(
+							error instanceof Error ? error.message : String(error),
+						),
 					});

Also applies to: 167-169

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/hooks/useSubmitWorkspace/useSubmitWorkspace.ts`
around lines 142 - 144, In useSubmitWorkspace.ts, sanitize any backend error
text before passing it into toast.error (the occurrences where toast.error(...)
is called with result.error) to avoid leaking internal SQL/query details to
users; replace the raw result.error in the toast description with a
user-friendly, generic message (e.g. "Workspace creation failed. Please try
again.") and send the full result.error to an internal logger or attach it to a
non-UI debug context for developers; ensure both places that reference
result.error for the toast (the current toast.error calls) are updated to use
the sanitized/generic message while preserving the original error for internal
logs.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 20 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/PromptGroup.tsx">

<violation number="1" location="apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/PromptGroup.tsx:278">
P2: The new host-service toast condition is too broad and can override unrelated submit blockers (for example, "Select a project"). Only show the rich host-service toast when the blocker is specifically the host-service-unavailable case.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Re-trigger cubic

}
if (submitBlocker) {
toast.error(submitBlocker);
if ((draft.hostId ?? machineId) === machineId && !activeHostUrl) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The new host-service toast condition is too broad and can override unrelated submit blockers (for example, "Select a project"). Only show the rich host-service toast when the blocker is specifically the host-service-unavailable case.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/PromptGroup.tsx, line 278:

<comment>The new host-service toast condition is too broad and can override unrelated submit blockers (for example, "Select a project"). Only show the rich host-service toast when the blocker is specifically the host-service-unavailable case.</comment>

<file context>
@@ -273,11 +275,26 @@ export function PromptGroup({
 		}
 		if (submitBlocker) {
-			toast.error(submitBlocker);
+			if ((draft.hostId ?? machineId) === machineId && !activeHostUrl) {
+				showHostServiceUnavailableToast(hostService, {
+					action: "create the workspace",
</file context>
Suggested change
if ((draft.hostId ?? machineId) === machineId && !activeHostUrl) {
if (submitBlocker === "Host service is not running") {

@greptile-apps

greptile-apps Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces generic "Host service not available" toasts across ~15 call sites with a shared showHostServiceUnavailableToast / getHostServiceUnavailableMessage helper that surfaces the active organization, device ID, process status (starting / running / stopped / unknown), and a tailored recovery hint. It also adds a new getProcessStatus tRPC poll to LocalHostServiceProvider (1 s when disconnected, off when connected) and threads the new fields through CommandContext.

  • New host-service-unavailable.ts utility: centralises message formatting with formatOrganization, formatDevice, and getRecoveryText; all four HostServiceAvailabilityStatus cases are covered.
  • LocalHostServiceProvider extended: exposes activeOrganizationId, activeOrganizationName, and hostServiceStatus derived from the new getProcessStatus query alongside the existing connection query.
  • Batch-submission error enrichment in RunInWorkspacePopoverV2 and RunIssuesInWorkspacePopover: appends the first failure's error detail to the "N of M succeeded" message.

Confidence Score: 4/5

Safe to merge; the changes are largely additive error-message improvements with no data-path mutations, and the new processStatus poll is correctly scoped to when there is no active connection.

All modified call sites follow the same well-understood pattern, and the new utility functions are pure string formatters. The only notable issue is the redundant boolean guard in the batch-submission error detail calculation across two files, which could produce a : undefined suffix if a failure result ever carries no error string. Everything else — context threading, polling logic, and the enriched error paths — looks correct.

RunInWorkspacePopoverV2.tsx and RunIssuesInWorkspacePopover.tsx for the details-expression fix; LocalHostServiceProvider.tsx if the processStatus poll frequency needs tuning in future.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/lib/host-service-unavailable.ts New utility module for enriched host-service error messages and toasts; all enum cases covered, helper functions are well-scoped
apps/desktop/src/renderer/routes/_authenticated/providers/LocalHostServiceProvider/LocalHostServiceProvider.tsx Adds processStatus polling query and exposes activeOrganizationId/Name + hostServiceStatus through context; polling correctly stops when a connection exists; stale processStatus edge case on disconnect is transient (~1s)
apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/components/TasksView/components/TasksTopBar/components/RunInWorkspacePopoverV2/RunInWorkspacePopoverV2.tsx Switches to enriched toast for local host-service failures; adds first-failure error details to batch-submission error — redundant boolean check in details expression
apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/components/TasksView/components/TasksTopBar/components/RunIssuesInWorkspacePopover/RunIssuesInWorkspacePopover.tsx Same batch-submission enrichment as RunInWorkspacePopoverV2; same redundant boolean check in details expression
apps/desktop/src/renderer/stores/workspace-creates/useWorkspaceCreates.ts Replaces plain 'Host service not available' string with contextual message from helper; hostService added to callback dep array
apps/desktop/src/renderer/commandPalette/core/ContextProvider.tsx Threads new host-service context fields through CommandContextProvider; straightforward data plumbing
apps/desktop/src/renderer/routes/_authenticated/components/DashboardNewWorkspaceModal/components/DashboardNewWorkspaceForm/PromptGroup/PromptGroup.tsx Conditions on (draft.hostId ?? machineId) === machineId to gate enriched toast; logic is correct and dependency array is complete
apps/desktop/src/renderer/routes/_authenticated/settings/v2-project/$projectId/components/V2ProjectSettings/components/ProjectLocationSection/ProjectLocationSection.tsx All five host-check paths consistently replaced with showHostServiceUnavailableToast; no issues

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User triggers host-dependent action] --> B{submitBlocker set?}
    B -- No --> C[Proceed with action]
    B -- Yes --> D{hostId === machineId\nAND activeHostUrl null?}
    D -- Yes --> E[showHostServiceUnavailableToast]
    D -- No --> F[toast.error with submitBlocker message]
    E --> G[getHostServiceUnavailableMessage]
    G --> H{activeOrganizationId present?}
    H -- No --> I[Cannot ACTION: no active organization selected]
    H -- Yes --> J[Fetch hostServiceStatus from LocalHostServiceProvider]
    J --> K{processStatus polling\n1s when disconnected,\noff when connected}
    K --> L{status}
    L -- starting --> M[Retry in a few seconds]
    L -- stopped --> N[Use tray menu to restart]
    L -- running --> O[Retry after connection refreshes]
    L -- unknown --> P[Retry; if persists, restart Superset]
Loading

Comments Outside Diff (1)

  1. apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/components/TasksView/components/TasksTopBar/components/RunInWorkspacePopoverV2/RunInWorkspacePopoverV2.tsx, line 252-263 (link)

    P2 The inner !firstFailure.ok guard is always true because find(result => !result.ok) already guarantees it. More importantly, if firstFailure.error is ever undefined (a failure variant with no message), the toast description would literally read "N of M succeeded: undefined". Using optional chaining on .error handles both concerns.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/components/TasksView/components/TasksTopBar/components/RunInWorkspacePopoverV2/RunInWorkspacePopoverV2.tsx
    Line: 252-263
    
    Comment:
    The inner `!firstFailure.ok` guard is always true because `find(result => !result.ok)` already guarantees it. More importantly, if `firstFailure.error` is ever `undefined` (a failure variant with no message), the toast description would literally read "N of M succeeded: undefined". Using optional chaining on `.error` handles both concerns.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/components/TasksView/components/TasksTopBar/components/RunInWorkspacePopoverV2/RunInWorkspacePopoverV2.tsx:252-263
The inner `!firstFailure.ok` guard is always true because `find(result => !result.ok)` already guarantees it. More importantly, if `firstFailure.error` is ever `undefined` (a failure variant with no message), the toast description would literally read "N of M succeeded: undefined". Using optional chaining on `.error` handles both concerns.

```suggestion
		const promise = Promise.all(submissions).then((results) => {
			const failed = results.filter((r) => !r.ok).length;
			if (failed > 0) {
				const firstFailure = results.find((result) => !result.ok);
				const details =
					firstFailure?.error ? `: ${firstFailure.error}` : "";
				throw new Error(
					`${results.length - failed} of ${results.length} succeeded${details}`,
				);
			}
			return results.length;
		});
```

### Issue 2 of 2
apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/components/TasksView/components/TasksTopBar/components/RunIssuesInWorkspacePopover/RunIssuesInWorkspacePopover.tsx:253-258
Same redundant double-check pattern as in `RunInWorkspacePopoverV2``find` already ensures `!result.ok` for the matched element, and an absent `error` value would produce `: undefined` in the error message.

```suggestion
		const promise = Promise.all(submissions).then((results) => {
			const failed = results.filter((r) => !r.ok).length;
			if (failed > 0) {
				const firstFailure = results.find((result) => !result.ok);
				const details =
					firstFailure?.error ? `: ${firstFailure.error}` : "";
```

Reviews (1): Last reviewed commit: "Remove host service unavailable message ..." | Re-trigger Greptile

Comment on lines 253 to +258
const promise = Promise.all(submissions).then((results) => {
const failed = results.filter((r) => !r.ok).length;
if (failed > 0) {
const firstFailure = results.find((result) => !result.ok);
const details =
firstFailure && !firstFailure.ok ? `: ${firstFailure.error}` : "";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Same redundant double-check pattern as in RunInWorkspacePopoverV2find already ensures !result.ok for the matched element, and an absent error value would produce : undefined in the error message.

Suggested change
const promise = Promise.all(submissions).then((results) => {
const failed = results.filter((r) => !r.ok).length;
if (failed > 0) {
const firstFailure = results.find((result) => !result.ok);
const details =
firstFailure && !firstFailure.ok ? `: ${firstFailure.error}` : "";
const promise = Promise.all(submissions).then((results) => {
const failed = results.filter((r) => !r.ok).length;
if (failed > 0) {
const firstFailure = results.find((result) => !result.ok);
const details =
firstFailure?.error ? `: ${firstFailure.error}` : "";
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/renderer/routes/_authenticated/_dashboard/tasks/components/TasksView/components/TasksTopBar/components/RunIssuesInWorkspacePopover/RunIssuesInWorkspacePopover.tsx
Line: 253-258

Comment:
Same redundant double-check pattern as in `RunInWorkspacePopoverV2``find` already ensures `!result.ok` for the matched element, and an absent `error` value would produce `: undefined` in the error message.

```suggestion
		const promise = Promise.all(submissions).then((results) => {
			const failed = results.filter((r) => !r.ok).length;
			if (failed > 0) {
				const firstFailure = results.find((result) => !result.ok);
				const details =
					firstFailure?.error ? `: ${firstFailure.error}` : "";
```

How can I resolve this? If you propose a fix, please make it concise.

@Kitenite Kitenite merged commit cdaba5d into main May 16, 2026
10 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

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