Spaces:
				
			
			
	
			
			
					
		Running
		
			on 
			
			CPU Upgrade
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
			on 
			
			CPU Upgrade
	
		Thomas G. Lopes
		
	commited on
		
		
					Commit 
							
							·
						
						0ce274f
	
1
								Parent(s):
							
							7991bc0
								
improve auto scroll
Browse files
    	
        package.json
    CHANGED
    
    | @@ -41,7 +41,7 @@ | |
| 41 | 
             
            		"prettier": "^3.1.1",
         | 
| 42 | 
             
            		"prettier-plugin-svelte": "^3.2.6",
         | 
| 43 | 
             
            		"prettier-plugin-tailwindcss": "^0.6.11",
         | 
| 44 | 
            -
            		"runed": "^0. | 
| 45 | 
             
            		"svelte": "^5.20.4",
         | 
| 46 | 
             
            		"svelte-check": "^4.0.0",
         | 
| 47 | 
             
            		"tailwind-merge": "^3.0.2",
         | 
|  | |
| 41 | 
             
            		"prettier": "^3.1.1",
         | 
| 42 | 
             
            		"prettier-plugin-svelte": "^3.2.6",
         | 
| 43 | 
             
            		"prettier-plugin-tailwindcss": "^0.6.11",
         | 
| 44 | 
            +
            		"runed": "^0.25.0",
         | 
| 45 | 
             
            		"svelte": "^5.20.4",
         | 
| 46 | 
             
            		"svelte-check": "^4.0.0",
         | 
| 47 | 
             
            		"tailwind-merge": "^3.0.2",
         | 
    	
        pnpm-lock.yaml
    CHANGED
    
    | @@ -97,8 +97,8 @@ importers: | |
| 97 | 
             
                    specifier: ^0.6.11
         | 
| 98 | 
             
                    version: 0.6.11(prettier-plugin-svelte@3.3.3(prettier@3.5.3)(svelte@5.23.0))(prettier@3.5.3)
         | 
| 99 | 
             
                  runed:
         | 
| 100 | 
            -
                    specifier: ^0. | 
| 101 | 
            -
                    version: 0. | 
| 102 | 
             
                  svelte:
         | 
| 103 | 
             
                    specifier: ^5.20.4
         | 
| 104 | 
             
                    version: 5.23.0
         | 
| @@ -1861,8 +1861,8 @@ packages: | |
| 1861 | 
             
                peerDependencies:
         | 
| 1862 | 
             
                  svelte: ^5.7.0
         | 
| 1863 |  | 
| 1864 | 
            -
              runed@0. | 
| 1865 | 
            -
                resolution: {integrity: sha512- | 
| 1866 | 
             
                peerDependencies:
         | 
| 1867 | 
             
                  svelte: ^5.7.0
         | 
| 1868 |  | 
| @@ -3731,7 +3731,7 @@ snapshots: | |
| 3731 | 
             
                  esm-env: 1.2.2
         | 
| 3732 | 
             
                  svelte: 5.23.0
         | 
| 3733 |  | 
| 3734 | 
            -
              runed@0. | 
| 3735 | 
             
                dependencies:
         | 
| 3736 | 
             
                  esm-env: 1.2.2
         | 
| 3737 | 
             
                  svelte: 5.23.0
         | 
|  | |
| 97 | 
             
                    specifier: ^0.6.11
         | 
| 98 | 
             
                    version: 0.6.11(prettier-plugin-svelte@3.3.3(prettier@3.5.3)(svelte@5.23.0))(prettier@3.5.3)
         | 
| 99 | 
             
                  runed:
         | 
| 100 | 
            +
                    specifier: ^0.25.0
         | 
| 101 | 
            +
                    version: 0.25.0(svelte@5.23.0)
         | 
| 102 | 
             
                  svelte:
         | 
| 103 | 
             
                    specifier: ^5.20.4
         | 
| 104 | 
             
                    version: 5.23.0
         | 
|  | |
| 1861 | 
             
                peerDependencies:
         | 
| 1862 | 
             
                  svelte: ^5.7.0
         | 
| 1863 |  | 
| 1864 | 
            +
              runed@0.25.0:
         | 
| 1865 | 
            +
                resolution: {integrity: sha512-7+ma4AG9FT2sWQEA0Egf6mb7PBT2vHyuHail1ie8ropfSjvZGtEAx8YTmUjv/APCsdRRxEVvArNjALk9zFSOrg==}
         | 
| 1866 | 
             
                peerDependencies:
         | 
| 1867 | 
             
                  svelte: ^5.7.0
         | 
| 1868 |  | 
|  | |
| 3731 | 
             
                  esm-env: 1.2.2
         | 
| 3732 | 
             
                  svelte: 5.23.0
         | 
| 3733 |  | 
| 3734 | 
            +
              runed@0.25.0(svelte@5.23.0):
         | 
| 3735 | 
             
                dependencies:
         | 
| 3736 | 
             
                  esm-env: 1.2.2
         | 
| 3737 | 
             
                  svelte: 5.23.0
         | 
    	
        src/lib/components/debug-menu.svelte
    CHANGED
    
    | @@ -9,6 +9,7 @@ | |
| 9 | 
             
            	import type { ToastData } from "./toaster.svelte.js";
         | 
| 10 | 
             
            	import { addToast } from "./toaster.svelte.js";
         | 
| 11 | 
             
            	import { models } from "$lib/state/models.svelte";
         | 
|  | |
| 12 |  | 
| 13 | 
             
            	let innerWidth = $state<number>();
         | 
| 14 | 
             
            	let innerHeight = $state<number>();
         | 
| @@ -25,6 +26,13 @@ | |
| 25 | 
             
            	};
         | 
| 26 |  | 
| 27 | 
             
            	const actions: Action[] = [
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 28 | 
             
            		{ label: "Toggle Theme", cb: toggleTheme },
         | 
| 29 | 
             
            		{
         | 
| 30 | 
             
            			label: "Log session to console",
         | 
|  | |
| 9 | 
             
            	import type { ToastData } from "./toaster.svelte.js";
         | 
| 10 | 
             
            	import { addToast } from "./toaster.svelte.js";
         | 
| 11 | 
             
            	import { models } from "$lib/state/models.svelte";
         | 
| 12 | 
            +
            	import { last } from "$lib/utils/array.js";
         | 
| 13 |  | 
| 14 | 
             
            	let innerWidth = $state<number>();
         | 
| 15 | 
             
            	let innerHeight = $state<number>();
         | 
|  | |
| 26 | 
             
            	};
         | 
| 27 |  | 
| 28 | 
             
            	const actions: Action[] = [
         | 
| 29 | 
            +
            		{
         | 
| 30 | 
            +
            			label: "Set long text",
         | 
| 31 | 
            +
            			cb: () => {
         | 
| 32 | 
            +
            				const conv = session.project.conversations[0]!;
         | 
| 33 | 
            +
            				last(conv.messages)!.content = "This is a lot of text. ".repeat(10000);
         | 
| 34 | 
            +
            			},
         | 
| 35 | 
            +
            		},
         | 
| 36 | 
             
            		{ label: "Toggle Theme", cb: toggleTheme },
         | 
| 37 | 
             
            		{
         | 
| 38 | 
             
            			label: "Log session to console",
         | 
    	
        src/lib/components/inference-playground/conversation.svelte
    CHANGED
    
    | @@ -1,11 +1,12 @@ | |
| 1 | 
             
            <script lang="ts">
         | 
| 2 | 
             
            	import type { Conversation } from "$lib/types.js";
         | 
| 3 |  | 
|  | |
|  | |
|  | |
| 4 | 
             
            	import IconPlus from "~icons/carbon/add";
         | 
| 5 | 
             
            	import CodeSnippets from "./code-snippets.svelte";
         | 
| 6 | 
             
            	import Message from "./message.svelte";
         | 
| 7 | 
            -
            	import { ScrollState } from "$lib/spells/scroll-state.svelte";
         | 
| 8 | 
            -
            	import { watch } from "runed";
         | 
| 9 |  | 
| 10 | 
             
            	interface Props {
         | 
| 11 | 
             
            		conversation: Conversation;
         | 
| @@ -20,13 +21,20 @@ | |
| 20 | 
             
            		element: () => messageContainer,
         | 
| 21 | 
             
            		offset: { bottom: 100 },
         | 
| 22 | 
             
            	});
         | 
|  | |
| 23 |  | 
| 24 | 
             
            	watch(
         | 
| 25 | 
             
            		() => conversation.messages.at(-1)?.content,
         | 
| 26 | 
             
            		() => {
         | 
| 27 | 
            -
            			const shouldScroll =  | 
| 28 | 
             
            			if (!shouldScroll) return;
         | 
| 29 | 
            -
            			 | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 30 | 
             
            		}
         | 
| 31 | 
             
            	);
         | 
| 32 |  | 
|  | |
| 1 | 
             
            <script lang="ts">
         | 
| 2 | 
             
            	import type { Conversation } from "$lib/types.js";
         | 
| 3 |  | 
| 4 | 
            +
            	import { ScrollState } from "$lib/spells/scroll-state.svelte";
         | 
| 5 | 
            +
            	import { watch } from "runed";
         | 
| 6 | 
            +
            	import { tick } from "svelte";
         | 
| 7 | 
             
            	import IconPlus from "~icons/carbon/add";
         | 
| 8 | 
             
            	import CodeSnippets from "./code-snippets.svelte";
         | 
| 9 | 
             
            	import Message from "./message.svelte";
         | 
|  | |
|  | |
| 10 |  | 
| 11 | 
             
            	interface Props {
         | 
| 12 | 
             
            		conversation: Conversation;
         | 
|  | |
| 21 | 
             
            		element: () => messageContainer,
         | 
| 22 | 
             
            		offset: { bottom: 100 },
         | 
| 23 | 
             
            	});
         | 
| 24 | 
            +
            	const atBottom = $derived(scrollState.arrived.bottom);
         | 
| 25 |  | 
| 26 | 
             
            	watch(
         | 
| 27 | 
             
            		() => conversation.messages.at(-1)?.content,
         | 
| 28 | 
             
            		() => {
         | 
| 29 | 
            +
            			const shouldScroll = atBottom && !scrollState.isScrolling;
         | 
| 30 | 
             
            			if (!shouldScroll) return;
         | 
| 31 | 
            +
            			try {
         | 
| 32 | 
            +
            				tick().then(() => {
         | 
| 33 | 
            +
            					scrollState.scrollToBottom();
         | 
| 34 | 
            +
            				});
         | 
| 35 | 
            +
            			} catch {
         | 
| 36 | 
            +
            				// noop
         | 
| 37 | 
            +
            			}
         | 
| 38 | 
             
            		}
         | 
| 39 | 
             
            	);
         | 
| 40 |  | 
