mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-22 21:50:42 -05:00
chore: format
This commit is contained in:
1 parent
b6e71d4d7f
commit
916c03829d
27 files changed
+146
-132
No files matched your search
@@ -73,6 +73,8 @@ def folder_status_since(meta: dict, status: str | None):
|
||||
if status is None or started is None:
|
||||
return None
|
||||
return started - (_as_seconds((meta.get('folder_status_durations') or {}).get(status)) or 0)
|
||||
|
||||
|
||||
CHAT_SEARCH_FILTER_PREFIXES = ('tag:', 'folder:', 'pinned:', 'archived:', 'shared:')
|
||||
|
||||
|
||||
@@ -2169,9 +2171,7 @@ class ChatTable:
|
||||
)
|
||||
# Unfinished chats are excluded above; count each approval-pending chat once.
|
||||
pending_chats = {
|
||||
(folder_id, chat_id)
|
||||
for folder_id, chat_id, output in result.all()
|
||||
if has_pending_tool_approval(output)
|
||||
(folder_id, chat_id) for folder_id, chat_id, output in result.all() if has_pending_tool_approval(output)
|
||||
}
|
||||
for folder_id, _ in pending_chats:
|
||||
counts[folder_id] = counts.get(folder_id, 0) + 1
|
||||
@@ -2708,9 +2708,7 @@ class ChatTable:
|
||||
matches = [stored.in_(named)] if named else []
|
||||
if NO_FOLDER_STATUS in status_ids:
|
||||
# Unknown or deleted statuses read as no status.
|
||||
matches.append(
|
||||
or_(stored.is_(None), stored.not_in(list(valid_status_ids)))
|
||||
)
|
||||
matches.append(or_(stored.is_(None), stored.not_in(list(valid_status_ids))))
|
||||
conditions.append(or_(*matches))
|
||||
return conditions
|
||||
|
||||
@@ -2832,9 +2830,7 @@ class ChatTable:
|
||||
labels = (
|
||||
{
|
||||
(tag.user_id, tag.id): tag
|
||||
for tag in (
|
||||
await session.execute(select(Tag).where(Tag.user_id.in_(owners), Tag.id.in_(tag_ids)))
|
||||
)
|
||||
for tag in (await session.execute(select(Tag).where(Tag.user_id.in_(owners), Tag.id.in_(tag_ids))))
|
||||
.scalars()
|
||||
.all()
|
||||
}
|
||||
@@ -2873,9 +2869,7 @@ class ChatTable:
|
||||
chat['status_since'] = folder_status_since(meta, chat['status'])
|
||||
# For the time-in-status tooltip: when the current stretch began, and earlier
|
||||
# time per status (statuses the folder no longer has are left out).
|
||||
chat['status_entered_at'] = (
|
||||
_as_seconds(meta.get('folder_status_at')) if chat['status'] else None
|
||||
)
|
||||
chat['status_entered_at'] = _as_seconds(meta.get('folder_status_at')) if chat['status'] else None
|
||||
chat['status_durations'] = {
|
||||
key: seconds
|
||||
for key, value in (meta.get('folder_status_durations') or {}).items()
|
||||
@@ -2946,9 +2940,7 @@ class ChatTable:
|
||||
async with get_async_db_context(db) as session:
|
||||
row = (
|
||||
await session.execute(
|
||||
select(Chat.meta).filter_by(
|
||||
id=id, folder_id=folder_id, **({'user_id': user_id} if user_id else {})
|
||||
)
|
||||
select(Chat.meta).filter_by(id=id, folder_id=folder_id, **({'user_id': user_id} if user_id else {}))
|
||||
)
|
||||
).one_or_none()
|
||||
if row is None:
|
||||
@@ -2968,7 +2960,11 @@ class ChatTable:
|
||||
.values(
|
||||
meta={
|
||||
# No status means no stored status, like chats that never had one.
|
||||
**{key: value for key, value in meta.items() if key not in ('folder_status', 'folder_status_at')},
|
||||
**{
|
||||
key: value
|
||||
for key, value in meta.items()
|
||||
if key not in ('folder_status', 'folder_status_at')
|
||||
},
|
||||
**({'folder_status': status, 'folder_status_at': now} if status is not None else {}),
|
||||
'folder_status_durations': durations,
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Tag(Base): # database table mapping for tag entity
|
||||
__tablename__ = 'tag'
|
||||
id = Column(String)
|
||||
@@ -98,7 +99,9 @@ class TagTable:
|
||||
meta = (await db.execute(select(Tag.meta).filter_by(id=id, user_id=user_id))).one_or_none()
|
||||
if meta is None:
|
||||
return False
|
||||
await db.execute(update(Tag).filter_by(id=id, user_id=user_id).values(meta={**(meta[0] or {}), 'color': color}))
|
||||
await db.execute(
|
||||
update(Tag).filter_by(id=id, user_id=user_id).values(meta={**(meta[0] or {}), 'color': color})
|
||||
)
|
||||
await db.commit()
|
||||
return True
|
||||
|
||||
|
||||
@@ -2394,8 +2394,10 @@ async def get_chat_with_tag_access(id: str, user, db: AsyncSession):
|
||||
if chat:
|
||||
return chat
|
||||
chat = await Chats.get_chat_by_id(id, db=db)
|
||||
if chat and chat.folder_id and (
|
||||
user.role == 'admin' or await has_folder_write_access(user.id, chat.folder_id, db=db)
|
||||
if (
|
||||
chat
|
||||
and chat.folder_id
|
||||
and (user.role == 'admin' or await has_folder_write_access(user.id, chat.folder_id, db=db))
|
||||
):
|
||||
return chat
|
||||
return None
|
||||
@@ -2478,8 +2480,13 @@ class TagColorForm(BaseModel):
|
||||
|
||||
|
||||
@router.patch('/{id}/tags', response_model=list[TagModel])
|
||||
async def update_chat_tag_color(request: Request, id: str, form_data: TagColorForm,
|
||||
user=Depends(get_verified_user), db: AsyncSession = Depends(get_async_session)):
|
||||
async def update_chat_tag_color(
|
||||
request: Request,
|
||||
id: str,
|
||||
form_data: TagColorForm,
|
||||
user=Depends(get_verified_user),
|
||||
db: AsyncSession = Depends(get_async_session),
|
||||
):
|
||||
tag_id = form_data.name.replace(' ', '_').lower()
|
||||
chat = await get_chat_with_tag_access(id, user, db)
|
||||
if not chat or tag_id not in (chat.meta or {}).get('tags', []):
|
||||
|
||||
@@ -754,7 +754,9 @@ async def get_folder_automations(
|
||||
return []
|
||||
latest = await AutomationRuns.get_latest_batch([item.id for item in automations], db=db)
|
||||
creators = {u.id: u.name for u in await Users.get_users_by_user_ids(list({a.user_id for a in automations}), db=db)}
|
||||
has_write = user.role == 'admin' or folder.user_id == user.id or await _has_folder_access(user.id, folder, 'write', db)
|
||||
has_write = (
|
||||
user.role == 'admin' or folder.user_id == user.id or await _has_folder_access(user.id, folder, 'write', db)
|
||||
)
|
||||
return [
|
||||
{
|
||||
**AutomationResponse(**item.model_dump(), last_run=latest.get(item.id)).model_dump(),
|
||||
@@ -767,7 +769,9 @@ async def get_folder_automations(
|
||||
|
||||
|
||||
@router.get('/{id}/users')
|
||||
async def get_folder_users(request: Request, id: str, user=Depends(get_verified_user), db: AsyncSession = Depends(get_async_session)):
|
||||
async def get_folder_users(
|
||||
request: Request, id: str, user=Depends(get_verified_user), db: AsyncSession = Depends(get_async_session)
|
||||
):
|
||||
await check_folder_read_access(request, id, user, db)
|
||||
counts = await Chats.get_participant_counts_by_folder_id(id, db=db)
|
||||
users = await Users.get_users_by_user_ids(list(counts), db=db) if counts else []
|
||||
@@ -779,7 +783,9 @@ async def get_folder_users(request: Request, id: str, user=Depends(get_verified_
|
||||
|
||||
|
||||
@router.get('/{id}/tags')
|
||||
async def get_folder_tags(request: Request, id: str, user=Depends(get_verified_user), db: AsyncSession = Depends(get_async_session)):
|
||||
async def get_folder_tags(
|
||||
request: Request, id: str, user=Depends(get_verified_user), db: AsyncSession = Depends(get_async_session)
|
||||
):
|
||||
await check_folder_read_access(request, id, user, db)
|
||||
return await Chats.get_tag_counts_by_folder_id(id, db=db)
|
||||
|
||||
@@ -790,19 +796,32 @@ class FolderChatStatusForm(BaseModel):
|
||||
|
||||
|
||||
@router.patch('/{id}/chats/{chat_id}/status')
|
||||
async def update_folder_chat_status(request: Request, id: str, chat_id: str, form_data: FolderChatStatusForm,
|
||||
user=Depends(get_verified_user), db: AsyncSession = Depends(get_async_session)):
|
||||
async def update_folder_chat_status(
|
||||
request: Request,
|
||||
id: str,
|
||||
chat_id: str,
|
||||
form_data: FolderChatStatusForm,
|
||||
user=Depends(get_verified_user),
|
||||
db: AsyncSession = Depends(get_async_session),
|
||||
):
|
||||
folder = await check_folder_read_access(request, id, user, db)
|
||||
if form_data.status is not None and form_data.status not in folder_status_ids(folder.meta):
|
||||
raise HTTPException(status_code=422, detail='Invalid status')
|
||||
# Folder editors may set status on any chat in the folder; others only on their own.
|
||||
has_write = user.role == 'admin' or folder.user_id == user.id or await _has_folder_access(user.id, folder, 'write', db)
|
||||
has_write = (
|
||||
user.role == 'admin' or folder.user_id == user.id or await _has_folder_access(user.id, folder, 'write', db)
|
||||
)
|
||||
if not await Chats.update_chat_folder_status_by_id(
|
||||
chat_id, id, None if has_write else user.id, form_data.status, db=db
|
||||
):
|
||||
raise HTTPException(status_code=403, detail=ERROR_MESSAGES.ACCESS_PROHIBITED)
|
||||
await publish_event(request, EVENTS.CHAT_UPDATED, actor=user, subject_id=chat_id,
|
||||
data={'folder_id': id, 'folder_status': form_data.status})
|
||||
await publish_event(
|
||||
request,
|
||||
EVENTS.CHAT_UPDATED,
|
||||
actor=user,
|
||||
subject_id=chat_id,
|
||||
data={'folder_id': id, 'folder_status': form_data.status},
|
||||
)
|
||||
return {'id': chat_id, 'status': form_data.status}
|
||||
|
||||
|
||||
|
||||
@@ -3002,11 +3002,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
||||
metadata['context_summary'] = context_summary
|
||||
|
||||
# Added after compaction: it can summarize away the copy the model had, and it should not summarize this turn's.
|
||||
if (
|
||||
use_builtin_tools
|
||||
and not metadata.get('assistant_message_id')
|
||||
and await memory_context_enabled(user, features)
|
||||
):
|
||||
if use_builtin_tools and not metadata.get('assistant_message_id') and await memory_context_enabled(user, features):
|
||||
initial_output.extend(await preload_memory(request, form_data['messages'], user, model))
|
||||
for name, manifest in manifests.items():
|
||||
if get_last_tool_result(form_data['messages'], name) != manifest:
|
||||
|
||||
@@ -53,12 +53,7 @@
|
||||
const texts = await Promise.all(
|
||||
sourceFiles.map(async (file) => {
|
||||
try {
|
||||
return await readComparisonSource(
|
||||
capturedTarget,
|
||||
file.path,
|
||||
request.signal,
|
||||
file.size
|
||||
);
|
||||
return await readComparisonSource(capturedTarget, file.path, request.signal, file.size);
|
||||
} catch (cause) {
|
||||
request.signal.throwIfAborted();
|
||||
throw new Error(
|
||||
|
||||
@@ -636,12 +636,7 @@
|
||||
<FileTypeIcon name={entry.name} type={entry.type} size={14} />
|
||||
{:else}
|
||||
{#key JSON.stringify( [target?.baseUrl, target?.key, terminalSessionId, entryPath, entry.modified, entry.size] )}
|
||||
<FileGridIcon
|
||||
{entry}
|
||||
path={entryPath}
|
||||
{target}
|
||||
itemCount={folderItemCount}
|
||||
/>
|
||||
<FileGridIcon {entry} path={entryPath} {target} itemCount={folderItemCount} />
|
||||
{/key}
|
||||
{/if}
|
||||
{#if renaming}
|
||||
|
||||
@@ -71,8 +71,7 @@
|
||||
>
|
||||
{error}<button
|
||||
class="underline"
|
||||
on:click={() =>
|
||||
load(target, root, file, active, hideWhitespace, resourceVersion)}
|
||||
on:click={() => load(target, root, file, active, hideWhitespace, resourceVersion)}
|
||||
>{$i18n.t('Retry')}</button
|
||||
>
|
||||
</div>
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
class="h-60 max-h-[calc(100dvh-6rem)] overflow-hidden text-xs [&_.document-markdown]:!p-2 [&_.document-markdown_h1]:!text-sm [&_.document-markdown_h2]:!text-xs [&_.document-markdown_h3]:!text-xs [&_.document-markdown]:!text-[0.8125rem] [&_.cm-editor]:!text-[0.6875rem] [&_pre]:!text-[0.6875rem]"
|
||||
>
|
||||
{#if documentPreview && withinPreviewLimit}
|
||||
<CommentFilePreview {path} {target} />
|
||||
<CommentFilePreview {path} {target} />
|
||||
{:else if loading || fileContent !== null || fileImageUrl || fileVideoUrl || fileAudioUrl || fileSqliteData || fileModelData}
|
||||
<FilePreview
|
||||
selectedFile={path}
|
||||
|
||||
@@ -163,12 +163,7 @@
|
||||
}
|
||||
};
|
||||
$: void configurePreview(
|
||||
JSON.stringify([
|
||||
isHtml,
|
||||
selectedFile,
|
||||
target?.baseUrl,
|
||||
target?.context
|
||||
])
|
||||
JSON.stringify([isHtml, selectedFile, target?.baseUrl, target?.context])
|
||||
);
|
||||
onDestroy(() => previewGeneration++);
|
||||
// Simple CSV parser that handles quoted fields
|
||||
@@ -332,11 +327,7 @@
|
||||
path={selectedFile ?? ''}
|
||||
loadResource={target?.baseUrl
|
||||
? async (path, signal) => {
|
||||
const result = await downloadFileBlob(
|
||||
target,
|
||||
path,
|
||||
signal
|
||||
);
|
||||
const result = await downloadFileBlob(target, path, signal);
|
||||
if (!result) throw new Error('Could not load model resource.');
|
||||
return result.blob;
|
||||
}
|
||||
@@ -464,12 +455,7 @@
|
||||
</div>
|
||||
{:else if isNotebook && !showRaw && parsedNotebook}
|
||||
<div class="overflow-auto h-full">
|
||||
<NotebookView
|
||||
notebook={parsedNotebook}
|
||||
filePath={selectedFile ?? ''}
|
||||
{target}
|
||||
{readOnly}
|
||||
/>
|
||||
<NotebookView notebook={parsedNotebook} filePath={selectedFile ?? ''} {target} {readOnly} />
|
||||
</div>
|
||||
{:else if isJson && !showRaw && parsedJson !== undefined}
|
||||
<div class="overflow-auto h-full">
|
||||
|
||||
@@ -168,13 +168,25 @@
|
||||
<path d="M17.5 8.5L21 12L17.5 15.5" />
|
||||
{:else if name === 'claude'}
|
||||
<!-- Simple Icons 14.0.0 (CC0): claude -->
|
||||
<path fill="currentColor" stroke="none" d="m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z" />
|
||||
<path
|
||||
fill="currentColor"
|
||||
stroke="none"
|
||||
d="m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z"
|
||||
/>
|
||||
{:else if name === 'openai'}
|
||||
<!-- Simple Icons 14.0.0 (CC0): openai -->
|
||||
<path fill="currentColor" stroke="none" d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z" />
|
||||
<path
|
||||
fill="currentColor"
|
||||
stroke="none"
|
||||
d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"
|
||||
/>
|
||||
{:else if name === 'nodejs'}
|
||||
<!-- Simple Icons 14.0.0 (CC0): nodedotjs -->
|
||||
<path fill="currentColor" stroke="none" d="M11.998,24c-0.321,0-0.641-0.084-0.922-0.247l-2.936-1.737c-0.438-0.245-0.224-0.332-0.08-0.383 c0.585-0.203,0.703-0.25,1.328-0.604c0.065-0.037,0.151-0.023,0.218,0.017l2.256,1.339c0.082,0.045,0.197,0.045,0.272,0l8.795-5.076 c0.082-0.047,0.134-0.141,0.134-0.238V6.921c0-0.099-0.053-0.192-0.137-0.242l-8.791-5.072c-0.081-0.047-0.189-0.047-0.271,0 L3.075,6.68C2.99,6.729,2.936,6.825,2.936,6.921v10.15c0,0.097,0.054,0.189,0.139,0.235l2.409,1.392 c1.307,0.654,2.108-0.116,2.108-0.89V7.787c0-0.142,0.114-0.253,0.256-0.253h1.115c0.139,0,0.255,0.112,0.255,0.253v10.021 c0,1.745-0.95,2.745-2.604,2.745c-0.508,0-0.909,0-2.026-0.551L2.28,18.675c-0.57-0.329-0.922-0.945-0.922-1.604V6.921 c0-0.659,0.353-1.275,0.922-1.603l8.795-5.082c0.557-0.315,1.296-0.315,1.848,0l8.794,5.082c0.57,0.329,0.924,0.944,0.924,1.603 v10.15c0,0.659-0.354,1.273-0.924,1.604l-8.794,5.078C12.643,23.916,12.324,24,11.998,24z M19.099,13.993 c0-1.9-1.284-2.406-3.987-2.763c-2.731-0.361-3.009-0.548-3.009-1.187c0-0.528,0.235-1.233,2.258-1.233 c1.807,0,2.473,0.389,2.747,1.607c0.024,0.115,0.129,0.199,0.247,0.199h1.141c0.071,0,0.138-0.031,0.186-0.081 c0.048-0.054,0.074-0.123,0.067-0.196c-0.177-2.098-1.571-3.076-4.388-3.076c-2.508,0-4.004,1.058-4.004,2.833 c0,1.925,1.488,2.457,3.895,2.695c2.88,0.282,3.103,0.703,3.103,1.269c0,0.983-0.789,1.402-2.642,1.402 c-2.327,0-2.839-0.584-3.011-1.742c-0.02-0.124-0.126-0.215-0.253-0.215h-1.137c-0.141,0-0.254,0.112-0.254,0.253 c0,1.482,0.806,3.248,4.655,3.248C17.501,17.007,19.099,15.91,19.099,13.993z" />
|
||||
<path
|
||||
fill="currentColor"
|
||||
stroke="none"
|
||||
d="M11.998,24c-0.321,0-0.641-0.084-0.922-0.247l-2.936-1.737c-0.438-0.245-0.224-0.332-0.08-0.383 c0.585-0.203,0.703-0.25,1.328-0.604c0.065-0.037,0.151-0.023,0.218,0.017l2.256,1.339c0.082,0.045,0.197,0.045,0.272,0l8.795-5.076 c0.082-0.047,0.134-0.141,0.134-0.238V6.921c0-0.099-0.053-0.192-0.137-0.242l-8.791-5.072c-0.081-0.047-0.189-0.047-0.271,0 L3.075,6.68C2.99,6.729,2.936,6.825,2.936,6.921v10.15c0,0.097,0.054,0.189,0.139,0.235l2.409,1.392 c1.307,0.654,2.108-0.116,2.108-0.89V7.787c0-0.142,0.114-0.253,0.256-0.253h1.115c0.139,0,0.255,0.112,0.255,0.253v10.021 c0,1.745-0.95,2.745-2.604,2.745c-0.508,0-0.909,0-2.026-0.551L2.28,18.675c-0.57-0.329-0.922-0.945-0.922-1.604V6.921 c0-0.659,0.353-1.275,0.922-1.603l8.795-5.082c0.557-0.315,1.296-0.315,1.848,0l8.794,5.082c0.57,0.329,0.924,0.944,0.924,1.603 v10.15c0,0.659-0.354,1.273-0.924,1.604l-8.794,5.078C12.643,23.916,12.324,24,11.998,24z M19.099,13.993 c0-1.9-1.284-2.406-3.987-2.763c-2.731-0.361-3.009-0.548-3.009-1.187c0-0.528,0.235-1.233,2.258-1.233 c1.807,0,2.473,0.389,2.747,1.607c0.024,0.115,0.129,0.199,0.247,0.199h1.141c0.071,0,0.138-0.031,0.186-0.081 c0.048-0.054,0.074-0.123,0.067-0.196c-0.177-2.098-1.571-3.076-4.388-3.076c-2.508,0-4.004,1.058-4.004,2.833 c0,1.925,1.488,2.457,3.895,2.695c2.88,0.282,3.103,0.703,3.103,1.269c0,0.983-0.789,1.402-2.642,1.402 c-2.327,0-2.839-0.584-3.011-1.742c-0.02-0.124-0.126-0.215-0.253-0.215h-1.137c-0.141,0-0.254,0.112-0.254,0.253 c0,1.482,0.806,3.248,4.655,3.248C17.501,17.007,19.099,15.91,19.099,13.993z"
|
||||
/>
|
||||
{:else if name === 'python'}
|
||||
<path
|
||||
d="M8 10H16C17.1046 10 18 9.10457 18 8V5.5C18 4.11929 16.8807 3 15.5 3H10C8.89543 3 8 3.89543 8 5V10Z"
|
||||
|
||||
@@ -267,11 +267,7 @@
|
||||
try {
|
||||
for (const file of files) {
|
||||
if (current !== generation || currentEditor.isDestroyed || readOnly) break;
|
||||
const result = await uploadNewFileToTerminal(
|
||||
capturedTarget!,
|
||||
directory,
|
||||
file
|
||||
);
|
||||
const result = await uploadNewFileToTerminal(capturedTarget!, directory, file);
|
||||
if (current !== generation || currentEditor.isDestroyed || readOnly) break;
|
||||
if (!result) throw new Error($i18n.t('Failed to upload file.'));
|
||||
const name = result.path.split('/').pop()!;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
export let active = true;
|
||||
export let previewBaseUrl: string | null = null;
|
||||
|
||||
|
||||
let ports: ListeningPort[] = [];
|
||||
let loading = false;
|
||||
let mounted = false;
|
||||
|
||||
@@ -467,8 +467,7 @@
|
||||
workspace: true,
|
||||
search: appliedSearch,
|
||||
userIds: selectedUsers,
|
||||
tagIds:
|
||||
activeBy() === 'tags' && key !== 'all' ? [key] : selectedTags,
|
||||
tagIds: activeBy() === 'tags' && key !== 'all' ? [key] : selectedTags,
|
||||
activity: activeBy() === 'activity' && key !== 'all' ? (key as FolderActivity) : activity,
|
||||
updatedAtGte,
|
||||
status:
|
||||
|
||||
@@ -11,11 +11,7 @@
|
||||
browserFrameUrl,
|
||||
type BrowserSession
|
||||
} from '$lib/apis/terminal/browser';
|
||||
import {
|
||||
getPortProxyUrl,
|
||||
TerminalRequestError,
|
||||
type TerminalTarget
|
||||
} from '$lib/apis/terminal';
|
||||
import { getPortProxyUrl, TerminalRequestError, type TerminalTarget } from '$lib/apis/terminal';
|
||||
import PortList from '../FileNav/PortList.svelte';
|
||||
import { settings } from '$lib/stores';
|
||||
import Icon from '../FileNav/Icon.svelte';
|
||||
@@ -54,16 +50,12 @@
|
||||
let frameReady = false;
|
||||
$: viewUrl = session && sessionTarget ? browserViewUrl(sessionTarget, session) : '';
|
||||
$: if (session && sessionTarget) {
|
||||
void updateBrowserSession(sessionTarget, session.id, { active }).catch(
|
||||
() => {}
|
||||
);
|
||||
void updateBrowserSession(sessionTarget, session.id, { active }).catch(() => {});
|
||||
}
|
||||
|
||||
const persist = (url: string, title: string) => {
|
||||
if (session && sessionTarget)
|
||||
void updateBrowserSession(sessionTarget, session.id, { url, title }).catch(
|
||||
() => {}
|
||||
);
|
||||
void updateBrowserSession(sessionTarget, session.id, { url, title }).catch(() => {});
|
||||
};
|
||||
const switchMode = async (mode: 'proxy' | 'chrome', force = false) => {
|
||||
if (!session || !sessionTarget || switching || (!force && session.mode === mode)) return;
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
timer = setTimeout(async () => {
|
||||
const path = query.trim().replace(/\\/g, '/');
|
||||
const slash = path.lastIndexOf('/');
|
||||
const response = await searchFiles(target,
|
||||
const response = await searchFiles(
|
||||
target,
|
||||
path.slice(slash + 1),
|
||||
slash < 0 ? '.' : path.slice(0, slash) || '/',
|
||||
50,
|
||||
|
||||
@@ -105,9 +105,7 @@
|
||||
saving = true;
|
||||
error = '';
|
||||
try {
|
||||
const listing = await listFiles(target,
|
||||
directory
|
||||
);
|
||||
const listing = await listFiles(target, directory);
|
||||
if (!listing || listing.writable === false) throw new Error($i18n.t('File is not writable.'));
|
||||
const existing = listing.entries.find((entry) => entry.name === name);
|
||||
if (existing?.type === 'directory' || existing?.writable === false)
|
||||
@@ -117,7 +115,8 @@
|
||||
error = $i18n.t('A file with this name already exists. Replace it?');
|
||||
return;
|
||||
}
|
||||
const result = await uploadToTerminal(target,
|
||||
const result = await uploadToTerminal(
|
||||
target,
|
||||
directory,
|
||||
new File([value], name, { type: 'text/plain' })
|
||||
);
|
||||
|
||||
@@ -222,7 +222,8 @@
|
||||
player?.pause();
|
||||
try {
|
||||
if (!draft.audioPath) {
|
||||
const result = await uploadNewFileToTerminal(target,
|
||||
const result = await uploadNewFileToTerminal(
|
||||
target,
|
||||
draft.directory,
|
||||
new File([draft.audio], `${draft.name.trim()}.${voiceNoteExtension(draft.audio.type)}`, {
|
||||
type: draft.audio.type
|
||||
@@ -231,7 +232,8 @@
|
||||
if (!result?.path) throw new Error();
|
||||
draft.audioPath = result.path;
|
||||
}
|
||||
const note = await uploadNewFileToTerminal(target,
|
||||
const note = await uploadNewFileToTerminal(
|
||||
target,
|
||||
draft.directory,
|
||||
new File([voiceNoteMarkdown(draft)], `${draft.name.trim()}.md`, { type: 'text/markdown' })
|
||||
);
|
||||
|
||||
@@ -178,11 +178,7 @@ export function openTab(state: TabsState, tab: Tab): TabsState {
|
||||
}
|
||||
|
||||
/** Opens `tab` in a group beside the one holding `besideId`, so both stay in view. */
|
||||
export function openTabInSplit(
|
||||
state: TabsState,
|
||||
tab: Tab,
|
||||
besideId = mainChatTabId
|
||||
): TabsState {
|
||||
export function openTabInSplit(state: TabsState, tab: Tab, besideId = mainChatTabId): TabsState {
|
||||
const besideGroup = state.groups.find((group) => group.tabIds.includes(besideId));
|
||||
if (!besideGroup) return openTab(state, tab);
|
||||
if (state.tabs.some((item) => item.id === tab.id) && !besideGroup.tabIds.includes(tab.id))
|
||||
|
||||
@@ -5,11 +5,7 @@
|
||||
import { WebLinksAddon } from '@xterm/addon-web-links';
|
||||
import { WebglAddon } from '@xterm/addon-webgl';
|
||||
import '@xterm/xterm/css/xterm.css';
|
||||
import {
|
||||
terminalRequest,
|
||||
TerminalRequestError,
|
||||
type TerminalTarget
|
||||
} from '$lib/apis/terminal';
|
||||
import { terminalRequest, TerminalRequestError, type TerminalTarget } from '$lib/apis/terminal';
|
||||
import { assignTerminalChat, openTerminalSocket } from '$lib/apis/terminal/socket';
|
||||
|
||||
export let target: TerminalTarget;
|
||||
@@ -114,10 +110,7 @@
|
||||
connecting = true;
|
||||
try {
|
||||
if (!sessionId) throw new Error('Session no longer available');
|
||||
await terminalRequest(
|
||||
target,
|
||||
`/api/terminals/${encodeURIComponent(sessionId)}`
|
||||
);
|
||||
await terminalRequest(target, `/api/terminals/${encodeURIComponent(sessionId)}`);
|
||||
if (destroyed) return;
|
||||
ws = openTerminalSocket(
|
||||
target,
|
||||
|
||||
@@ -135,8 +135,7 @@
|
||||
}
|
||||
|
||||
const isTextField = (element: EventTarget | null) =>
|
||||
element instanceof HTMLElement &&
|
||||
element.matches('input, textarea, [contenteditable="true"]');
|
||||
element instanceof HTMLElement && element.matches('input, textarea, [contenteditable="true"]');
|
||||
|
||||
function handleContentKeydown(event: KeyboardEvent) {
|
||||
if (['ArrowLeft', 'Home', 'End'].includes(event.key) && isTextField(event.target)) return;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
folderChatPageKey,
|
||||
loadFolderDetails,
|
||||
loadFolderChatPage,
|
||||
type FolderDetails,
|
||||
type FolderDetails
|
||||
} from '$lib/stores/folderStates';
|
||||
import { models } from '$lib/stores';
|
||||
import Emoji from '$lib/components/common/Emoji.svelte';
|
||||
@@ -72,7 +72,10 @@
|
||||
{/if}
|
||||
{#if !folder.shared && (folder.unread_count ?? 0) > 0}
|
||||
<span>·</span>
|
||||
<span>{folder.unread_count.toLocaleString()} {$i18n.t('Unread or waiting for approval')}</span>
|
||||
<span
|
||||
>{folder.unread_count.toLocaleString()}
|
||||
{$i18n.t('Unread or waiting for approval')}</span
|
||||
>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -251,7 +251,9 @@
|
||||
<EmojiPicker
|
||||
side="bottom"
|
||||
selected={meta.icon || null}
|
||||
onSubmit={(icon: string | null) => { meta = { ...meta, icon: icon ?? '' }; }}
|
||||
onSubmit={(icon: string | null) => {
|
||||
meta = { ...meta, icon: icon ?? '' };
|
||||
}}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
import {
|
||||
loadFolderDetails,
|
||||
updateFolderDetails,
|
||||
markFolderChatsDirty,
|
||||
markFolderChatsDirty
|
||||
} from '$lib/stores/folderStates';
|
||||
|
||||
type AccessGrant = {
|
||||
|
||||
@@ -18,9 +18,15 @@
|
||||
|
||||
import { chatId, mobile, selectedFolder, showSidebar, user } from '$lib/stores';
|
||||
import {
|
||||
folderStates, folderChatPageKey, loadFolderChatPage,
|
||||
loadFolderDetails, setFolderSidebarPage, updateFolderChatLists, markFolderRead,
|
||||
updateFolderDetails, removeFolderState,
|
||||
folderStates,
|
||||
folderChatPageKey,
|
||||
loadFolderChatPage,
|
||||
loadFolderDetails,
|
||||
setFolderSidebarPage,
|
||||
updateFolderChatLists,
|
||||
markFolderRead,
|
||||
updateFolderDetails,
|
||||
removeFolderState,
|
||||
isCancelledFolderRequest
|
||||
} from '$lib/stores/folderStates';
|
||||
import { refreshFolderChatLists } from '$lib/stores/chatList';
|
||||
@@ -474,10 +480,12 @@
|
||||
toast.success($i18n.t('Folder updated successfully'));
|
||||
|
||||
if ($selectedFolder?.id === folderId) {
|
||||
const folder = await loadFolderDetails(localStorage.token, folderId, true).catch((error) => {
|
||||
toast.error(`${error}`);
|
||||
return null;
|
||||
});
|
||||
const folder = await loadFolderDetails(localStorage.token, folderId, true).catch(
|
||||
(error) => {
|
||||
toast.error(`${error}`);
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
||||
if (folder) {
|
||||
await selectedFolder.set(folder);
|
||||
@@ -516,10 +524,16 @@
|
||||
$: {
|
||||
const retained = $folderStates[folderId];
|
||||
chatsPage = retained?.sidebarPage ?? 1;
|
||||
const pages = Array.from({ length: chatsPage }, (_, index) =>
|
||||
retained?.chatPages[folderChatPageKey({ page: index + 1 })]
|
||||
const pages = Array.from(
|
||||
{ length: chatsPage },
|
||||
(_, index) => retained?.chatPages[folderChatPageKey({ page: index + 1 })]
|
||||
);
|
||||
chats = pages.some(Boolean) ? mergeFolderChats([], pages.flatMap((page) => page?.chats ?? [])) : null;
|
||||
chats = pages.some(Boolean)
|
||||
? mergeFolderChats(
|
||||
[],
|
||||
pages.flatMap((page) => page?.chats ?? [])
|
||||
)
|
||||
: null;
|
||||
hasMoreChats = pages.at(-1)?.has_more ?? false;
|
||||
}
|
||||
|
||||
@@ -532,9 +546,16 @@
|
||||
chatsLoading = true;
|
||||
try {
|
||||
const nextPage = append ? chatsPage + 1 : chatsPage;
|
||||
await Promise.all(Array.from({ length: append ? 1 : nextPage }, (_, index) =>
|
||||
loadFolderChatPage(localStorage.token, folderId, { page: append ? nextPage : index + 1 }, !append && refresh)
|
||||
));
|
||||
await Promise.all(
|
||||
Array.from({ length: append ? 1 : nextPage }, (_, index) =>
|
||||
loadFolderChatPage(
|
||||
localStorage.token,
|
||||
folderId,
|
||||
{ page: append ? nextPage : index + 1 },
|
||||
!append && refresh
|
||||
)
|
||||
)
|
||||
);
|
||||
if (append) setFolderSidebarPage(folderId, nextPage);
|
||||
} catch (error) {
|
||||
if (!isCancelledFolderRequest(error)) toast.error(`${error}`);
|
||||
@@ -860,7 +881,8 @@
|
||||
showCreateSubFolderModal = true;
|
||||
}}
|
||||
onMarkAllRead={markAllReadHandler}
|
||||
onShare={($user?.role === 'admin' || (folders[folderId]?.user_id === $user?.id && $user?.permissions?.sharing?.folders))
|
||||
onShare={$user?.role === 'admin' ||
|
||||
(folders[folderId]?.user_id === $user?.id && $user?.permissions?.sharing?.folders)
|
||||
? () => (showShareModal = true)
|
||||
: null}
|
||||
>
|
||||
|
||||
@@ -36,8 +36,9 @@
|
||||
let saving = false;
|
||||
|
||||
export let accessRoles = ['read'];
|
||||
export let labels: Partial<Record<'title' | 'public' | 'private' | 'read' | 'write' | 'empty', string>> =
|
||||
{};
|
||||
export let labels: Partial<
|
||||
Record<'title' | 'public' | 'private' | 'read' | 'write' | 'empty', string>
|
||||
> = {};
|
||||
export let accessGrants: AccessGrant[] | any = [];
|
||||
export let accessControl: any = undefined;
|
||||
|
||||
|
||||
@@ -487,7 +487,9 @@
|
||||
<div id="main-content" tabindex="-1" class="sr-only left-0 top-0"></div>
|
||||
{#if routeHasTabs || usePageTabs}
|
||||
<Chat
|
||||
initialPage={usePageTabs ? $page.url.pathname + $page.url.search + $page.url.hash : ''}
|
||||
initialPage={usePageTabs
|
||||
? $page.url.pathname + $page.url.search + $page.url.hash
|
||||
: ''}
|
||||
/>
|
||||
{/if}
|
||||
{#if !usePageTabs}<slot />{/if}
|
||||
|
||||
Reference in new issue
Block a user