Skip to content

Commit

Permalink
Svelte => SvelteKit (stitionai#17)
Browse files Browse the repository at this point in the history
* deleted old svelte files; initialized sveltekit project; moved api.js and store.js to src/lib; moved ui/public/assets to ui/static/assets

* moved components to src/lib

* src/App.svelte => src/routes/+page.svelte; fixed imports ()

* added /components

* src/routes/+layout.js: ssr = false (temporary fix for xterm not working in ssr context)

* moved Sidebar to +layout.svelte so that it's persistent across pages; made Sidebar a fixed element (fixed top-0 left-0 h-dvh z-10)

* force added api.js & store.js

---------

Co-authored-by: Vivek R <[email protected]>
  • Loading branch information
TheoIsDumb and 123vivekr authored Mar 23, 2024
1 parent 68f3dd4 commit c246fa7
Show file tree
Hide file tree
Showing 37 changed files with 182 additions and 166 deletions.
Binary file removed ui/.DS_Store
Binary file not shown.
9 changes: 9 additions & 0 deletions ui/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
.DS_Store
node_modules/
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
pnpm-lock.yaml
1 change: 1 addition & 0 deletions ui/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
Binary file modified ui/bun.lockb
Binary file not shown.
13 changes: 0 additions & 13 deletions ui/index.html

This file was deleted.

48 changes: 18 additions & 30 deletions ui/package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,26 @@
{
"name": "devika-ui",
"version": "1.0.0",
"description": "",
"main": "index.js",
"name": "ui",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite",
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"autoprefixer": "^10.4.16",
"postcss": "^8.4.32",
"postcss-load-config": "^5.0.2",
"svelte": "^4.2.7",
"tailwindcss": "^3.3.6",
"vite": "^5.0.3"
},
"type": "module",
"dependencies": {
"@babel/core": "^7.24.1",
"@babel/preset-env": "^7.24.1",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"autoprefixer": "latest",
"css-loader": "^6.10.0",
"mini-css-extract-plugin": "^2.8.1",
"postcss": "latest",
"postcss-loader": "^8.1.1",
"rollup": "^4.13.0",
"rollup-plugin-css-only": "^4.5.2",
"rollup-plugin-livereload": "^2.0.5",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-svelte": "^7.2.0",
"rollup-plugin-terser": "^7.0.2",
"svelte": "^4.2.12",
"svelte-loader": "^3.2.0",
"tailwindcss": "latest",
"vite": "^5.1.6",
"xterm": "^5.2.0",
"xterm": "^5.3.0",
"xterm-addon-fit": "^0.8.0"
}
}
}
13 changes: 13 additions & 0 deletions ui/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const tailwindcss = require("tailwindcss");
const autoprefixer = require("autoprefixer");

const config = {
plugins: [
//Some plugins, like tailwindcss/nesting, need to run before Tailwind,
tailwindcss(),
//But others, like autoprefixer, need to run after,
autoprefixer,
],
};

module.exports = config;
6 changes: 0 additions & 6 deletions ui/postcss.config.js

This file was deleted.

Binary file removed ui/public/.DS_Store
Binary file not shown.
76 changes: 0 additions & 76 deletions ui/src/App.svelte

This file was deleted.

13 changes: 13 additions & 0 deletions ui/src/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover" class="bg-slate-950 text-white font-sans">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
4 changes: 4 additions & 0 deletions ui/src/app.pcss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Write your global styles here, in PostCSS syntax */
@tailwind base;
@tailwind components;
@tailwind utilities;
3 changes: 0 additions & 3 deletions ui/src/index.css

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import { agentState } from "../store";
import { API_BASE_URL } from "../api";
import { agentState } from "$lib/store";
import { API_BASE_URL } from "$lib/api";
</script>

<div class="flex flex-col bg-slate-950 border border-indigo-700 rounded flex-1 overflow-hidden">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
import { onMount } from 'svelte';
import { projectList, modelList, internet } from "../store";
import { createProject, fetchProjectList, getTokenUsage } from "../api";
import { projectList, modelList, internet } from "$lib/store";
import { createProject, fetchProjectList, getTokenUsage } from "$lib/api";
let selectedProject = localStorage.getItem("selectedProject") || "Select Project";
let selectedModel = localStorage.getItem("selectedModel") || "Select Model";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import { agentState } from "../store";
import { agentState } from "$lib/store";
</script>

<div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import { messages } from "../store";
import { messages } from "$lib/store";
import { onMount, afterUpdate } from "svelte";
let messageContainer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import { sendMessage, executeAgent, API_BASE_URL } from "../api";
import { agentState, messages } from "../store";
import { sendMessage, executeAgent, API_BASE_URL } from "$lib/api";
import { agentState, messages } from "$lib/store";
let isAgentActive = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div
class="flex flex-col w-20 bg-slate-950 p-4 space-y-4 items-center shadow-2xl shadow-indigo-700"
class="flex flex-col w-20 h-dvh fixed top-0 left-0 z-10 bg-slate-950 p-4 space-y-4 items-center shadow-2xl shadow-indigo-700"
>
<div class="p-5 rounded nav-button relative">
<button class="text-gray-400 hover:text-white flex justify-center w-full">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Terminal } from "xterm";
import "xterm/css/xterm.css";
import { FitAddon } from "xterm-addon-fit";
import { agentState } from "../store";
import { agentState } from "$lib/store";
let terminalElement;
let terminal;
Expand Down
File renamed without changes.
8 changes: 0 additions & 8 deletions ui/src/main.js

This file was deleted.

1 change: 1 addition & 0 deletions ui/src/routes/+layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const ssr = false
9 changes: 9 additions & 0 deletions ui/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script>
import "../app.pcss"
import Sidebar from '$lib/components/Sidebar.svelte'
</script>

<main class="h-dvh w-[calc(100dvw-5rem)] ml-20">
<Sidebar />
<slot />
</main>
67 changes: 67 additions & 0 deletions ui/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<script>
import { onMount } from "svelte";
import ControlPanel from "$lib/components/ControlPanel.svelte";
import MessageContainer from "$lib/components/MessageContainer.svelte";
import InternalMonologue from "$lib/components/InternalMonologue.svelte";
import MessageInput from "$lib/components/MessageInput.svelte";
import BrowserWidget from "$lib/components/BrowserWidget.svelte";
import TerminalWidget from "$lib/components/TerminalWidget.svelte";
import {
fetchProjectList,
fetchModelList,
fetchAgentState,
fetchMessages,
checkInternetStatus,
} from "$lib/api";
onMount(() => {
localStorage.clear();
const intervalId = setInterval(async () => {
await fetchProjectList();
await fetchModelList();
await fetchAgentState();
await fetchMessages();
await checkInternetStatus();
}, 1000);
return () => clearInterval(intervalId);
});
</script>

<div class="flex flex-col p-4 h-full">
<ControlPanel />

<div class="flex h-full space-x-4">
<div class="flex flex-col w-1/2">
<MessageContainer />
<InternalMonologue />
<MessageInput />
</div>

<div class="flex flex-col w-1/2 space-y-4">
<BrowserWidget />
<TerminalWidget />
</div>
</div>
</div>

<style>
:global(::-webkit-scrollbar) {
width: 10px;
}
:global(::-webkit-scrollbar-track) {
background: #2d3748;
border-radius: 10px;
}
:global(::-webkit-scrollbar-thumb) {
background: #4a5568;
border-radius: 10px;
}
:global(::-webkit-scrollbar-thumb:hover) {
background: #6b7280;
}
</style>
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
Binary file added ui/static/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
16 changes: 16 additions & 0 deletions ui/svelte.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
import adapter from "@sveltejs/adapter-auto";

/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter(),
},

preprocess: [vitePreprocess({})],
};

export default config;
12 changes: 12 additions & 0 deletions ui/tailwind.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import('tailwindcss').Config}*/
const config = {
content: ["./src/**/*.{html,js,svelte,ts}"],

theme: {
extend: {},
},

plugins: [],
};

module.exports = config;
Loading

0 comments on commit c246fa7

Please sign in to comment.