Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e07c9c6
use object instead of string as single source of truth
interim17 Nov 10, 2025
2decf90
Merge branch 'feature/show-precomputed-results-tweaks' of https://git…
interim17 Nov 10, 2025
3a02c07
use displayName
interim17 Nov 10, 2025
0c886b5
split manifest into RecipeMetadata and RecipeData and refactor prefet…
interim17 Nov 11, 2025
ed152a6
add second call of editRecipe for gradient value
interim17 Nov 11, 2025
adbd622
Merge branch 'feature/ssot-refactor' of https://github.com/mesoscope/…
interim17 Nov 11, 2025
df1c6df
Apply suggestion from @Copilot
interim17 Nov 11, 2025
fc79530
Apply suggestion from @Copilot
interim17 Nov 11, 2025
22a5672
Apply suggestion from @Copilot
interim17 Nov 11, 2025
5d3a689
Apply suggestions from code review
interim17 Nov 11, 2025
9de4abf
move building current recipe object from util into selector
interim17 Nov 11, 2025
656b14a
Merge branch 'main' of https://github.com/mesoscope/cellpack-client i…
interim17 Nov 11, 2025
faf266d
revert to using utility to build recipe objects
interim17 Nov 12, 2025
9fd8319
Merge branch 'feature/ssot-refactor' into fix/prefetch
interim17 Nov 12, 2025
fb23431
fix merge artifact
interim17 Nov 12, 2025
8f5f11a
add documenting comment to buildRecipeObject
interim17 Nov 12, 2025
98e37c5
Merge branch 'main' of https://github.com/mesoscope/cellpack-client i…
interim17 Nov 13, 2025
f6f6dca
rename and adjust typing of recipe object utility
interim17 Nov 13, 2025
d5e6f1c
wrap loading text in container to position it
interim17 Nov 13, 2025
725b614
RecipeMetadata -> RecipeManifest
interim17 Nov 13, 2025
fe4a840
defaultRecipeData -> defaultRecipe
interim17 Nov 13, 2025
2e789a4
Merge branch 'feature/ssot-refactor' of https://github.com/mesoscope/…
interim17 Nov 13, 2025
f23c4fa
fix defaultRecipe naming
interim17 Nov 13, 2025
3442ed7
Merge branch 'main' of https://github.com/AllenCell/cellpack-client i…
meganrm Nov 13, 2025
273c4e1
Merge branch 'main' of https://github.com/AllenCell/cellpack-client i…
meganrm Nov 13, 2025
b832ba2
dont export locally used hooks
meganrm Nov 13, 2025
efa33c5
remove error from merge conflict
meganrm Nov 13, 2025
73b06cb
Update src/state/store.ts
meganrm Nov 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/Dropdown/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { Select } from "antd";
import { map } from "lodash-es";
import { Dictionary, RecipeManifest } from "../../types";
import { Dictionary, RecipeMetadata } from "../../types";

interface DropdownProps {
placeholder: string;
defaultValue?: string;
options: Dictionary<RecipeManifest>;
options: Dictionary<RecipeMetadata>;
Copy link
Contributor

Choose a reason for hiding this comment

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

personally I still like the term manifest but I'm not super attached to it. it's what we use in other apps like CFE for this same type of data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh sure I like manifest too, for some reason I thought you said at our 1:1 that you wanted it called metadata.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, I think I was just using that as a category term, sorry!

onChange: (value: string) => void;
}

const Dropdown = (props: DropdownProps): JSX.Element => {
const { placeholder, options, onChange, defaultValue } = props;
const selectOptions = map(options, (opt, key) => ({
label: opt.name || key,
value: opt.recipe,
label: opt.displayName || key,
value: opt.recipeId,
}));

return (
Expand Down
16 changes: 5 additions & 11 deletions src/components/GradientInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { Select, Slider, InputNumber } from "antd";
import { GradientOption } from "../../types";
import {
useSelectedRecipeId,
useUpdateRecipeObj,
useGetCurrentValue,
useCurrentRecipeString,
useEditRecipe,
} from "../../state/store";
import { getSelectedGradient, deriveGradientStrength, round2, toStore } from "../../utils/gradient";
import "./style.css";
Expand All @@ -19,10 +18,8 @@ interface GradientInputProps {
const GradientInput = (props: GradientInputProps): JSX.Element => {
const { displayName, description, gradientOptions, defaultValue } = props;
const selectedRecipeId = useSelectedRecipeId();
const updateRecipeObj = useUpdateRecipeObj();
const editRecipe = useEditRecipe();
const getCurrentValue = useGetCurrentValue();
// Force re-render after restore/navigation
useCurrentRecipeString();

const { currentGradient, selectedOption } = getSelectedGradient(
gradientOptions,
Expand All @@ -36,20 +33,17 @@ const GradientInput = (props: GradientInputProps): JSX.Element => {
if (!selectedRecipeId) return;
const selectedOption = gradientOptions.find(option => option.value === value);
if (!selectedOption || !selectedOption.path) return;

// Make changes to JSON recipe
const changes: Record<string, string | number> = {[selectedOption.path]: value};
if (selectedOption.packing_mode && selectedOption.packing_mode_path) {
changes[selectedOption.packing_mode_path] = selectedOption.packing_mode;
editRecipe(selectedRecipeId, selectedOption.packing_mode_path, selectedOption.packing_mode);
}
updateRecipeObj(selectedRecipeId, changes);
editRecipe(selectedRecipeId, selectedOption.path, value);
};

const handleStrengthChange = (val: number | null) => {
if (val == null || !selectedRecipeId || !gradientStrengthData) return;
const uiVal = round2(val);
const storeVal = toStore(uiVal);
updateRecipeObj(selectedRecipeId, { [gradientStrengthData.path]: storeVal });
editRecipe(selectedRecipeId, gradientStrengthData.path, storeVal);
};

const selectOptions = gradientOptions.map((option) => ({
Expand Down
12 changes: 6 additions & 6 deletions src/components/InputSwitch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { Input, InputNumber, Select, Slider } from "antd";
import { GradientOption } from "../../types";
import {
useSelectedRecipeId,
useUpdateRecipeObj,
useGetCurrentValue,
useCurrentRecipeString,
useEditRecipe,
useRecipes,
} from "../../state/store";
import GradientInput from "../GradientInput";
import "./style.css";
Expand All @@ -28,9 +28,9 @@ const InputSwitch = (props: InputSwitchProps): JSX.Element => {
const { displayName, inputType, dataType, description, min, max, options, id, gradientOptions, conversionFactor, unit } = props;

const selectedRecipeId = useSelectedRecipeId();
const updateRecipeObj = useUpdateRecipeObj();
const editRecipe = useEditRecipe();
const getCurrentValue = useGetCurrentValue();
const recipeVersion = useCurrentRecipeString();
const recipes = useRecipes();

// Conversion factor for numeric inputs where we want to display a
// different unit in the UI than is stored in the recipe
Expand Down Expand Up @@ -59,7 +59,7 @@ const InputSwitch = (props: InputSwitchProps): JSX.Element => {
// Reset local state when store value (or recipe) changes
useEffect(() => {
setValue(getCurrentValueMemo());
}, [getCurrentValueMemo, recipeVersion]);
}, [getCurrentValueMemo, recipes]);

const handleInputChange = (value: string | number | null) => {
if (value == null || !selectedRecipeId) return;
Expand All @@ -68,7 +68,7 @@ const InputSwitch = (props: InputSwitchProps): JSX.Element => {
// Convert back to original units for updating recipe object
value = value / conversion;
}
updateRecipeObj(selectedRecipeId, { [id]: value });
editRecipe(selectedRecipeId, id, value);
};

switch (inputType) {
Expand Down
9 changes: 3 additions & 6 deletions src/components/JSONViewer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import {
returnOneElement,
} from "./formattingUtils";
import "./style.css";
import { ViewableRecipe } from "../../types";

interface JSONViewerProps {
title: string;
content: string;
isEditable: boolean;
onChange: (value: string) => void;
content?: ViewableRecipe;
}

const JSONViewer = (props: JSONViewerProps): JSX.Element | null => {
Expand All @@ -22,8 +21,6 @@ const JSONViewer = (props: JSONViewerProps): JSX.Element | null => {
return null;
}

const contentAsObj = JSON.parse(content);

// descriptions for top level key-value pairs
const descriptions: DescriptionsItemProps[] = [];
// trees for nested objects like 'objects', 'composition', 'gradients'
Expand All @@ -44,7 +41,7 @@ const JSONViewer = (props: JSONViewerProps): JSX.Element | null => {
};

// top level objects, like name, bounding_box, etc.
Object.entries(contentAsObj).forEach(([key, value]) => {
Object.entries(content).forEach(([key, value]) => {
if (typeof value === "string") {
descriptions.push({
label: convertUnderscoreToSpace(key),
Expand Down
53 changes: 22 additions & 31 deletions src/components/PackingInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ import { Tabs } from "antd";

import {
useSelectedRecipeId,
useCurrentRecipeString,
useFieldsToDisplay,
useInputOptions,
useIsLoading,
useLoadInputOptions,
useSelectRecipe,
useUpdateRecipeString,
useStartPacking,
useLoadAllRecipes,
useCurrentRecipeObject,
useInputOptions,
useLoadInputOptions,
} from "../../state/store";
import Dropdown from "../Dropdown";
import JSONViewer from "../JSONViewer";
Expand All @@ -29,15 +26,12 @@ interface PackingInputProps {
const PackingInput = (props: PackingInputProps): JSX.Element => {
const { startPacking } = props;
const selectedRecipeId = useSelectedRecipeId();
const recipeString = useCurrentRecipeString();
const fieldsToDisplay = useFieldsToDisplay();
const recipeObj = useCurrentRecipeObject();
const inputOptions = useInputOptions();
const isLoading = useIsLoading();

const loadInputOptions = useLoadInputOptions();
const loadAllRecipes = useLoadAllRecipes();
const selectRecipe = useSelectRecipe();
const updateRecipeString = useUpdateRecipeString();
const storeStartPacking = useStartPacking();

const preFetchInputsAndRecipes = useCallback(async () => {
Expand All @@ -54,15 +48,12 @@ const PackingInput = (props: PackingInputProps): JSX.Element => {
await storeStartPacking(startPacking);
};

const handleRecipeStringChange = (newString: string) => {
if (selectedRecipeId) {
updateRecipeString(selectedRecipeId, newString);
}
};
const loadingText = (<div>Loading...</div>)

if (isLoading) {
return <div>Loading...</div>;
}
// No recipe or dropdown options to load
if (!recipeObj && !inputOptions[selectedRecipeId]) {
return loadingText;
}

return (
<>
Expand All @@ -75,19 +66,19 @@ const PackingInput = (props: PackingInputProps): JSX.Element => {
onChange={selectRecipe}
/>
</div>
<Tabs defaultActiveKey="1" className="recipe-content">
<Tabs.TabPane tab="Edit" key="1">
<RecipeForm onStartPacking={handleStartPacking} />
</Tabs.TabPane>
<Tabs.TabPane tab="Full Recipe" key="2">
<JSONViewer
title="Recipe"
content={recipeString}
isEditable={fieldsToDisplay === undefined}
onChange={handleRecipeStringChange}
/>
</Tabs.TabPane>
</Tabs>
{/* Options menu loaded, but no recipe to load yet */}
{!recipeObj ? (
loadingText
) : (
<Tabs defaultActiveKey="1" className="recipe-content">
<Tabs.TabPane tab="Edit" key="1">
<RecipeForm onStartPacking={handleStartPacking} />
</Tabs.TabPane>
<Tabs.TabPane tab="Full Recipe" key="2">
<JSONViewer title="Recipe" content={recipeObj} />
</Tabs.TabPane>
</Tabs>
)}
Comment on lines +70 to +81
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There isn't a good reason to prevent this panel from loading once the first recipe has been fetched, but I figured showing the loading marker was in line with our overall design pattern, and it should only be visible very briefly if the user selects a recipe right after the dropdown populates.

</>
);
};
Expand Down
Loading