Skip to content

Commit

Permalink
chore: small tweaks for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Dec 23, 2024
1 parent 74e78cb commit 8f9ff1b
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 36 deletions.
4 changes: 2 additions & 2 deletions apiclient/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ type TaskRunOptions struct {
func (c *Client) RunTask(ctx context.Context, taskID string, input string, opts TaskRunOptions) (*types.TaskRun, error) {
var url string
if opts.ThreadID != "" {
url = fmt.Sprintf("/threads/%s/tasks/%s/runs", opts.ThreadID, taskID)
url = fmt.Sprintf("/threads/%s/tasks/%s/run", opts.ThreadID, taskID)
} else {
url = fmt.Sprintf("/assistants/%s/tasks/%s/runs", opts.AssistantID, taskID)
url = fmt.Sprintf("/assistants/%s/tasks/%s/run", opts.AssistantID, taskID)
}

_, resp, err := c.postJSON(ctx, url, input)
Expand Down
10 changes: 5 additions & 5 deletions ui/user/src/lib/actions/div.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { tick } from 'svelte';

export function autoscroll(node: HTMLElement) {
const observer = new MutationObserver(() => {
if (node.dataset.scroll !== 'false') {
if (node.dataset.autoscroll !== 'false') {
tick().then(() => {
node.scrollTop = node.scrollHeight;
});
Expand All @@ -17,11 +17,11 @@ export function autoscroll(node: HTMLElement) {
const scrollHeight = node.scrollHeight;
const clientHeight = node.clientHeight;

// Check if the user has scrolled to the bottom
if (scrollTop + clientHeight >= scrollHeight) {
node.dataset.scroll = 'true';
// Check if the user has scrolled to withing 40px of the bottom
if (scrollHeight - (scrollTop + clientHeight) <= 40) {
node.dataset.autoscroll = 'true';
} else {
node.dataset.scroll = 'false';
node.dataset.autoscroll = 'false';
}
});
}
6 changes: 4 additions & 2 deletions ui/user/src/lib/actions/popover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface Popover extends Readable<boolean> {
interface PopoverOptions extends Partial<ComputePositionConfig> {
hover?: boolean;
assign?: (x: number, y: number) => void;
offset?: number;
}

let id = 0;
Expand All @@ -28,6 +29,7 @@ export default function popover(opts?: PopoverOptions): Popover {
let ref: HTMLElement;
let tooltip: HTMLElement;
const open = writable(false);
const offsetSize = opts?.offset ?? 8;

function build(): ActionReturn | void {
if (!ref || !tooltip) return;
Expand All @@ -45,9 +47,9 @@ export default function popover(opts?: PopoverOptions): Popover {
middleware: [
flip(),
shift({
padding: 8
padding: offsetSize
}),
offset(8)
offset(offsetSize)
],
...opts
}).then(({ x, y }) => {
Expand Down
9 changes: 7 additions & 2 deletions ui/user/src/lib/components/Thread.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
let { assistant = '' }: Props = $props();
let messages: Messages = $state({ messages: [], inProgress: false });
let thread: Thread | undefined = $state<Thread>();
let messagesDiv = $state<HTMLDivElement>();
$effect(() => {
if (!assistant || thread) {
Expand Down Expand Up @@ -45,7 +46,8 @@

<div>
<div
class="flex h-screen w-full justify-center overflow-auto transition-all scrollbar-none"
bind:this={messagesDiv}
class="flex h-dvh w-full justify-center overflow-auto transition-all scrollbar-none"
use:autoscroll
>
<div class="flex w-full max-w-[900px] flex-col px-8 pt-24 transition-all">
Expand All @@ -66,7 +68,10 @@
onAbort={async () => {
await thread?.abort();
}}
onSubmit={async (i) => await thread?.invoke(i)}
onSubmit={async (i) => {
messagesDiv?.scrollTo({ top: messagesDiv?.scrollHeight });
await thread?.invoke(i)
}}
/>
</div>
</div>
4 changes: 2 additions & 2 deletions ui/user/src/lib/components/editor/Controls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="flex">
{#if $editorMaxSize}
<button
class="icon-button"
class="icon-button hidden md:block"
onclick={() => {
editorMaxSize.set(false);
}}
Expand All @@ -30,7 +30,7 @@
</button>
{:else}
<button
class="icon-button"
class="icon-button hidden md:block"
onclick={() => {
editorMaxSize.set(true);
}}
Expand Down
1 change: 0 additions & 1 deletion ui/user/src/lib/components/messages/Message.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
{#snippet files()}
{#if msg.file?.filename}
<div
onclick={fileLoad}
role="none"
class="m-5 flex cursor-pointer flex-col
divide-y divide-gray-300
Expand Down
40 changes: 21 additions & 19 deletions ui/user/src/lib/components/navbar/Menu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
let { onLoad, icon, body, title, description, show }: Props = $props();
let loading = $state(false);
const { ref, tooltip, toggle, open } = popover({
placement: 'bottom'
placement: 'bottom',
offset: 0
});
$effect(() => {
Expand Down Expand Up @@ -61,25 +62,26 @@
{@render icon()}
</button>

<div
use:tooltip
class="flex w-96 flex-col divide-y
divide-gray-200
rounded-3xl
bg-gray-50 p-6 shadow dark:divide-gray-700 dark:bg-gray-950"
>
<div class="mb-4">
<div class="flex justify-between">
{title}
{#if onLoad}
<button onclick={load}>
<RotateCw class="h-4 w-4 {loading ? 'animate-spin' : ''}" />
</button>
<div use:tooltip class="w-screen md:w-96 px-2" >
<div
class="flex w-full flex-col divide-y
divide-gray-200
rounded-3xl
bg-gray-50 p-6 shadow dark:divide-gray-700 dark:bg-gray-950"
>
<div class="mb-4">
<div class="flex justify-between">
{title}
{#if onLoad}
<button onclick={load}>
<RotateCw class="h-4 w-4 {loading ? 'animate-spin' : ''}" />
</button>
{/if}
</div>
{#if description}
<p class="mt-1 text-xs font-normal text-gray-700 dark:text-gray-300">{description}</p>
{/if}
</div>
{#if description}
<p class="mt-1 text-xs font-normal text-gray-700 dark:text-gray-300">{description}</p>
{/if}
{@render body()}
</div>
{@render body()}
</div>
7 changes: 7 additions & 0 deletions ui/user/src/lib/services/editor/index.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ async function loadFile(
modified: false,
selected: true
};
for (let i = 0; i < items.length; i++) {
if (items[i].id === targetFile.id) {
items[i] = targetFile;
select(targetFile.id);
return;
}
}
items.push(targetFile);
select(targetFile.id);
} catch {
Expand Down
2 changes: 1 addition & 1 deletion ui/user/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<div
bind:this={div}
class="relative hidden h-screen w-full items-center text-black dark:text-white"
class="relative hidden h-dvh w-full items-center text-black dark:text-white"
>
<div
class="absolute right-0 top-0 flex items-center gap-4 p-4 pr-6 text-white hover:text-blue-50"
Expand Down
3 changes: 2 additions & 1 deletion ui/user/src/routes/[agent]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
const editorMaxSize = EditorService.maxSize;
let title = $derived($currentAssistant.name ?? '');
let splitWindow = $derived(editorVisible && !$editorMaxSize);
$effect(() => {
if ($profile.unauthorized) {
Expand All @@ -36,7 +37,7 @@
</div>

{#if $editorVisible}
<div class="pt-20 transition-all {$editorMaxSize ? 'w-full' : 'w-1/2'} h-screen">
<div class="pt-20 transition-all w-full {splitWindow ? 'md:w-3/5' : ''}" >
<Editor />
</div>
{/if}
Expand Down
2 changes: 1 addition & 1 deletion ui/user/src/routes/login_complete/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
</script>

<main id="main-content" class="flex h-screen justify-center">
<main id="main-content" class="flex h-dvh justify-center">
<div class="relative mt-32 text-center">
<img src="/images/obot-icon-blue.svg" alt="Assistant logo" class="mx-auto mb-4 h-72 w-72" />
<h1 class="my-4 text-6xl font-extrabold text-black dark:text-gray-100">All Set!</h1>
Expand Down

0 comments on commit 8f9ff1b

Please sign in to comment.