Skip to content
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

[editor] Support Deleting Prompt #665

Merged
merged 2 commits into from
Dec 29, 2023
Merged

[editor] Support Deleting Prompt #665

merged 2 commits into from
Dec 29, 2023

Conversation

rholinshead
Copy link
Contributor

@rholinshead rholinshead commented Dec 29, 2023

[editor] Support Deleting Prompt

[editor] Support Deleting Prompt

Add the UI side for deleting a prompt, with placeholder to call the server endpoint once it's implemented

Screen.Recording.2023-12-28.at.9.33.24.PM.mov

Stack created with Sapling. Best reviewed with ReviewStack.

@rossdanlm
Copy link
Contributor

placeholder to call the server endpoint once it's implemented

I thought Jonathan added the delete_prompt endpoint on the backend here? #595

Comment on lines +2 to +9
import {
Container,
Group,
Button,
createStyles,
Stack,
Flex,
} from "@mantine/core";
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on my understanding from your response in #640 (comment), this is just fancy colors around base components right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For mantine in general? Think of it more like XDS - it's a component library that gives a lot of out-of-the-box functionality and common styles that can be easily updated across the components

id: promptId,
};

dispatch(action);
Copy link
Contributor

Choose a reason for hiding this comment

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

why not inline action to stay consistent with #662 ?

case "DELETE_PROMPT": {
return {
...state,
prompts: state.prompts.filter((prompt) => prompt._ui.id !== action.id),
Copy link
Contributor

@rossdanlm rossdanlm Dec 29, 2023

Choose a reason for hiding this comment

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

Why do we need to nest this extra _ui.id field instead of using id directly in

export type ClientPrompt = Prompt & {
_ui: {
id: string;
};

Copy link
Contributor Author

@rholinshead rholinshead Dec 29, 2023

Choose a reason for hiding this comment

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

I think it makes it really clear that there's a UI-only distinction between ClientPrompt and Prompt and makes it clearer to reason about for conversion between the two where needed (we should remove UI-only state like this so it's not propagated to the config on disk)

# [editor] Model Selector

Implement the model selector and add a placeholder call to the future api endpoint for updating the model.


https://github.com/lastmile-ai/aiconfig/assets/5060851/812f3a10-aaac-4ec3-9f1f-4d21ebc99e9f
@rossdanlm
Copy link
Contributor

This is also super nit and not a blocker, but noticed from the Figma file that there's no clear way of deleting a cell. I personally feel like having it on the left is unintuitive (since most systems have action menu on the top right), but yea not a blocker, just wanted to point out it seems strange to me

Screenshot 2023-12-29 at 10 30 02

Comment on lines +345 to +346
<PromptMenuButton
promptId={prompt._ui.id}
onDeletePrompt={() => onDeletePrompt(prompt._ui.id)}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yea left comment (#665 (comment)) how I said this feels a bit weird it being on the left instead of right, but yea not a big deal

Copy link
Contributor

Choose a reason for hiding this comment

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

But also why not put this within the prompt container?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just a design thing, it's not in the figma designs so just went with how it is in workbooks right now. We can update later

@@ -107,7 +107,7 @@ export default memo(function PromptContainer({
const { classes } = useStyles();

return (
<Flex justify="space-between" mt="md">
Copy link
Contributor

Choose a reason for hiding this comment

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

Very quickly, what does the mt field mean in typescript components?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's margin-top in supported mantine components

Comment on lines 7 to 10
marginLeft: -8,
[theme.fn.smallerThan("sm")]: {
float: "left",
marginTop: -2,
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels kind of strange to use negative margins (and kind of related to my question about why not put this within the prompt container itself), but yea not a big deal

zIndex: 99,
"&:hover": {
backgroundColor:
theme.colorScheme === "dark"
Copy link
Contributor

Choose a reason for hiding this comment

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

Very cool, but is this not supported automatically? Ex: at FB we have color.primary, color.emphasized, etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya, this was copied over from workbooks as well. I can double-check if it's even needed. Mantine does have auto-styling already based on theme so not sure what this was intended for there

const { classes } = useStyles();

return (
<Menu position="bottom-end">
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: could we wrap this inside of a more visible border/box container? It feels now a bit like the Delete Prompt dropdown item is just sort of floating below without firmly being connected to the three vertical dots icon
Screenshot 2023-12-29 at 10 37 55

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uh, not sure off the top of my head how to do that. But since this placement/UI isn't final anyway I'll hold off on anything for this

@rholinshead
Copy link
Contributor Author

placeholder to call the server endpoint once it's implemented

I thought Jonathan added the delete_prompt endpoint on the backend here? #595

Ah, right, let me hook it up and update

</Button>
</Menu.Target>

<Menu.Dropdown>
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be clear, is Menu.Dropdown automatically maintaining it's state to be visible or not based on whether you've clicked the Menu.Target component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

Copy link
Contributor

@rossdanlm rossdanlm left a comment

Choose a reason for hiding this comment

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

lgtm, just some minor nits, can be fixed forward

# [editor] Support Deleting Prompt

Add the UI side for deleting a prompt, with placeholder to call the server endpoint once it's implemented


https://github.com/lastmile-ai/aiconfig/assets/5060851/b3e682dd-a3ed-45c1-b153-b4b6e2094616
@rholinshead
Copy link
Contributor Author

Made changes:

  • connect to the endpoint to delete the prompt in the config server-side
  • remove unnecessary styles (mainly "sm" screen size for button)

@rholinshead rholinshead merged commit 8c35024 into main Dec 29, 2023
2 checks passed
@rossdanlm rossdanlm deleted the pr665 branch December 29, 2023 16:07
rholinshead added a commit that referenced this pull request Dec 29, 2023
[editor] Run Prompt (non-streaming)

# [editor] Run Prompt (non-streaming)

With non-streaming /run endpoint properly returning the response now, we
can update the client config with the resulting output. We can also
leverage the client-side `_ui` state for maintaining 'isRunning' state
to show a spinner / disable the execute button for now (TODO: we may
need to handle canceling execution as well).



https://github.com/lastmile-ai/aiconfig/assets/5060851/67fa793a-9a60-4285-a7d1-69fff633d6a6

---
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with
[ReviewStack](https://reviewstack.dev/lastmile-ai/aiconfig/pull/667).
* __->__ #667
* #666
* #665
* #662
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.

2 participants