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

AI update #45

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 0 additions & 23 deletions app/api/auth/callback/route.ts

This file was deleted.

77 changes: 0 additions & 77 deletions app/api/chat/route.ts

This file was deleted.

42 changes: 0 additions & 42 deletions app/share/[id]/page.tsx

This file was deleted.

44 changes: 0 additions & 44 deletions components/chat-list.tsx

This file was deleted.

79 changes: 0 additions & 79 deletions components/chat-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export function ChatPanel({ messages }: ChatPanelProps) {
const router = useRouter()

const searchParam = useSearchParams()
const isIframe = searchParam.get('isIframe') === "true"

const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault()
Expand Down Expand Up @@ -74,84 +73,6 @@ export function ChatPanel({ messages }: ChatPanelProps) {
)
}
return (
isIframe ?
<div
className={
'fixed bottom-0 left-0 right-0 w-full max-h-screen flex mx-auto flex-col items-center justify-end py-10'
}
>
<form onSubmit={handleSubmit} className="max-w-2xl w-full px-6">
<EmptyScreen
submitMessage={message => {
setInput(message)
}}
className={cn(showEmptyScreen ? 'visible' : 'invisible')}
/>
<div className="relative flex items-center w-full">
<Textarea
ref={inputRef}
name="input"
rows={1}
maxRows={5}
tabIndex={0}
placeholder="Ask a question..."
spellCheck={false}
value={input}
className="resize-none w-full min-h-12 rounded-fill bg-muted border border-input pl-4 pr-10 pt-3 pb-1 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50'"
onChange={e => {
setInput(e.target.value)
setShowEmptyScreen(e.target.value.length === 0)
}}
onKeyDown={e => {
// Enter should submit the form
if (
e.key === 'Enter' &&
!e.shiftKey &&
!e.nativeEvent.isComposing
) {
// Prevent the default action to avoid adding a new line
if (input.trim().length === 0) {
e.preventDefault()
return
}
e.preventDefault()
const textarea = e.target as HTMLTextAreaElement
textarea.form?.requestSubmit()
}
}}
onHeightChange={height => {
// Ensure inputRef.current is defined
if (!inputRef.current) return

// The initial height and left padding is 70px and 2rem
const initialHeight = 70
// The initial border radius is 32px
const initialBorder = 32
// The height is incremented by multiples of 20px
const multiple = (height - initialHeight) / 20

// Decrease the border radius by 4px for each 20px height increase
const newBorder = initialBorder - 4 * multiple
// The lowest border radius will be 8px
inputRef.current.style.borderRadius =
Math.max(8, newBorder) + 'px'
}}
onFocus={() => setShowEmptyScreen(true)}
onBlur={() => setShowEmptyScreen(false)}
/>
<Button
type="submit"
size={'icon'}
variant={'ghost'}
className="absolute right-2 top-1/2 transform -translate-y-1/2"
disabled={input.length === 0}
>
<ArrowRight size={20} />
</Button>
</div>

</form>
</div> :
<div
className={
'fixed bottom-8 left-0 right-0 top-10 mx-auto h-screen flex flex-col items-center justify-center'
Expand Down
Loading