This commit is contained in:
Timothy Jaeryang Baek committed 2026-11-24 22:44:12 +04:00
1 parent 680cd3a0f3
commit 20c4133713
8 files changed
+234 -72

No files matched your search

+33 -26
View File
@@ -31,17 +31,18 @@
/>
{:else if name === 'page'}
<path
d="M4 21.4V2.6C4 2.26863 4.26863 2 4.6 2H16.2515C16.4106 2 16.5632 2.06321 16.6757 2.17574L19.8243 5.32426C19.9368 5.43679 20 5.5894 20 5.74853V21.4C20 21.7314 19.7314 22 19.4 22H4.6C4.26863 22 4 21.7314 4 21.4Z"
stroke-width="2"
d="M13.5 2.75H6.75A2.25 2.25 0 0 0 4.5 5v14a2.25 2.25 0 0 0 2.25 2.25h10.5A2.25 2.25 0 0 0 19.5 19V8.75Z"
/>
<path d="M16 2V5.4C16 5.73137 16.2686 6 16.6 6H20" />
<path stroke-width="2" d="M13.5 2.75V7a1.75 1.75 0 0 0 1.75 1.75h4.25" />
{:else if name === 'page-text'}
<path
d="M4 21.4V2.6C4 2.26863 4.26863 2 4.6 2H16.2515C16.4106 2 16.5632 2.06321 16.6757 2.17574L19.8243 5.32426C19.9368 5.43679 20 5.5894 20 5.74853V21.4C20 21.7314 19.7314 22 19.4 22H4.6C4.26863 22 4 21.7314 4 21.4Z"
stroke-width="2"
d="M13.5 2.75H6.75A2.25 2.25 0 0 0 4.5 5v14a2.25 2.25 0 0 0 2.25 2.25h10.5A2.25 2.25 0 0 0 19.5 19V8.75Z"
/>
<path d="M8 10L16 10" />
<path d="M8 18L16 18" />
<path d="M8 14L12 14" />
<path d="M16 2V5.4C16 5.73137 16.2686 6 16.6 6H20" />
<path d="M8.5 13H15.5" />
<path d="M8.5 17H12" />
<path stroke-width="2" d="M13.5 2.75V7a1.75 1.75 0 0 0 1.75 1.75h4.25" />
{:else if name === 'terminal'}
<path d="M13 17H20" />
<path d="M5 7L10 12L5 17" />
@@ -391,9 +392,10 @@
>
{:else if name === 'pdf-logo'}
<path
d="M4 21.4V2.6C4 2.26863 4.26863 2 4.6 2H16.2515C16.4106 2 16.5632 2.06321 16.6757 2.17574L19.8243 5.32426C19.9368 5.43679 20 5.5894 20 5.74853V21.4C20 21.7314 19.7314 22 19.4 22H4.6C4.26863 22 4 21.7314 4 21.4Z"
stroke-width="2"
d="M13.5 2.75H6.75A2.25 2.25 0 0 0 4.5 5v14a2.25 2.25 0 0 0 2.25 2.25h10.5A2.25 2.25 0 0 0 19.5 19V8.75Z"
/>
<path d="M16 2V5.4C16 5.73137 16.2686 6 16.6 6H20" />
<path stroke-width="2" d="M13.5 2.75V7a1.75 1.75 0 0 0 1.75 1.75h4.25" />
<text
x="12"
y="15.2"
@@ -405,26 +407,28 @@
>
{:else if name === 'docx-logo'}
<path
d="M4 21.4V2.6C4 2.26863 4.26863 2 4.6 2H16.2515C16.4106 2 16.5632 2.06321 16.6757 2.17574L19.8243 5.32426C19.9368 5.43679 20 5.5894 20 5.74853V21.4C20 21.7314 19.7314 22 19.4 22H4.6C4.26863 22 4 21.7314 4 21.4Z"
stroke-width="2"
d="M13.5 2.75H6.75A2.25 2.25 0 0 0 4.5 5v14a2.25 2.25 0 0 0 2.25 2.25h10.5A2.25 2.25 0 0 0 19.5 19V8.75Z"
/>
<path d="M16 2V5.4C16 5.73137 16.2686 6 16.6 6H20" />
<path d="M8 10H16" />
<path d="M8 14H16" />
<path d="M8 18H13" />
<path stroke-width="2" d="M13.5 2.75V7a1.75 1.75 0 0 0 1.75 1.75h4.25" />
<path d="M8.5 13H15.5" />
<path d="M8.5 17H13" />
{:else if name === 'xlsx-logo'}
<path
d="M4 21.4V2.6C4 2.26863 4.26863 2 4.6 2H16.2515C16.4106 2 16.5632 2.06321 16.6757 2.17574L19.8243 5.32426C19.9368 5.43679 20 5.5894 20 5.74853V21.4C20 21.7314 19.7314 22 19.4 22H4.6C4.26863 22 4 21.7314 4 21.4Z"
stroke-width="2"
d="M13.5 2.75H6.75A2.25 2.25 0 0 0 4.5 5v14a2.25 2.25 0 0 0 2.25 2.25h10.5A2.25 2.25 0 0 0 19.5 19V8.75Z"
/>
<path d="M16 2V5.4C16 5.73137 16.2686 6 16.6 6H20" />
<path d="M7.5 10H16.5V18H7.5V10Z" />
<path d="M7.5 14H16.5" />
<path d="M12 10V18" />
<path stroke-width="2" d="M13.5 2.75V7a1.75 1.75 0 0 0 1.75 1.75h4.25" />
<path d="M8 12H16V18H8Z" />
<path d="M8 15H16" />
<path d="M12 12V18" />
{:else if name === 'pptx-logo'}
<path
d="M4 21.4V2.6C4 2.26863 4.26863 2 4.6 2H16.2515C16.4106 2 16.5632 2.06321 16.6757 2.17574L19.8243 5.32426C19.9368 5.43679 20 5.5894 20 5.74853V21.4C20 21.7314 19.7314 22 19.4 22H4.6C4.26863 22 4 21.7314 4 21.4Z"
stroke-width="2"
d="M13.5 2.75H6.75A2.25 2.25 0 0 0 4.5 5v14a2.25 2.25 0 0 0 2.25 2.25h10.5A2.25 2.25 0 0 0 19.5 19V8.75Z"
/>
<path d="M16 2V5.4C16 5.73137 16.2686 6 16.6 6H20" />
<path d="M8 10H16V16H8V10Z" />
<path stroke-width="2" d="M13.5 2.75V7a1.75 1.75 0 0 0 1.75 1.75h4.25" />
<path d="M8 12.5H16V17.5H8Z" />
{:else if name === 'npm'}
<path d="M1 8L23 8V15L11 15V17L7.5 17V15L1 15V8Z" />
<path d="M7.5 8L7.5 15" />
@@ -501,9 +505,10 @@
/>
{:else if name === 'empty-page'}
<path
d="M4 21.4V2.6C4 2.26863 4.26863 2 4.6 2H16.2515C16.4106 2 16.5632 2.06321 16.6757 2.17574L19.8243 5.32426C19.9368 5.43679 20 5.5894 20 5.74853V21.4C20 21.7314 19.7314 22 19.4 22H4.6C4.26863 22 4 21.7314 4 21.4Z"
stroke-width="2"
d="M13.5 2.75H6.75A2.25 2.25 0 0 0 4.5 5v14a2.25 2.25 0 0 0 2.25 2.25h10.5A2.25 2.25 0 0 0 19.5 19V8.75Z"
/>
<path d="M16 2V5.4C16 5.73137 16.2686 6 16.6 6H20" />
<path stroke-width="2" d="M13.5 2.75V7a1.75 1.75 0 0 0 1.75 1.75h4.25" />
{:else if name === 'monitor'}
<path d="M2 17V4.6C2 4.26863 2.26863 4 2.6 4H21.4C21.7314 4 22 4.26863 22 4.6V17" />
<path d="M1 17H23" />
@@ -519,8 +524,10 @@
{:else if name === 'check'}
<path d="M5 13L9 17L19 7" />
{:else if name === 'file-plus'}
<path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9Z" />
<path d="M14 3v6h6M9 15h6M12 12v6" />
<path
d="M13.5 2.75H6.75A2.25 2.25 0 0 0 4.5 5v14a2.25 2.25 0 0 0 2.25 2.25h10.5A2.25 2.25 0 0 0 19.5 19V8.75Z"
/>
<path d="M13.5 2.75V7a1.75 1.75 0 0 0 1.75 1.75h4.25M9 15h6M12 12v6" />
{:else if name === 'folder-plus' || name === 'folder-upload'}
<path
d="m13.06 6.31-2.12-2.12a1.5 1.5 0 0 0-1.061-.44H4.5A2.25 2.25 0 0 0 2.25 6v12a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 18V9a2.25 2.25 0 0 0-2.25-2.25h-5.379a1.5 1.5 0 0 1-1.06-.44Z"
+72 -6
View File
@@ -84,6 +84,45 @@
if (active && terminalEl?.clientWidth && terminalEl?.clientHeight) fitAddon?.fit();
}
// Keys a touch keyboard lacks.
const touch = window.matchMedia('(pointer: coarse)').matches;
const keys: { label: string; name?: string; value: string; arrow?: boolean }[] = [
{ label: 'Tab', value: '\t' },
{ label: 'Esc', value: '\x1b' },
{ label: 'Ctrl', value: '' },
{ label: '↑', name: 'Up', value: 'A', arrow: true },
{ label: '↓', name: 'Down', value: 'B', arrow: true },
{ label: '←', name: 'Left', value: 'D', arrow: true },
{ label: '→', name: 'Right', value: 'C', arrow: true },
...['|', '~', '/', '-', '_'].map((value) => ({ label: value, value }))
];
let ctrlHeld = false;
function withCtrl(char: string) {
if (char === ' ') return '\0';
const code = char.toUpperCase().charCodeAt(0);
return code >= 64 && code <= 95 ? String.fromCharCode(code - 64) : char;
}
function pressKey(key: (typeof keys)[number]) {
if (!term) return;
if (!key.value) {
ctrlHeld = !ctrlHeld;
} else if (key.arrow) {
// Full-screen programs may ask for the other form of the arrow keys.
const prefix = ctrlHeld
? '\x1b[1;5'
: term.modes.applicationCursorKeysMode
? '\x1bO'
: '\x1b[';
ctrlHeld = false;
term.input(prefix + key.value);
} else {
term.input(key.value);
}
term.focus();
}
function updateTheme() {
if (!term) return;
term.options.theme = document.documentElement.classList.contains('dark')
@@ -277,6 +316,10 @@
requestAnimationFrame(fit);
if (!readOnly) {
term.onData((data) => {
if (ctrlHeld && data.length === 1) {
ctrlHeld = false;
data = withCtrl(data);
}
if (ws?.readyState === WebSocket.OPEN) ws.send(new TextEncoder().encode(data));
});
term.onBinary((data) => {
@@ -309,7 +352,7 @@
});
</script>
<div class="terminal-view h-full min-h-0 relative bg-transparent">
<div class="terminal-view flex h-full min-h-0 flex-col relative bg-transparent">
{#if reconnecting}
<div
class="absolute top-1 right-2 z-10 rounded bg-base-0/90 px-2 py-1 text-xs text-base-600 dark:bg-base-900/90 dark:text-base-300"
@@ -318,11 +361,34 @@
Connection interrupted. Reconnecting to the same terminal…
</div>
{/if}
<div
bind:this={terminalEl}
class="absolute inset-0 pl-2 pr-0.5"
class:pointer-events-none={overlay}
></div>
<div class="relative flex-1 min-h-0">
<div
bind:this={terminalEl}
class="absolute inset-0 pl-2 pr-0.5"
class:pointer-events-none={overlay}
></div>
</div>
{#if touch && !readOnly}
<div
class="flex shrink-0 items-center gap-1 overflow-x-auto scrollbar-none px-2 py-1"
class:pointer-events-none={overlay}
>
{#each keys as key (key.label)}
<!-- Keeps focus in the terminal, so the keyboard stays open. -->
<button
type="button"
class="min-w-8 shrink-0 rounded-md px-2.5 py-1 font-mono text-xs transition {!key.value &&
ctrlHeld
? 'bg-base-900 text-base-0 dark:bg-base-100 dark:text-base-900'
: 'bg-base-50 text-base-600 dark:bg-base-850 dark:text-base-300'}"
aria-label={key.name}
aria-pressed={key.value ? undefined : ctrlHeld}
on:mousedown|preventDefault
on:click={() => pressKey(key)}>{key.label}</button
>
{/each}
</div>
{/if}
</div>
<style>
+5 -5
View File
@@ -12,15 +12,15 @@
stroke="currentColor"
class={className}
><path
d="M4 21.4V2.6C4 2.26863 4.26863 2 4.6 2H16.2515C16.4106 2 16.5632 2.06321 16.6757 2.17574L19.8243 5.32426C19.9368 5.43679 20 5.5894 20 5.74853V21.4C20 21.7314 19.7314 22 19.4 22H4.6C4.26863 22 4 21.7314 4 21.4Z"
d="M13.5 2.75H6.75A2.25 2.25 0 0 0 4.5 5v14a2.25 2.25 0 0 0 2.25 2.25h10.5A2.25 2.25 0 0 0 19.5 19V8.75Z"
stroke-linecap="round"
stroke-linejoin="round"
></path><path d="M8 10L16 10" stroke-linecap="round" stroke-linejoin="round"></path><path
d="M8 18L16 18"
></path><path d="M8.5 13H15.5" stroke-linecap="round" stroke-linejoin="round"></path><path
d="M8.5 17H12"
stroke-linecap="round"
stroke-linejoin="round"
></path><path d="M8 14L12 14" stroke-linecap="round" stroke-linejoin="round"></path><path
d="M16 2V5.4C16 5.73137 16.2686 6 16.6 6H20"
></path><path
d="M13.5 2.75V7a1.75 1.75 0 0 0 1.75 1.75h4.25"
stroke-linecap="round"
stroke-linejoin="round"
></path></svg
+3 -4
View File
@@ -11,13 +11,12 @@
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
><path d="M9 12H12M15 12H12M12 12V9M12 12V15" stroke-linecap="round" stroke-linejoin="round"
></path><path
d="M4 21.4V2.6C4 2.26863 4.26863 2 4.6 2H16.2515C16.4106 2 16.5632 2.06321 16.6757 2.17574L19.8243 5.32426C19.9368 5.43679 20 5.5894 20 5.74853V21.4C20 21.7314 19.7314 22 19.4 22H4.6C4.26863 22 4 21.7314 4 21.4Z"
><path d="M9 15H15M12 12V18" stroke-linecap="round" stroke-linejoin="round"></path><path
d="M13.5 2.75H6.75A2.25 2.25 0 0 0 4.5 5v14a2.25 2.25 0 0 0 2.25 2.25h10.5A2.25 2.25 0 0 0 19.5 19V8.75Z"
stroke-linecap="round"
stroke-linejoin="round"
></path><path
d="M16 2V5.4C16 5.73137 16.2686 6 16.6 6H20"
d="M13.5 2.75V7a1.75 1.75 0 0 0 1.75 1.75h4.25"
stroke-linecap="round"
stroke-linejoin="round"
></path></svg
@@ -3,40 +3,73 @@
const i18n = getContext('i18n');
const dispatch = createEventDispatcher();
import { toast } from 'svelte-sonner';
import { settings } from '$lib/stores';
import { updateFolderDetails } from '$lib/stores/folderStates';
import { updateFolderParentIdById } from '$lib/apis/folders';
import { updateUserSettings } from '$lib/apis/users';
import { sortFolders } from '$lib/utils/folders';
import RecursiveFolder from './RecursiveFolder.svelte';
export let folderRegistry = {};
export let folders = {};
export let folders: Record<string, any> = {};
export let shiftKey = false;
export let onDelete = () => {};
export let onFolderUnreadCounts = () => {};
let ownedList = [];
let sharedList = [];
let ownedList: string[] = [];
let sharedList: string[] = [];
$: {
const rootKeys = Object.keys(folders)
.filter((key) => {
const f = folders[key];
if (!f.name) return false;
// Root folder: no parent, or shared folder whose parent isn't in our folders
if (f.shared) {
return !f.parent_id || !folders[f.parent_id];
}
return f.parent_id === null;
})
.sort((a, b) =>
(folders[a].name ?? '').localeCompare(folders[b].name ?? '', undefined, {
numeric: true,
sensitivity: 'base'
})
);
ownedList = rootKeys.filter((key) => !folders[key].shared);
sharedList = rootKeys.filter((key) => folders[key].shared);
const rootFolders = Object.values(folders).filter((f) => {
if (!f.name) return false;
// Root folder: no parent, or shared folder whose parent isn't in our folders
if (f.shared) {
return !f.parent_id || !folders[f.parent_id];
}
return f.parent_id === null;
});
ownedList = sortFolders(
rootFolders.filter((f) => !f.shared),
$settings?.folderOrder?.root
).map((f) => f.id);
sharedList = sortFolders(rootFolders.filter((f) => f.shared)).map((f) => f.id);
}
const onReorder = async (id: string, targetId: string, position: 'before' | 'after') => {
const parentId = folders[targetId].parent_id;
if (folders[id].parent_id !== parentId) {
const res = await updateFolderParentIdById(localStorage.token, id, parentId).catch(
(error) => {
toast.error(`${error}`);
return null;
}
);
if (!res) return;
updateFolderDetails(id, res);
dispatch('update');
}
const key = parentId ?? 'root';
const order = sortFolders(
Object.values(folders).filter((f) => f.parent_id === parentId && !f.shared && f.id !== id),
$settings?.folderOrder?.[key]
).map((f) => f.id);
order.splice(order.indexOf(targetId) + (position === 'after' ? 1 : 0), 0, id);
const folderOrder = { ...$settings?.folderOrder, [key]: order };
settings.set({ ...$settings, folderOrder });
await updateUserSettings(localStorage.token, { ui: { folderOrder } }).catch((error) => {
toast.error(`${error}`);
});
};
const onItemMove = (e) => {
if (e.originFolderId) {
folderRegistry[e.originFolderId]?.setFolderItems();
@@ -55,6 +88,7 @@
{shiftKey}
{onDelete}
{onItemMove}
{onReorder}
{onFolderUnreadCounts}
on:import={(e) => {
dispatch('import', e.detail);
@@ -84,6 +118,7 @@
{shiftKey}
{onDelete}
{onItemMove}
{onReorder}
{onFolderUnreadCounts}
on:import={(e) => {
dispatch('import', e.detail);
@@ -1,5 +1,8 @@
<script context="module">
let closeActiveHoverPreview = null;
// Drag data can't be read until the drop
/** @type {string | null} */
let draggedFolderId = null;
</script>
<script>
@@ -24,6 +27,7 @@
config,
mobile,
selectedFolder,
settings,
showSidebar,
user
} from '$lib/stores';
@@ -40,6 +44,7 @@
isCancelledFolderRequest
} from '$lib/stores/folderStates';
import { refreshFolderChatLists } from '$lib/stores/chatList';
import { sortFolders } from '$lib/utils/folders';
import { updateNoteFolderIdById } from '$lib/apis/notes';
import { createNoteHandler } from '$lib/components/notes/utils';
import dayjs from '$lib/dayjs';
@@ -90,9 +95,13 @@
export let onDelete = () => {};
export let onItemMove = () => {};
/** @type {(id: string, targetId: string, position: 'before' | 'after') => void} */
export let onReorder = () => {};
export let onFolderUnreadCounts = () => {};
let folderElement;
/** @type {HTMLElement} */
let rowElement;
let openPreview = false;
let showFolderModal = false;
@@ -103,6 +112,7 @@
let createSubFolderParentId = null;
let draggedOver = false;
let dropPosition = 'inside';
let dragged = false;
let clickTimer = null;
@@ -199,6 +209,18 @@
$: isWritable = !folders[folderId]?.shared || folders[folderId]?.permission === 'write';
/** @param {any} e */
const getDropPosition = (e) => {
// Only folders reorder, and shared folders keep their place
if (draggedFolderId && !folders[folderId]?.shared && rowElement.contains(e.target)) {
const rect = rowElement.getBoundingClientRect();
const offset = (e.clientY - rect.top) / rect.height;
if (offset < 0.25) return 'before';
if (offset > 0.75) return 'after';
}
return 'inside';
};
const onDragOver = (e) => {
e.stopPropagation();
if (dragged || parentDragged || !isWritable) {
@@ -206,6 +228,7 @@
}
e.preventDefault();
draggedOver = true;
dropPosition = getDropPosition(e);
};
const onDrop = async (e) => {
@@ -260,6 +283,13 @@
const { type, id, item } = data;
if (type === 'folder') {
const position = getDropPosition(e);
if (position !== 'inside') {
draggedOver = false;
onReorder(id, folderId, position);
return;
}
open = true;
if (id === folderId) {
return;
@@ -386,6 +416,7 @@
event.dataTransfer.setData('application/x-open-webui-drag', '');
dragged = true;
draggedFolderId = folderId;
folderElement.style.opacity = '0.5'; // Optional: Visual cue to show it's being dragged
};
@@ -401,6 +432,7 @@
folderElement.style.opacity = '1'; // Reset visual cue after drag
dragged = false;
draggedFolderId = null;
};
onMount(async () => {
@@ -736,10 +768,17 @@
role="listitem"
draggable={!folders[folderId]?.shared}
>
{#if draggedOver}
{#if draggedOver && dropPosition === 'inside'}
<div
class="pointer-events-none absolute inset-0 z-50 touch-none bg-base-1000/[0.02] ring-1 ring-inset ring-base-1000/10 dark:bg-base-0/[0.02] dark:ring-base-0/10"
></div>
{:else if draggedOver}
<div
class="pointer-events-none absolute inset-x-1 z-50 h-px rounded-[1px] bg-base-800/20 dark:bg-base-200/20 {dropPosition ===
'before'
? 'top-0'
: 'bottom-0'}"
></div>
{/if}
<Collapsible
@@ -754,6 +793,7 @@
<div class="w-full group">
<!-- svelte-ignore a11y_click_events_have_key_events a11y_no_static_element_interactions -->
<div
bind:this={rowElement}
id="folder-{folderId}-button"
class="relative w-full py-1 px-1.5 rounded-xl flex items-center gap-1.5 hover:bg-base-100 dark:hover:bg-base-900 transition"
on:click|stopPropagation
@@ -949,14 +989,10 @@
class="ml-3 pl-1 mt-[0.0625rem] flex flex-col overflow-y-auto scrollbar-hidden border-s border-base-100 dark:border-base-900"
>
{#if folders[folderId]?.childrenIds}
{@const children = folders[folderId]?.childrenIds
.map((id) => folders[id])
.sort((a, b) =>
a.name.localeCompare(b.name, undefined, {
numeric: true,
sensitivity: 'base'
})
)}
{@const children = sortFolders(
folders[folderId].childrenIds.map((id) => folders[id]),
$settings?.folderOrder?.[folderId]
)}
{#if children.length > 0}
<div role="list">
@@ -966,8 +1002,9 @@
{folders}
folderId={childFolder.id}
{shiftKey}
parentDragged={dragged}
parentDragged={dragged || parentDragged}
{onItemMove}
{onReorder}
{onDelete}
{onFolderUnreadCounts}
on:import={(e) => {
+2
View File
@@ -392,6 +392,8 @@ type Settings = {
recentEmojis?: string[];
pinnedMenuItems?: string[];
pinnedNotesOrder?: string[];
/** Folder ids in display order, by parent folder id ('root' for top-level folders). */
folderOrder?: Record<string, string[]>;
defaultUploadContext?: 'full' | 'focused';
+16
View File
@@ -124,5 +124,21 @@ export type CanEditChat = (chat: Pick<WorkspaceChat, 'user_id'>) => boolean;
export type WorkspacePage = { chats: WorkspaceChat[]; total: number; has_more: boolean };
export type FolderUser = { id: string; name: string; count: number };
// Folders missing from the saved order go last, by name.
export const sortFolders = <T extends { id: string; name?: string }>(
folders: T[],
order: string[] = []
): T[] => {
const position = new Map(order.map((id, index) => [id, index]));
return [...folders].sort(
(a, b) =>
(position.get(a.id) ?? order.length) - (position.get(b.id) ?? order.length) ||
(a.name ?? '').localeCompare(b.name ?? '', undefined, {
numeric: true,
sensitivity: 'base'
})
);
};
export const isChatUnread = (chat: WorkspaceChat) =>
(chat.last_read_at ?? 0) === 0 || chat.updated_at > (chat.last_read_at ?? 0);