-
Notifications
You must be signed in to change notification settings - Fork 12
Fix: Fix creation bugs to make slug unique. #149
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,4 +42,4 @@ export async function request<T>(obj: T, path: string, method: string): Promise< | |
| } | ||
|
|
||
| return res | ||
| } | ||
| } | ||
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
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 |
|---|---|---|
|
|
@@ -13,16 +13,18 @@ import {ScriptContext} from "@/contexts/script"; | |
| import AssistantNotFound from "@/components/assistant-not-found" | ||
|
|
||
| interface ScriptProps { | ||
| className?: string | ||
| messagesHeight?: string | ||
| className?: string | ||
| messagesHeight?: string | ||
| enableThreads?: boolean | ||
| showAssistantName?: boolean | ||
| } | ||
|
|
||
| const Script: React.FC<ScriptProps> = ({ className, messagesHeight = 'h-full', enableThreads }) => { | ||
| const Script: React.FC<ScriptProps> = ({ className, messagesHeight = 'h-full', enableThreads, showAssistantName }) => { | ||
| const inputRef = useRef<HTMLInputElement>(null); | ||
| const [inputValue, setInputValue] = useState<string>(""); | ||
| const { | ||
| script, | ||
| scriptDisplayName, | ||
| tool, | ||
| showForm, | ||
| setShowForm, | ||
|
|
@@ -99,9 +101,11 @@ const Script: React.FC<ScriptProps> = ({ className, messagesHeight = 'h-full', e | |
|
|
||
| return ( | ||
| <div className={`h-full w-full ${className}`}> | ||
| {showAssistantName && <h1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| className="px-6 pt-10 text-2xl font-medium truncate">{scriptDisplayName ?? ''}</h1>} | ||
| {(connected && running) || (showForm && hasParams) ? (<> | ||
| <div | ||
| id="small-message" | ||
| id="small-message" | ||
| className={`px-6 pt-10 overflow-y-auto w-full items-center ${messagesHeight}`} | ||
| > | ||
| {showForm && hasParams ? ( | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import React from "react"; | |
| import {Popover, PopoverTrigger, PopoverContent, Button, Input} from "@nextui-org/react"; | ||
| import { VscNewFile } from "react-icons/vsc"; | ||
| import { GoPaperAirplane, GoPersonAdd } from "react-icons/go"; | ||
| import { createScript, getNewScriptName, getScript } from "@/actions/me/scripts"; | ||
| import { createScript, getScript } from "@/actions/me/scripts"; | ||
|
|
||
| const newDefaultAssistant = (name: string): string => { | ||
| return ` | ||
|
|
@@ -17,22 +17,22 @@ export default function Create() { | |
| const [loading, setLoading] = React.useState(false); | ||
|
|
||
| const handleSubmit = async () => { | ||
| getNewScriptName() | ||
| .then((name) => { | ||
| createScript({ | ||
| displayName: name, | ||
| visibility: "private", | ||
| content: newDefaultAssistant(name), | ||
| }).then((script) => { | ||
| getScript(`${script.id}`) | ||
| .then((script) => | ||
| window.location.href = `/edit?file=${script?.publicURL}&id=${script?.id}` | ||
| ); | ||
| }) | ||
| }) | ||
| const defaultName = "New Assistant"; | ||
| const slug = defaultName.toLowerCase().replace(" ", "-") + "-" + Math.random().toString(36).substring(2, 7); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic of creating a unique slug per assistant by appending random 5 charaters. |
||
| createScript({ | ||
| displayName: defaultName, | ||
| slug, | ||
| visibility: "private", | ||
| content: newDefaultAssistant(defaultName), | ||
| }).then((script) => { | ||
| getScript(`${script.id}`) | ||
| .then((script) => | ||
| window.location.href = `/edit?file=${script?.publicURL}&id=${script?.id}` | ||
| ); | ||
| }) | ||
| }; | ||
|
|
||
|
|
||
| return ( | ||
| <Button | ||
| isLoading={loading} | ||
|
|
||
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
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.
The logic of magically delecting assistant name is removed. Right now it defaults to
New Assistantwhere user can have multiple.