akanjs 3.3.0-rc.28 → 3.3.0-rc.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/ui/Agent/Chat.tsx +65 -46
- package/ui/Agent/useKeyboardFrame.ts +4 -2
package/package.json
CHANGED
package/ui/Agent/Chat.tsx
CHANGED
|
@@ -125,8 +125,9 @@ const launcherSides = {
|
|
|
125
125
|
const launcherHiddenBelow = { sm: "max-sm:hidden", md: "max-md:hidden", lg: "max-lg:hidden" } as const;
|
|
126
126
|
|
|
127
127
|
const panelLayer = "fixed inset-0 sm:inset-auto sm:right-4 sm:bottom-4";
|
|
128
|
+
|
|
128
129
|
const panelSize =
|
|
129
|
-
"h-
|
|
130
|
+
"h-[calc(100dvh-var(--akan-keyboard-cover,0px))] w-screen rounded-none pt-[max(var(--akan-top-safe-area,0px),env(safe-area-inset-top,0px))] pb-[max(var(--akan-bottom-safe-area,0px),env(safe-area-inset-bottom,0px))] [html[data-akan-keyboard]_&]:pb-0 sm:h-[min(600px,calc(100dvh-2rem))] sm:w-[min(24rem,calc(100vw-2rem))] sm:rounded-box sm:pt-0 sm:pb-0";
|
|
130
131
|
|
|
131
132
|
const stickyEdge = 80;
|
|
132
133
|
|
|
@@ -483,6 +484,16 @@ const ChatPanel = ({
|
|
|
483
484
|
sticky,
|
|
484
485
|
title,
|
|
485
486
|
}: ChatPanelProps) => {
|
|
487
|
+
|
|
488
|
+
useEffect(() => {
|
|
489
|
+
const list = listRef.current;
|
|
490
|
+
if (!list || typeof ResizeObserver === "undefined") return;
|
|
491
|
+
const observer = new ResizeObserver(() => {
|
|
492
|
+
if (sticky.current && !list.hasAttribute("data-akan-keyboard-glide")) list.scrollTop = list.scrollHeight;
|
|
493
|
+
});
|
|
494
|
+
observer.observe(list);
|
|
495
|
+
return () => observer.disconnect();
|
|
496
|
+
}, []);
|
|
486
497
|
const clear = () => {
|
|
487
498
|
files.clear();
|
|
488
499
|
queue.take();
|
|
@@ -517,59 +528,67 @@ const ChatPanel = ({
|
|
|
517
528
|
/>
|
|
518
529
|
) : null}
|
|
519
530
|
<div
|
|
520
|
-
|
|
521
|
-
aria-live="polite"
|
|
522
|
-
className="scrollbar-thin flex flex-1 flex-col gap-2 overflow-y-auto px-4 py-3"
|
|
531
|
+
className="scrollbar-thin flex flex-1 flex-col overflow-y-auto px-4 py-3"
|
|
523
532
|
onScroll={() => {
|
|
524
533
|
const list = listRef.current;
|
|
525
534
|
if (list) sticky.current = list.scrollHeight - list.scrollTop - list.clientHeight < stickyEdge;
|
|
526
535
|
}}
|
|
527
536
|
ref={listRef}
|
|
528
|
-
role="log"
|
|
529
537
|
>
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
538
|
+
<div
|
|
539
|
+
aria-busy={session.isRunning}
|
|
540
|
+
aria-live="polite"
|
|
541
|
+
className="flex flex-col gap-2"
|
|
542
|
+
data-akan-keyboard-ride="inset"
|
|
543
|
+
role="log"
|
|
544
|
+
>
|
|
545
|
+
{bubbles.length
|
|
546
|
+
? bubbles
|
|
547
|
+
: (intro ?? <p className="py-6 text-center text-foreground/40 text-sm">{l("base.agentIntro")}</p>)}
|
|
548
|
+
{session.isCompacting ? (
|
|
549
|
+
<p className="flex items-center gap-2 text-foreground/50 text-xs">
|
|
550
|
+
<span className="size-1.5 shrink-0 animate-pulse rounded-full bg-primary" />
|
|
551
|
+
{l("base.agentSummarizing")}
|
|
552
|
+
</p>
|
|
553
|
+
) : null}
|
|
554
|
+
</div>
|
|
539
555
|
</div>
|
|
540
556
|
<ChatPendingCards portal={inline ? layers.enclosingPortal : layers.cardOverlays} session={session} />
|
|
541
|
-
{
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
557
|
+
{/* In an app the panel keeps the whole screen while the keys are up, as a native chat does, and this rides them. */}
|
|
558
|
+
<div className="shrink-0" data-akan-keyboard-overlay="" data-akan-keyboard-ride="">
|
|
559
|
+
{queue.queued ? (
|
|
560
|
+
<Queued message={queue.queued} onCancel={() => queue.take()} onEdit={composer.unpark} />
|
|
561
|
+
) : null}
|
|
562
|
+
<Menu
|
|
563
|
+
onPick={(row) => row.pick()}
|
|
564
|
+
prefix={composer.list === composer.menu ? "/" : "@"}
|
|
565
|
+
rows={composer.list.rows}
|
|
566
|
+
selected={composer.list.selected}
|
|
567
|
+
/>
|
|
568
|
+
<Composer
|
|
569
|
+
attached={files.attached}
|
|
570
|
+
pending={files.pending}
|
|
571
|
+
draft={draft}
|
|
572
|
+
handleRef={handleRef}
|
|
573
|
+
inputRef={inputRef}
|
|
574
|
+
isMenuOpen={!!composer.list.at()}
|
|
575
|
+
mentions={mentions}
|
|
576
|
+
{...(speech.canListen ? { mic: { listening: speech.listening, onToggle: speech.toggle } } : {})}
|
|
577
|
+
onDraft={composer.write}
|
|
578
|
+
onFiles={(picked) => void files.add(picked)}
|
|
579
|
+
onKeyDown={composer.onKeyDown}
|
|
580
|
+
onRemoveFile={files.remove}
|
|
581
|
+
onRemoveReference={refs.remove}
|
|
582
|
+
onSend={composer.send}
|
|
583
|
+
references={refs.references}
|
|
584
|
+
onStop={() => {
|
|
585
|
+
speech.silence();
|
|
586
|
+
composer.unpark();
|
|
587
|
+
session.abort();
|
|
588
|
+
}}
|
|
589
|
+
session={session}
|
|
590
|
+
/>
|
|
591
|
+
</div>
|
|
573
592
|
</OverlayPortalProvider>
|
|
574
593
|
</aside>
|
|
575
594
|
{inline ? null : <PanelOverlayHosts asking={isAsking(session)} {...layers.overlayHosts} />}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { breakpointQuery } from "akanjs/client";
|
|
2
|
+
import { breakpointQuery, isPageKeyboardAvoidance } from "akanjs/client";
|
|
3
3
|
import { useVisualViewportFrame } from "akanjs/webkit";
|
|
4
4
|
import type { CSSProperties } from "react";
|
|
5
5
|
|
|
6
6
|
export const useKeyboardFrame = (): CSSProperties | undefined => {
|
|
7
7
|
const { keyboardHeight, height, offsetTop } = useVisualViewportFrame();
|
|
8
8
|
if (typeof window === "undefined") return undefined;
|
|
9
|
+
|
|
10
|
+
if (isPageKeyboardAvoidance()) return undefined;
|
|
9
11
|
if (window.matchMedia(breakpointQuery("sm", { below: true })).matches)
|
|
10
|
-
return height < window.innerHeight ? { top: offsetTop, bottom: "auto", height } : undefined;
|
|
12
|
+
return height < window.innerHeight ? { top: offsetTop, bottom: "auto", height, paddingBottom: 0 } : undefined;
|
|
11
13
|
return keyboardHeight ? { paddingBottom: keyboardHeight } : undefined;
|
|
12
14
|
};
|