refac
Some checks are pending
Python CI / Ruff Format (3.11) (push) Waiting to run
Python CI / Ruff Format (3.12) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args: free_disk:false name:main suffix:]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_CUDA=true USE_CUDA_VER=cu126 free_disk:true name:cuda126 suffix:-cuda126]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_CUDA=true free_disk:true name:cuda suffix:-cuda]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_OLLAMA=true free_disk:false name:ollama suffix:-ollama]) (push) Waiting to run
Create and publish Docker images with specific build args / merge (map[name:main suffix:]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / build (map[arch:linux/amd64 runner:ubuntu-latest], map[build_args:USE_SLIM=true free_disk:false name:slim suffix:-slim]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args: free_disk:false name:main suffix:]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_CUDA=true USE_CUDA_VER=cu126 free_disk:true name:cuda126 suffix:-cuda126]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_CUDA=true free_disk:true name:cuda suffix:-cuda]) (push) Waiting to run
Create and publish Docker images with specific build args / copy-to-dockerhub (-cuda126, cuda126) (push) Blocked by required conditions
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_OLLAMA=true free_disk:false name:ollama suffix:-ollama]) (push) Waiting to run
Create and publish Docker images with specific build args / build (map[arch:linux/arm64 runner:ubuntu-24.04-arm], map[build_args:USE_SLIM=true free_disk:false name:slim suffix:-slim]) (push) Waiting to run
Create and publish Docker images with specific build args / merge (map[name:cuda suffix:-cuda]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:cuda126 suffix:-cuda126]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:ollama suffix:-ollama]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge (map[name:slim suffix:-slim]) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (, main) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-cuda, cuda) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-ollama, ollama) (push) Blocked by required conditions
Create and publish Docker images with specific build args / copy-to-dockerhub (-slim, slim) (push) Blocked by required conditions
Frontend Build / Format & Build (push) Waiting to run
Frontend Build / Unit Tests (push) Waiting to run

This commit is contained in:
Timothy Jaeryang Baek 2026-06-16 00:05:14 +02:00
parent 76854d1424
commit 084d040e22
5 changed files with 55 additions and 30 deletions

View file

@ -210,7 +210,8 @@ async def get_shared_folders(
async def get_folder_by_id(id: str, user=Depends(get_verified_user), db: AsyncSession = Depends(get_async_session)):
folder = await Folders.get_folder_by_id_and_user_id(id, user.id, db=db)
if folder:
return folder
grants = await AccessGrants.get_grants_by_resource('folder', id, db=db)
return {**folder.model_dump(), 'access_grants': [g.model_dump() for g in grants]}
# Check shared access
folder = await Folders.get_folder_by_id(id, db=db)

View file

@ -74,8 +74,14 @@
$: models = selectedModels.map((id) => $_models.find((m) => m.id === id));
// True when viewing a shared folder the current user doesn't own
$: folderReadOnly = $selectedFolder != null && $selectedFolder.user_id !== $user?.id;
// True when viewing a shared folder the current user doesn't own AND lacks write access
$: folderReadOnly =
$selectedFolder != null &&
$selectedFolder.user_id !== $user?.id &&
$selectedFolder.permission !== 'write';
// True when the current user does NOT own this folder (hide management menus)
$: folderNotOwned = $selectedFolder != null && $selectedFolder.user_id !== $user?.id;
</script>
<div class="m-auto w-full max-w-6xl px-2 @2xl:px-20 translate-y-6 py-24 text-center">
@ -97,19 +103,19 @@
<div class="w-full flex flex-col justify-center items-center">
{#if $selectedFolder}
<FolderTitle
folder={$selectedFolder}
readOnly={folderReadOnly}
onUpdate={async (folder) => {
await chats.set(await getChatList(localStorage.token, $currentChatPage));
currentChatPage.set(1);
}}
onDelete={async () => {
await chats.set(await getChatList(localStorage.token, $currentChatPage));
currentChatPage.set(1);
folder={$selectedFolder}
readOnly={folderNotOwned}
onUpdate={async (folder) => {
await chats.set(await getChatList(localStorage.token, $currentChatPage));
currentChatPage.set(1);
}}
onDelete={async () => {
await chats.set(await getChatList(localStorage.token, $currentChatPage));
currentChatPage.set(1);
selectedFolder.set(null);
}}
/>
selectedFolder.set(null);
}}
/>
{:else}
<div class="flex flex-row justify-center gap-2.5 @sm:gap-3 w-fit px-5 max-w-xl">
<div class="flex shrink-0 justify-center">

View file

@ -529,6 +529,16 @@
on:focus={(e) => {}}
draggable="false"
>
{#if ownerUserId}
<Tooltip content={ownerName || 'Unknown'}>
<img
src="/api/v1/users/{ownerUserId}/profile/image"
alt=""
class="size-4 rounded-full shrink-0 object-cover mr-1.5"
/>
</Tooltip>
{/if}
<!-- Loading spinner for active chat (left side) -->
{#if $activeChatIds.has(id)}
<div class="shrink-0 self-center pr-2">
@ -537,15 +547,6 @@
{/if}
<div class="flex self-center flex-1 w-full min-w-0">
{#if ownerUserId}
<Tooltip content={ownerName || 'Unknown'}>
<img
src="/api/v1/users/{ownerUserId}/profile/image"
alt=""
class="size-4 rounded-full shrink-0 object-cover mr-1.5"
/>
</Tooltip>
{/if}
{#if unread}
<div class="shrink-0 self-center pr-2.5 flex transition-opacity duration-300">
<div class="size-1.5 bg-sky-500 rounded-full" />

View file

@ -5,7 +5,7 @@
import Modal from '$lib/components/common/Modal.svelte';
import AccessControl from '$lib/components/workspace/common/AccessControl.svelte';
import XMark from '$lib/components/icons/XMark.svelte';
import { updateFolderAccessById } from '$lib/apis/folders';
import { getFolderById, updateFolderAccessById } from '$lib/apis/folders';
import { user } from '$lib/stores';
type AccessGrant = {
@ -19,11 +19,28 @@
export let folder: any = null;
let accessGrants: AccessGrant[] = [];
let loading = false;
$: if (folder) {
accessGrants = folder.access_grants ?? [];
// Fetch fresh folder data (with access_grants) when modal opens
$: if (show && folder?.id) {
loadAccessGrants();
}
const loadAccessGrants = async () => {
loading = true;
try {
const freshFolder = await getFolderById(localStorage.token, folder.id);
if (freshFolder) {
accessGrants = freshFolder.access_grants ?? [];
}
} catch (e) {
console.error('Failed to load folder access grants', e);
accessGrants = folder?.access_grants ?? [];
} finally {
loading = false;
}
};
const handleAccessChange = async () => {
if (!folder) return;
try {

View file

@ -549,7 +549,7 @@
});
if (folder) {
await selectedFolder.set(folder);
await selectedFolder.set({ ...folders[folderId], ...folder });
}
await goto('/');
@ -703,8 +703,8 @@
createdAt={chat.created_at}
updatedAt={chat.updated_at}
lastReadAt={chat.last_read_at}
ownerName={chat.owner_name ?? null}
ownerUserId={chat.owner_name ? chat.user_id : null}
ownerName={folders[folderId]?.shared ? (chat.owner_name ?? null) : null}
ownerUserId={folders[folderId]?.shared && chat.owner_name ? chat.user_id : null}
readonly={chat.user_id !== $user?.id}
{shiftKey}
on:change={(e) => {