Skip to content

send JSON object in body instead of uploading edited recipe#174

Open
ascibisz wants to merge 4 commits intomainfrom
feature/pass-json-recipe
Open

send JSON object in body instead of uploading edited recipe#174
ascibisz wants to merge 4 commits intomainfrom
feature/pass-json-recipe

Conversation

@ascibisz
Copy link
Contributor

@ascibisz ascibisz commented Jan 14, 2026

Problem

In an effort to improve the efficiency of our packings, we want to remove the step where we're posting the edited recipe to firebase from the client and instead send the edited recipe JSON to the server in the body of the POST request, and then the server will handle any necessary firebase interactions.

Part of this ticket

Note: Deploy PR with server side changes before merging this PR.

Solution

  • Send the edited recipe in the body of the POST request, don't upload it to firebase
  • Remove unused gradients from JSON recipe before sending to server (so server can better assess whether the edited recipe actually matches that of a previous run)
  • Change retention policy for JOB_STATUS firebase collection to improve re-usability of previous job runs

@github-actions
Copy link

github-actions bot commented Jan 14, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 33.64% 679 / 2018
🔵 Statements 33.64% 679 / 2018
🔵 Functions 40.19% 41 / 102
🔵 Branches 74.01% 151 / 204
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
src/App.tsx 0% 0% 0% 0% 1-6, 15-18, 20, 22-23, 25-35, 37, 39-41, 43-49, 51-65, 67-84, 86-94, 96-115, 119, 121-140, 142-146, 148-152, 154-174, 176, 178
src/components/InputSwitch/index.tsx 0% 0% 0% 0% 1-2, 9-11, 27-28, 30-33, 37, 40-42, 44-55, 58, 61-63, 65-68, 70-74, 76-83, 85-122, 124, 126-144, 146, 148-155, 157, 159, 161-173, 175-177, 179
src/constants/aws.ts 0% 100% 100% 0% 2, 5, 7-20, 22-24, 26-28, 31-37
src/constants/firebase.ts 100% 100% 100% 100%
src/state/store.ts 62.92% 67.64% 22.5% 62.92% 100, 112, 160, 190-191, 202, 206-213, 216-232, 254, 258, 263-267, 270-274, 277-281, 284-288, 291-294, 297-300, 303, 307-309, 312-314, 317-319, 322-325, 328-331, 334-344, 347-350, 354, 359, 362, 364, 366
src/utils/firebase.ts 64.24% 75% 71.42% 64.24% 40-43, 82-92, 103-116, 119-123, 134-135, 222-232, 234-243, 245, 247-251, 253-258
src/utils/recipeLoader.ts 95.98% 92.04% 100% 95.98% 21, 29-30, 41, 56-57, 61-62, 201-202, 344-345
Generated in workflow #244

@github-actions
Copy link

github-actions bot commented Jan 14, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://AllenCell.github.io/cellpack-client/pr-preview/pr-174/

Built to branch gh-pages at 2026-03-11 21:06 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@ascibisz ascibisz force-pushed the feature/pass-json-recipe branch from 00f3d24 to 38be27f Compare February 25, 2026 21:16
RETENTION_PERIODS: {
RECIPES_EDITED: 24 * 60 * 60 * 1000, // 24 hours
JOB_STATUS: 24 * 60 * 60 * 1000, // 24 hours
JOB_STATUS: 30 * 24 * 60 * 60 * 1000, // 30 days
Copy link
Contributor Author

Choose a reason for hiding this comment

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

since we're re-using results from previous job runs now using the job_status collection, we want to increase it's retention policy

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the step of uploading edited recipes to Firebase, instead sending the recipe JSON directly in the POST request body to the server. It also cleans up unused gradients from the recipe before sending, and extends the JOB_STATUS retention policy to support re-use of previous job runs.

Changes:

  • Send edited recipe JSON in POST body instead of uploading to Firebase; remove addRecipe function
  • Strip unreferenced gradients from recipe in recipeToString before sending to server
  • Extend JOB_STATUS retention from 24 hours to 30 days and update timestamp after reading final status

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/App.tsx Remove Firebase upload flow; send recipe in POST body; update job status timestamp after completion
src/utils/recipeLoader.ts Rename jsonToString to recipeToString with gradient cleanup logic
src/utils/firebase.ts Remove addRecipe, add updateJobStatusTimestamp, replace setDoc with updateDoc
src/constants/aws.ts Make recipe param optional in getSubmitPackingUrl
src/constants/firebase.ts Extend JOB_STATUS retention to 30 days
src/components/InputSwitch/index.tsx Reduce numeric display precision from 4 to 2 decimal places
src/test/recipeLoader.test.ts Update to use renamed recipeToString
src/test/test-files/ER_peroxisome.json Remove unreferenced gradients from test fixture

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (typeof value == "number") {
value = value * conversion;
value = Number(value.toFixed(4));
value = Number(value.toFixed(2));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously, we were keeping 4 digits after the decimal point and it was getting cut off in the box on the form. It feels like 2 digits after the decimal point is sufficient?

ascibisz and others added 4 commits March 11, 2026 14:05
* set retention for job status to 30 days, update job status timestamp on read, and misc bug fixes

* code cleanup
* remove irrelevant gradient data from final recipe string

* round radius to 2 decimal points

* update test file to remove unnecessary gradients

* copilot suggestions
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ascibisz ascibisz force-pushed the feature/pass-json-recipe branch from b2cfeb8 to f960773 Compare March 11, 2026 21:05
@ascibisz ascibisz marked this pull request as ready for review March 19, 2026 18:24
Comment on lines +60 to +65
const firebaseRecipe = recipeChanged
? undefined
: "firebase:recipes/" + recipeId;
const firebaseConfig = configId
? "firebase:configs/" + configId
: undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

double check if this is still necessary

Copy link
Contributor

@interim17 interim17 left a comment

Choose a reason for hiding this comment

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

Consider encoding the url so it handle special characters, otherwise LGTM

Comment on lines +11 to +17
let url = SUBMIT_PACKING_ECS;
if (recipe && config) {
url += `?recipe=${recipe}&config=${config}`;
} else if (recipe) {
url += `?recipe=${recipe}`;
} else if (config) {
url += `?config=${config}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Safer to encode with this API as long as the result works on the backend: https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/URLSearchParams

Comment on lines +68 to +69
const requestBody = recipeChanged ? recipeString : undefined;
const request: RequestInfo = new Request(url, { method: "POST", body: requestBody });
Copy link
Contributor

Choose a reason for hiding this comment

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

Content-Type: application/json?

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