diff --git a/CHANGELOG.md b/CHANGELOG.md index 304da937a..2a747ff97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -116,6 +116,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f - **No blank band above the composer on phones either.** Scrolling to the newest message could also shift the message area itself up, leaving an empty band above the composer until the page was reloaded. Scrolling can no longer shift the message area (Safari 16 and later; older Safari keeps the old behavior). - **Sending to a session another omp process has open no longer leaves a dead fork.** When omp moved the resumed session to a new file during startup, the tab kept the old id, the event stream failed with "Failed to connect to the agent event stream", the prompt never went, and the forked session was reaped two minutes later. The requested id now stays routable alongside the new one. - **Changing Advisor keeps a moved session on the right conversation.** A tab still using the pre-move session ID now restarts the current session file on its owning host when toggling Advisor, instead of reopening the original file, selecting another host’s copy, or returning “Session not found” if the original was removed. +- **Workspace profile names are validated before they can break sessions.** The profile inputs show the naming rule and reject invalid names, and the API rejects invalid profiles and reserved launch arguments. Existing invalid profiles and reserved arguments remain visible in the workspace launch configuration; an updated host daemon refuses to start a session until they are corrected or cleared, instead of silently switching profiles or passing an orphan argument. Update remote host daemons as well: older versions do not enforce this spawn-time check. --- diff --git a/app/api/projects/route.ts b/app/api/projects/route.ts index af286fef5..612fff9c3 100644 --- a/app/api/projects/route.ts +++ b/app/api/projects/route.ts @@ -1,4 +1,5 @@ import { apiErrorResponse, opErrorResponse, resolveHostOrError } from "@/lib/api-utils"; +import { isValidOmpProfile } from "@/lib/omp-profile"; import { allowFileRoot } from "@/lib/file-access"; import { LOCAL_HOST_ID } from "@/lib/hosts/registry"; import { listProjectsAllHosts } from "@/lib/hosts/session-index"; @@ -15,7 +16,7 @@ function parseLaunchConfig(value: unknown): ProjectLaunchConfig | undefined { const raw = value as Record; const profile = raw.profile === undefined ? undefined : typeof raw.profile === "string" && raw.profile.trim() ? raw.profile.trim() : undefined; if (raw.profile !== undefined && !profile) throw new ProjectPathError("invalid_profile", "Profile must be a non-empty string"); - if (profile?.startsWith("-")) throw new ProjectPathError("invalid_profile", "Profile must not start with '-'"); + if (profile !== undefined && !isValidOmpProfile(profile)) throw new ProjectPathError("invalid_profile", "Profile names must match ^[a-z0-9][a-z0-9._-]{0,63}$, cannot end with '.', and cannot be a Windows reserved device name (CON, PRN, AUX, NUL, COM0-9, LPT0-9, or any of those with an extension)"); const advisor = raw.advisor === undefined ? undefined : raw.advisor; if (advisor !== undefined && typeof advisor !== "boolean") throw new ProjectPathError("invalid_advisor", "Advisor must be a boolean"); if (raw.extraArgs !== undefined && (!Array.isArray(raw.extraArgs) || raw.extraArgs.length > MAX_EXTRA_ARGS)) throw new ProjectPathError("invalid_extra_args", "Extra args must contain at most 32 arguments"); diff --git a/components/DirectoryPicker.tsx b/components/DirectoryPicker.tsx index 54807ed2f..f01a7d92f 100644 --- a/components/DirectoryPicker.tsx +++ b/components/DirectoryPicker.tsx @@ -3,6 +3,7 @@ import { FormEvent, useCallback, useEffect, useRef, useState } from "react"; import { createPortal } from "react-dom"; import { useModalDialog } from "@/hooks/useModalDialog"; +import { isValidOmpProfile } from "@/lib/omp-profile"; import { useI18n } from "@/lib/i18n"; import { formatApiError } from "@/lib/i18n/api-error"; import { appendProgress, cloneDirectoryName } from "@/lib/git-clone"; @@ -134,7 +135,8 @@ export function DirectoryPicker({ onCancel, onSelect, busy = false, error, host const hasUncommittedPath = pathInput.trim() !== currentPath; const cloneName = cloneUrl.trim() ? cloneDirectoryName(cloneUrl) : null; const cloneTarget = cloneName && currentPath ? `${currentPath.replace(/[\\/]+$/, "")}${currentPath.includes("\\") ? "\\" : "/"}${cloneName}` : null; - const canSelect = Boolean(currentPath) && !loading && !hasUncommittedPath && !locked && (!cloneUrl.trim() || cloneName !== null); + const profileInvalid = profile.trim() !== "" && !isValidOmpProfile(profile.trim()); + const canSelect = Boolean(currentPath) && !loading && !hasUncommittedPath && !locked && (!cloneUrl.trim() || cloneName !== null) && !profileInvalid; const goDisabled = loading || locked || !pathInput.trim(); const canNavigateUp = !locked && (Boolean(parentDirectory) || isWindowsDriveRoot(currentPath)); const submitSelection = async () => { @@ -359,7 +361,10 @@ export function DirectoryPicker({ onCancel, onSelect, busy = false, error, host {cloneLog.replace(/\r/g, "")} )} - setProfile(event.target.value)} placeholder={t("directoryPicker.profilePlaceholder")} aria-label={t("directoryPicker.profileLabel")} style={{ width: "100%", height: 30, boxSizing: "border-box", marginBottom: 7, padding: "0 8px", background: "var(--bg-panel)", border: "1px solid var(--border)", borderRadius: 6, color: "var(--text)", fontFamily: "var(--font-mono)", fontSize: 11 }} /> + setProfile(event.target.value)} placeholder={t("directoryPicker.profilePlaceholder")} aria-label={t("directoryPicker.profileLabel")} aria-invalid={profileInvalid || undefined} style={{ width: "100%", height: 30, boxSizing: "border-box", marginBottom: profileInvalid || profile.trim() ? 3 : 7, padding: "0 8px", background: "var(--bg-panel)", border: `1px solid ${profileInvalid ? "var(--status-error)" : "var(--border)"}`, borderRadius: 6, color: "var(--text)", fontFamily: "var(--font-mono)", fontSize: 11 }} /> + {profileInvalid + ?
{t("projectLaunchConfig.profileInvalid")}
+ : profile.trim() ?
{t("projectLaunchConfig.profileRule")}
: null}