Repository navigation
fix(projects): validate OMP profile names before they reach the spawn #343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import "../tests/setup-dom.mjs"; | ||
| import assert from "node:assert/strict"; | ||
| import React from "react"; | ||
| import test, { afterEach } from "node:test"; | ||
| const { render, cleanup, fireEvent, waitFor } = await import("@testing-library/react/pure.js"); | ||
| const { ProjectLaunchConfigDialog } = await import("./ProjectLaunchConfigDialog.tsx"); | ||
| const { translate } = await import("../lib/i18n/index.tsx"); | ||
| afterEach(cleanup); | ||
|
|
||
| test("the launch editor exposes legacy values and saves an explicit correction or clear", async () => { | ||
| const saved = []; | ||
| const props = { projectPath: "/workspace", initialConfig: { profile: "nova insight", extraArgs: ["--profile", "work"] }, onClose() {}, onSave: async (config) => { saved.push(config); } }; | ||
| const view = render(React.createElement(ProjectLaunchConfigDialog, props)); | ||
| const profile = view.getByDisplayValue("nova insight"); | ||
| const args = view.getByRole("textbox", { name: translate("projectLaunchConfig.extraArgsLabel") }); | ||
| assert.equal(args.value, "--profile\nwork"); | ||
| const save = view.getByRole("button", { name: translate("projectLaunchConfig.save") }); | ||
| assert.equal(profile.getAttribute("aria-invalid"), "true"); | ||
| assert.equal(save.disabled, true); | ||
| fireEvent.change(profile, { target: { value: "work" } }); | ||
| fireEvent.change(args, { target: { value: "--verbose" } }); | ||
| fireEvent.click(save); | ||
| await waitFor(() => assert.deepEqual(saved[0], { profile: "work", advisor: undefined, extraArgs: ["--verbose"] })); | ||
| await waitFor(() => assert.equal(save.disabled, false)); | ||
| fireEvent.change(profile, { target: { value: "" } }); | ||
| fireEvent.change(args, { target: { value: "" } }); | ||
| await waitFor(() => assert.equal(save.disabled, false)); | ||
| fireEvent.click(save); | ||
| await waitFor(() => assert.equal(saved[1], null)); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import "../tests/setup-dom.mjs"; | ||
| import assert from "node:assert/strict"; | ||
| import React from "react"; | ||
| import test from "node:test"; | ||
| const { render, cleanup, fireEvent, screen, waitFor } = await import("@testing-library/react/pure.js"); | ||
| const { SessionSidebar } = await import("./SessionSidebar.tsx"); | ||
| const { toast } = await import("./ui/toast.tsx"); | ||
| const { translate } = await import("../lib/i18n/index.tsx"); | ||
|
|
||
| test("failed workspace rename is reported without an unhandled rejection; failed launch save stays open", async () => { | ||
| const original = { fetch: globalThis.fetch, Worker: globalThis.Worker, SharedWorker: globalThis.SharedWorker, matchMedia: window.matchMedia, error: toast.error }; | ||
| const errors = []; | ||
| const writes = []; | ||
| globalThis.Worker = class { postMessage() {} }; | ||
| globalThis.SharedWorker = undefined; | ||
| window.matchMedia = () => ({ matches: false, addEventListener() {}, removeEventListener() {} }); | ||
| toast.error = (message) => { errors.push(message); }; | ||
| globalThis.fetch = async (input, init = {}) => { | ||
| const url = new URL(String(input), "http://localhost"); | ||
| if (url.pathname === "/api/projects") { | ||
| if (init.method === "PATCH") { | ||
| writes.push(JSON.parse(init.body)); | ||
| return Response.json({ error: "Workspace update refused", code: "workspace_write_refused" }, { status: 400 }); | ||
| } | ||
| return Response.json({ projects: [{ path: "/workspace", launchConfig: { profile: "work" } }] }); | ||
| } | ||
| if (url.pathname === "/api/sessions") return Response.json({ sessions: [] }); | ||
| return Response.json({}); | ||
| }; | ||
| try { | ||
| render(React.createElement(SessionSidebar, { | ||
| selectedSessionId: null, selectedCwd: "/workspace", skipInitialProjectSelection: true, | ||
| onSelectSession() {}, addProjectOpen: false, setAddProjectOpen() {}, usageVisible: false, | ||
| })); | ||
| await waitFor(() => assert.ok(screen.getByTitle("/workspace"))); | ||
| fireEvent.click(screen.getByRole("button", { name: translate("commandPalette.actions") })); | ||
| fireEvent.click(screen.getByRole("menuitem", { name: translate("projects.nameAlias") })); | ||
| const alias = screen.getByRole("textbox", { name: translate("projects.aliasPrompt") }); | ||
| fireEvent.change(alias, { target: { value: "New name" } }); | ||
| fireEvent.keyDown(alias, { key: "Enter" }); | ||
| await waitFor(() => assert.deepEqual(errors, ["Workspace update refused"])); | ||
| assert.equal(writes[0].alias, "New name"); | ||
| assert.ok(screen.getByTitle("/workspace"), "the failed rename does not replace the displayed workspace"); | ||
|
|
||
| fireEvent.click(screen.getByRole("button", { name: translate("commandPalette.actions") })); | ||
| fireEvent.click(screen.getByRole("menuitem", { name: translate("sessionSidebar.editLaunchConfig") })); | ||
| fireEvent.click(screen.getByRole("button", { name: translate("projectLaunchConfig.save") })); | ||
| await waitFor(() => assert.equal(errors.length, 2)); | ||
| assert.equal(writes[1].launchConfig.profile, "work"); | ||
| await waitFor(() => assert.equal(screen.getByRole("alert").textContent, "Workspace update refused")); | ||
| assert.ok(screen.getByRole("button", { name: translate("projectLaunchConfig.save") }), "the dialog remains open for correction or retry"); | ||
| } finally { | ||
| cleanup(); | ||
| globalThis.fetch = original.fetch; | ||
| globalThis.Worker = original.Worker; | ||
| globalThis.SharedWorker = original.SharedWorker; | ||
| window.matchMedia = original.matchMedia; | ||
| toast.error = original.error; | ||
| } | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: kahme247/ompweb
Length of output: 5663
Script executed:
Repository: kahme247/ompweb
Length of output: 12298
Restore scrolling in the launch-config dialog so Save and Cancel stay reachable.
DialogContentincomponents/ProjectLaunchConfigDialog.tsxpassesoverflow: "hidden". That value overrides the primitive'soverflow: "auto", so the popup cannot scroll. On a short viewport, the form content can exceed the popup's maximum height, and the footer with Save and Cancel is clipped. The new profile hint or alert line makes this clipping occur on taller viewports than before.Suggested fix