Skip to content

feat: added existing edit modal to create scene#435

Open
hazikchaudhry wants to merge 3 commits into
masterfrom
vps-118-scenario-metadata-should-be-editable-from-create-page
Open

feat: added existing edit modal to create scene#435
hazikchaudhry wants to merge 3 commits into
masterfrom
vps-118-scenario-metadata-should-be-editable-from-create-page

Conversation

@hazikchaudhry

@hazikchaudhry hazikchaudhry commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Issue

Currently the scenario metadata can be edited from the "edit scenario" button on the scenario info page which is accessible from the play page. This is confusing, given that an author would expect to be able to edit that information from the "authoring" section of the app, which is the create page and editor.

Solution

Use the existing modal to used on scene creation and inside scene editor.

was also thinking maybe I should delete the details editing button from the play page, thoughts ?

Risk

Could break on multi user scenario metadata editing. Not sure about this thou, just a thought.

Checklist

  • Acceptance criteria met
  • Wiki documentation is written and up to date
  • Unit tests written and passing
  • Integration tests written and passing
  • Continuous integration build passing

Summary by CodeRabbit

  • New Features
    • You can now set description and estimated time when creating a scenario.
    • You can edit scenario description and estimated time after creation via an “Details” flow.
    • Scenario creation is now done through a modal dialog with a unified details form.
  • Bug Fixes
    • Editing/creation forms now handle missing detail values safely.
    • Added stricter validation for scenario name input (whitespace-only names are rejected).

@linear

linear Bot commented Jul 2, 2026

Copy link
Copy Markdown

VPS-118

@hazikchaudhry
hazikchaudhry requested review from harbassan and leowla July 2, 2026 00:13
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@hazikchaudhry, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 25 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a1198a99-8d51-4730-bae1-c167b4cb2b1c

📥 Commits

Reviewing files that changed from the base of the PR and between 9eb5f4e and d97995d.

📒 Files selected for processing (1)
  • backend/src/routes/api/scenario.js
📝 Walkthrough

Walkthrough

Backend scenario creation and updates now carry validated scenario details, while the frontend uses a shared modal editor for creating and editing scenarios.

Changes

Scenario details create and edit flow

Layer / File(s) Summary
Backend scenario details contract
backend/src/db/daos/scenarioDao.js, backend/src/routes/api/scenario.js
Scenario creation persists description and estimatedTime; create and update routes trim names, reject blank names with HTTP 400, and use centralized async error handling.
Shared detail editor and mutation plumbing
frontend/src/context/ScenarioContextProvider.jsx, frontend/src/features/scenarioInfo/components/DetailEditModal.jsx
Scenario mutations accept full details objects, updates use mutateAsync, and the shared editor supports creation, validation, configurable labels, null-safe fields, and submission state.
Modal-based scenario creation and editing
frontend/src/features/create/CreateLandingPage.jsx, frontend/src/features/authoring/AuthoringToolPage.jsx, frontend/src/features/scenarioInfo/ScenarioInfo.jsx, frontend/src/components/CreateScenarioCard/CreateScenarioCard.jsx
Creation now uses DetailEditModal in a modal, the former CreateScenarioCard is removed, and owned scenarios gain a Details button and edit modal wiring.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • UoaWDCC/VPS#425: Shares ScenarioContextProvider.jsx and modifies scenario-context creation behavior.

Suggested labels: backend

Suggested reviewers: harbassan, leowla, rgin216

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is clearly related to the main change: reusing the edit modal for scenario creation.
Description check ✅ Passed The description includes all required sections and covers the issue, solution, risk, and checklist, though some details are brief.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vps-118-scenario-metadata-should-be-editable-from-create-page

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.

@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: 1

🧹 Nitpick comments (1)
frontend/src/features/scenarioInfo/components/DetailEditModal.jsx (1)

3-8: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a name required-check before allowing submission.

The submit button always calls onSave regardless of field contents. Now that this modal drives scenario creation (scenario={null}), an empty name can be submitted, which will likely fail on the backend (Scenario's name is presumably a required field) with a generic error toast rather than clear inline feedback.

💡 Proposed fix: disable submit when name is blank
         <button
-          onClick={() => onSave({ name, description, estimatedTime })}
+          disabled={!name.trim()}
+          onClick={() => onSave({ name, description, estimatedTime })}
           className={`btn btn-ghost text-base-content border border-base-content/20 hover:bg-base-content/10 hover:border-base-content/40 font-dm`}
         >

Also applies to: 88-93

🤖 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 `@frontend/src/features/scenarioInfo/components/DetailEditModal.jsx` around
lines 3 - 8, The DetailEditModal submit flow currently allows calling onSave
even when the scenario name is empty, which can create invalid submissions when
scenario is null. Update DetailEditModal’s submit handling and the submit button
state so that a blank name is blocked before onSave runs, using the existing
name state in DetailEditModal and any related submit handler/prop wiring. Add a
required-check tied to name so the button is disabled or submission is prevented
until a non-empty name is entered, while keeping the rest of the modal behavior
unchanged.
🤖 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 `@frontend/src/features/authoring/AuthoringToolPage.jsx`:
- Around line 189-202: The Edit Scenario flow in AuthoringToolPage currently
closes the ModalDialog without handling failures from updateScenarioDetails, and
DetailEditModal’s Save action is also triggering native form submit behavior via
method="dialog". Update the onSave path around updateScenarioDetails to await
the async save and surface any rejection with user-visible error handling, and
adjust the DetailEditModal save button behavior so it does not implicitly submit
the dialog form. Keep the modal open on failure and only close it after a
successful save.

---

Nitpick comments:
In `@frontend/src/features/scenarioInfo/components/DetailEditModal.jsx`:
- Around line 3-8: The DetailEditModal submit flow currently allows calling
onSave even when the scenario name is empty, which can create invalid
submissions when scenario is null. Update DetailEditModal’s submit handling and
the submit button state so that a blank name is blocked before onSave runs,
using the existing name state in DetailEditModal and any related submit
handler/prop wiring. Add a required-check tied to name so the button is disabled
or submission is prevented until a non-empty name is entered, while keeping the
rest of the modal behavior unchanged.
🪄 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 Plus

Run ID: eecad49a-431a-4ec8-8555-eba2582fea31

📥 Commits

Reviewing files that changed from the base of the PR and between d31605e and d2ba0e6.

📒 Files selected for processing (7)
  • backend/src/db/daos/scenarioDao.js
  • backend/src/routes/api/scenario.js
  • frontend/src/components/CreateScenarioCard/CreateScenarioCard.jsx
  • frontend/src/context/ScenarioContextProvider.jsx
  • frontend/src/features/authoring/AuthoringToolPage.jsx
  • frontend/src/features/create/CreateLandingPage.jsx
  • frontend/src/features/scenarioInfo/components/DetailEditModal.jsx
💤 Files with no reviewable changes (1)
  • frontend/src/components/CreateScenarioCard/CreateScenarioCard.jsx

Comment thread frontend/src/features/authoring/AuthoringToolPage.jsx Outdated

@harbassan harbassan 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.

nice, looking good. in regards to coderabbit review, rebase your branch to get the share modal changes from master, which you can base the loading state of the modal and owner check for the topbar header on.

Comment thread backend/src/db/daos/scenarioDao.js Outdated
Comment thread frontend/src/features/authoring/AuthoringToolPage.jsx Outdated
@hazikchaudhry
hazikchaudhry force-pushed the vps-118-scenario-metadata-should-be-editable-from-create-page branch from d2ba0e6 to b8bc4bf Compare July 5, 2026 12:14

@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.

🧹 Nitpick comments (2)
frontend/src/features/scenarioInfo/components/DetailEditModal.jsx (2)

22-32: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

No client-side guard against an empty scenario name.

Save/Create is only disabled while isSubmitting; there's no check that name.trim() is non-empty before calling onSave. This is more consequential now that the modal also drives scenario creation — a blank submit would create/save a nameless scenario shown in listings. Consider disabling the action button (or short-circuiting handleSave) when name.trim() is empty.

🤖 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 `@frontend/src/features/scenarioInfo/components/DetailEditModal.jsx` around
lines 22 - 32, The DetailEditModal handleSave flow allows saving with an empty
scenario name, so add a client-side guard using name.trim() before calling
onSave. Update the action button state and/or short-circuit handleSave so
submission stays blocked until a non-empty name is entered, keeping the existing
isSubmitting behavior intact.

22-32: 🗄️ Data Integrity & Integration | 🔵 Trivial

Consider optimistic-concurrency safeguards for metadata edits.

This save path is now reachable from three surfaces (create, authoring, scenario info), increasing the chance two users/tabs edit the same scenario's metadata concurrently. The PR description itself flags this as a known risk. Worth considering a version/updatedAt check (or a "last edited by X" indicator) on the backend update path to avoid silent last-write-wins overwrites, as a follow-up.

🤖 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 `@frontend/src/features/scenarioInfo/components/DetailEditModal.jsx` around
lines 22 - 32, The metadata save flow in DetailEditModal’s handleSave currently
does a blind onSave update, which can silently overwrite concurrent edits from
other users/tabs. Update the backend update path used by onSave to include an
optimistic-concurrency guard such as a version or updatedAt check, and make the
client pass whatever revision metadata is available from the scenario record. If
the check fails, surface a clear conflict state instead of closing the modal,
and keep the DetailEditModal flow aligned with onSave/onClose so users can retry
after reloading.
🤖 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.

Nitpick comments:
In `@frontend/src/features/scenarioInfo/components/DetailEditModal.jsx`:
- Around line 22-32: The DetailEditModal handleSave flow allows saving with an
empty scenario name, so add a client-side guard using name.trim() before calling
onSave. Update the action button state and/or short-circuit handleSave so
submission stays blocked until a non-empty name is entered, keeping the existing
isSubmitting behavior intact.
- Around line 22-32: The metadata save flow in DetailEditModal’s handleSave
currently does a blind onSave update, which can silently overwrite concurrent
edits from other users/tabs. Update the backend update path used by onSave to
include an optimistic-concurrency guard such as a version or updatedAt check,
and make the client pass whatever revision metadata is available from the
scenario record. If the check fails, surface a clear conflict state instead of
closing the modal, and keep the DetailEditModal flow aligned with onSave/onClose
so users can retry after reloading.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 198092ab-d678-4e77-bdf4-2b597289c7dc

📥 Commits

Reviewing files that changed from the base of the PR and between d2ba0e6 and b8bc4bf.

📒 Files selected for processing (8)
  • backend/src/db/daos/scenarioDao.js
  • backend/src/routes/api/scenario.js
  • frontend/src/components/CreateScenarioCard/CreateScenarioCard.jsx
  • frontend/src/context/ScenarioContextProvider.jsx
  • frontend/src/features/authoring/AuthoringToolPage.jsx
  • frontend/src/features/create/CreateLandingPage.jsx
  • frontend/src/features/scenarioInfo/ScenarioInfo.jsx
  • frontend/src/features/scenarioInfo/components/DetailEditModal.jsx
💤 Files with no reviewable changes (1)
  • frontend/src/components/CreateScenarioCard/CreateScenarioCard.jsx
🚧 Files skipped from review as they are similar to previous changes (4)
  • backend/src/routes/api/scenario.js
  • backend/src/db/daos/scenarioDao.js
  • frontend/src/context/ScenarioContextProvider.jsx
  • frontend/src/features/authoring/AuthoringToolPage.jsx

@hazikchaudhry

Copy link
Copy Markdown
Contributor Author

nice, looking good. in regards to coderabbit review, rebase your branch to get the share modal changes from master, which you can base the loading state of the modal and owner check for the topbar header on.

I did rebase and it should be fixed now

@harbassan harbassan 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.

nice, all seems to work perfectly 😄

@leowla leowla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It should not be possible for a user to rename the scenario to nothing

@hazikchaudhry

Copy link
Copy Markdown
Contributor Author

It should not be possible for a user to rename the scenario to nothing

yea that should be fixed now

@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: 1

🤖 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 `@backend/src/routes/api/scenario.js`:
- Around line 71-72: Update both scenario route handlers in
backend/src/routes/api/scenario.js: at lines 71-72, make the POST name
validation require a string before trimming; at lines 114-115, make the PATCH
validation allow undefined but require any provided name to be a string before
trimming. Preserve the existing 400 Bad Request behavior for invalid or blank
names.
🪄 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 Plus

Run ID: ea4f23be-d9db-4f08-874c-bfabfb001adf

📥 Commits

Reviewing files that changed from the base of the PR and between b8bc4bf and 9eb5f4e.

📒 Files selected for processing (2)
  • backend/src/routes/api/scenario.js
  • frontend/src/features/scenarioInfo/components/DetailEditModal.jsx

Comment thread backend/src/routes/api/scenario.js Outdated
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.

3 participants