This commit is contained in:
Timothy Jaeryang Baek committed 2026-11-17 00:31:18 +09:00
1 parent 1712f4fa6c
commit c82ceaf1fc
21 files changed
+285 -154

No files matched your search

@@ -107,6 +107,9 @@ async def run(transport, output, prompt, images, options):
streamed_thinking = True
await output.text(delta.get('thinking', ''), reasoning=True)
elif kind == 'assistant':
if message.get('uuid') and not message.get('parent_tool_use_id'):
# Later regenerations and edits fork the conversation at this turn's last reply.
output.state['turn'] = message['uuid']
for block in message.get('message', {}).get('content', []):
if block['type'] == 'text' and not streamed_text:
await output.text(block['text'])
+10 -1
View File
@@ -80,7 +80,14 @@ async def run(transport, output, prompt, images, options):
params['developerInstructions'] = options['instructions']
if options.get('resume'):
params['threadId'] = options['resume']
result = await client.request('thread/resume' if options.get('resume') else 'thread/start', params)
if options.get('resume') and options.get('fork'):
# A regenerated or edited message: copy the thread through the turn it follows.
result = await client.request('thread/fork', {**params, 'lastTurnId': options['resume_at']})
turns = result['thread'].get('turns') or []
if options.get('resume_at') and (not turns or turns[-1].get('id') != options['resume_at']):
raise ValueError('Update Codex to regenerate or edit earlier messages in this chat')
else:
result = await client.request('thread/resume' if options.get('resume') else 'thread/start', params)
thread_id = result['thread']['id']
output.state['session_id'] = thread_id
await output.flush(force=True, persist=True)
@@ -103,6 +110,8 @@ async def run(transport, output, prompt, images, options):
},
)
turn_id = result['turn']['id']
# Later regenerations and edits fork the thread through this turn.
output.state['turn'] = turn_id
while True:
event = await client.events.get()
if isinstance(event, Exception):
+50 -6
View File
@@ -4,9 +4,10 @@ import copy
from open_webui.models.chats import Chats
from open_webui.utils.chat_id import is_saved_chat_id
from open_webui.utils.misc import get_message_list
from open_webui.utils.terminals import get_terminal_json, upload_files_to_terminal
from .session import get_session
from .session import get_resume_point
from .output import Output
from .transport import TerminalTransport
from . import acp, codex, claude_code, pi
@@ -28,6 +29,10 @@ PROVIDERS = {
}
# Providers that can copy their native conversation up to an earlier turn.
FORKABLE = {'codex', 'claude-code'}
def provider_runner(provider):
# Agents configured in Open Terminal's OPEN_TERMINAL_ACP_AGENTS arrive as `acp-<id>`.
return PROVIDERS.get(provider) or (acp.run if provider.startswith('acp-') else None)
@@ -36,7 +41,7 @@ def provider_runner(provider):
async def run(request, form_data, user, metadata, model):
if not is_saved_chat_id(metadata.get('chat_id')):
raise ValueError('Agent conversations require a saved chat')
if metadata.get('regeneration_message_id') or metadata.get('assistant_message_id'):
if metadata.get('assistant_message_id'):
raise ValueError('Continue an agent conversation with a new message')
agent = model['agent']
run_provider = provider_runner(agent['provider'])
@@ -46,14 +51,29 @@ async def run(request, form_data, user, metadata, model):
if chat is None:
raise ValueError('Chat reply access denied')
parent = (metadata.get('user_message') or {}).get('parentId')
previous = await get_session(chat, parent) if parent else None
previous, branched = (
await get_resume_point(chat, parent, exclude=metadata.get('message_id')) if parent else (None, False)
)
if previous and any(previous.get(key) != agent[key] for key in ('terminal_id', 'provider')):
previous = None
# Regenerated and edited messages branch off a reply whose native conversation went on without them.
resume_at = None
if previous and branched:
if agent['provider'] in FORKABLE and previous.get('turn'):
resume_at = previous['turn']
else:
# The agent can't copy part of its conversation: start a new one from the transcript.
previous = {key: value for key, value in previous.items() if key != 'session_id'}
metadata['terminal_id'] = agent['terminal_id']
transport = await TerminalTransport.resolve(request, user, metadata)
output = Output(metadata, user, transport.raise_if_failed, form_data)
output.state = {
**{key: previous[key] for key in ('session_id', 'model_config') if previous and key in previous},
# A fork is a new native conversation, which records its own id once the agent reports it.
**{
key: previous[key]
for key in ('model_config', *(() if resume_at else ('session_id',)))
if previous and key in previous
},
**agent,
'instance_user_id': (previous or {}).get('instance_user_id') or (previous or {}).get('user') or user.id,
}
@@ -88,9 +108,23 @@ async def run(request, form_data, user, metadata, model):
prompt = text(user_message.get('content', ''))
if not previous or not previous.get('session_id'):
history = [m for m in messages if m.get('role') in {'user', 'assistant'}]
# A new native conversation starts from this branch's transcript. Saved chats send only
# the system prompt, so the branch is read from the stored messages.
stored = get_message_list(await Chats.get_messages_map_by_chat_id(chat.id) or {}, parent) if parent else []
history = [m for m in stored or messages if m.get('role') in {'user', 'assistant'}]
if stored:
history.append(user_message)
elif metadata.get('regeneration_message_id') and history and history[-1].get('role') == 'assistant':
history = history[:-1] # Guided regeneration sends the reply being revised; it's quoted below.
if len(history) > 1:
prompt = '\n\n'.join(f'{m["role"]}: {text(m.get("content", ""))}' for m in history)
if metadata.get('regeneration_message_id') and form_data.get('regeneration_prompt'):
# Guided regeneration: the agent revises a reply its forked conversation no longer holds.
regenerated = await Chats.get_message_by_id_and_message_id(chat.id, metadata['regeneration_message_id'])
earlier = text((regenerated or {}).get('content', ''))
if earlier:
prompt += f'\n\nYour previous reply to this was:\n<previous_reply>\n{earlier}\n</previous_reply>'
prompt += f'\n\n{form_data["regeneration_prompt"]}'
if paths:
prompt += '\n\nAttached files in this environment:\n' + '\n'.join(paths)
images = [
@@ -106,13 +140,23 @@ async def run(request, form_data, user, metadata, model):
'cwd': cwd,
'model': agent['model'],
'resume': (previous or {}).get('session_id'),
# A fork keeps the original conversation as it was for the reply that branched off it.
'resume_at': resume_at,
'fork': bool(resume_at),
'instructions': instructions,
# The chat's tool permission mode; agents with their own auto review use it for Auto.
'approval_mode': (metadata.get('params') or {}).get('tool_approval_mode', 'full'),
}
succeeded = False
try:
await transport.start(agent['provider'], options)
session = await transport.start(agent['provider'], options)
if (
resume_at
and agent['provider'] == 'claude-code'
and (session.get('resume_at') != resume_at or not session.get('fork'))
):
# An older Open Terminal would resume the original conversation instead of forking it.
raise ValueError('Update Open Terminal to regenerate or edit earlier messages in this chat')
extra = {'auth_method': 'cursor_login'} if agent['provider'] == 'cursor' else {}
await run_provider(
transport,
+53 -19
View File
@@ -36,6 +36,32 @@ async def ensure_chat_selections(chat):
return chat
def _state(message):
token = (message.get('meta') or {}).get('agent')
state = decode_token(token) if isinstance(token, str) else None
return state if state and state.get('typ') == 'agent_session' else None
def _find(chat, messages, message_id):
visited = set()
while message_id and message_id not in visited:
visited.add(message_id)
message = messages.get(message_id)
if not message:
return None, None
state = _state(message)
if state:
if state.get('chat') != chat.id:
return None, None # Forks and clones start independent native conversations.
if all(
isinstance(state.get(key), str) and state[key]
for key in ('terminal_id', 'provider', 'model', 'cwd', 'user')
):
return state, message_id
message_id = message.get('parentId')
return None, None
async def get_session(chat, message_id=None):
message_id = (
message_id or getattr(chat, 'current_message_id', None) or (chat.chat or {}).get('history', {}).get('currentId')
@@ -43,22 +69,30 @@ async def get_session(chat, message_id=None):
if not message_id:
return None
messages = await Chats.get_messages_map_by_chat_id(chat.id) or {}
visited = set()
while message_id and message_id not in visited:
visited.add(message_id)
message = messages.get(message_id)
if not message:
return None
token = (message.get('meta') or {}).get('agent')
if token:
state = decode_token(token) if isinstance(token, str) else None
if state and state.get('typ') == 'agent_session':
if state.get('chat') != chat.id:
return None # Forks and clones start independent native conversations.
if all(
isinstance(state.get(key), str) and state[key]
for key in ('terminal_id', 'provider', 'model', 'cwd', 'user')
):
return state
message_id = message.get('parentId')
return None
return _find(chat, messages, message_id)[0]
async def get_resume_point(chat, message_id, exclude=None):
"""The native conversation to continue from `message_id`, and whether later turns were added to it.
Regenerating or editing an earlier message reaches a reply whose native conversation already holds
the turns that came after it; that conversation is then forked at the reply instead of resumed.
"""
messages = await Chats.get_messages_map_by_chat_id(chat.id) or {}
state, found_id = _find(chat, messages, message_id)
if state is None or not state.get('session_id'):
return state, False
timestamp = messages[found_id].get('timestamp') or 0
for other_id, other in messages.items():
if other_id in (found_id, exclude) or (other.get('timestamp') or 0) < timestamp:
continue
other_state = _state(other)
if (
other_state
and other_state.get('chat') == chat.id
and other_state.get('session_id') == state['session_id']
and other_state.get('provider') == state.get('provider')
and other_state.get('terminal_id') == state.get('terminal_id')
):
return state, True
return state, False
+1 -1
View File
@@ -493,7 +493,7 @@
{#if channel && messages !== null}
<div class="flex-1 overflow-y-auto">
<div
class=" pb-2.5 max-w-full z-10 scrollbar-hidden w-full h-full pt-6 flex-1 flex flex-col-reverse overflow-auto"
class=" pb-2.5 max-w-full z-10 scrollbar-hidden w-full h-full flex-1 flex flex-col-reverse overflow-auto"
id="messages-container"
bind:this={messagesContainerElement}
on:scroll={(e) => {
@@ -67,7 +67,7 @@
type="button"
class="flex {sidebar
? 'size-4.5'
: 'size-7'} items-center justify-center rounded-lg text-gray-500 dark:text-gray-400 hover:bg-gray-50/60 dark:hover:bg-gray-800/60 transition-colors touch-auto"
: 'size-6'} items-center justify-center rounded-lg text-gray-500 transition hover:bg-gray-50/40 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800/40 dark:hover:text-gray-200 touch-auto"
aria-label={$i18n.t(channel.type === 'dm' ? 'Conversation options' : 'Channel options')}
aria-haspopup="menu"
aria-expanded={show}
@@ -162,7 +162,7 @@
{:else}
<div
bind:this={list}
class="flex-1 min-h-0 overflow-y-auto pt-14 pb-2.5"
class="flex-1 min-h-0 overflow-y-auto pt-6 pb-2.5"
role="log"
aria-label={$i18n.t('Encrypted messages')}
aria-live="polite"
+13 -30
View File
@@ -64,6 +64,8 @@
import MentionList from './MessageInput/MentionList.svelte';
import Skeleton from '../chat/Messages/Skeleton.svelte';
import XMark from '../icons/XMark.svelte';
import Mic from '../icons/Mic.svelte';
import PlusAlt from '../icons/PlusAlt.svelte';
export let placeholder: string | undefined = undefined;
export let chatInputElement: any;
@@ -1236,8 +1238,8 @@
</div>
</div>
<div class=" flex items-center justify-between gap-2 p-1.5 pt-0.5 max-w-full">
<div class="flex items-center flex-1 min-w-0">
<div class="flex items-center justify-between gap-2 mt-0.5 mb-2 mx-0.5 max-w-full">
<div class="ml-1 flex items-center flex-1 min-w-0">
<slot name="menu">
{#if acceptFiles}
<InputMenu
@@ -1248,32 +1250,23 @@
>
<button
id="input-menu-button"
class="bg-transparent hover:bg-gray-100 text-gray-500 dark:text-gray-400 dark:hover:bg-gray-800 rounded-lg size-7 flex justify-center items-center outline-hidden focus:outline-hidden shrink-0"
class="bg-transparent hover:bg-gray-100/40 text-gray-700 dark:text-white dark:hover:bg-gray-800/40 rounded-full size-[1.875rem] flex justify-center items-center outline-hidden focus:outline-hidden shrink-0"
type="button"
aria-label={$i18n.t('More')}
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
class="size-4"
>
<path
d="M10.75 4.75a.75.75 0 0 0-1.5 0v4.5h-4.5a.75.75 0 0 0 0 1.5h4.5v4.5a.75.75 0 0 0 1.5 0v-4.5h4.5a.75.75 0 0 0 0-1.5h-4.5v-4.5Z"
/>
</svg>
<PlusAlt className="size-5" />
</button>
</InputMenu>
{/if}
</slot>
</div>
<div class="flex items-center gap-1 shrink-0">
<div class="mr-1 flex items-center gap-1 shrink-0">
{#if content === ''}
<Tooltip content={$i18n.t('Record voice')}>
<button
id="voice-input-button"
class=" text-gray-600 dark:text-gray-300 hover:text-gray-700 dark:hover:text-gray-200 transition rounded-lg size-7 flex items-center justify-center"
class=" text-gray-600 dark:text-gray-300 hover:text-gray-700 dark:hover:text-gray-200 transition rounded-full p-1.5 self-center mr-0.5"
type="button"
on:click={async () => {
try {
@@ -1303,17 +1296,7 @@
}}
aria-label={$i18n.t('Voice Input')}
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
class="size-4"
>
<path d="M7 4a3 3 0 016 0v6a3 3 0 11-6 0V4z" />
<path
d="M5.5 9.643a.75.75 0 00-1.5 0V10c0 3.06 2.29 5.585 5.25 5.954V17.5h-1.5a.75.75 0 000 1.5h4.5a.75.75 0 000-1.5h-1.5v-1.546A6.001 6.001 0 0016 10v-.357a.75.75 0 00-1.5 0V10a4.5 4.5 0 01-9 0v-.357z"
/>
</svg>
<Mic className="size-[1.125rem]" />
</button>
</Tooltip>
{/if}
@@ -1324,7 +1307,7 @@
<Tooltip content={$i18n.t('Stop')}>
<button
aria-label={$i18n.t('Stop')}
class="bg-white hover:bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-800 transition rounded-full size-7 flex items-center justify-center"
class="bg-white hover:bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-800 transition rounded-full p-[0.3125rem]"
on:click={() => {
onStop();
}}
@@ -1333,7 +1316,7 @@
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
class="size-4"
class="size-5"
>
<path
fill-rule="evenodd"
@@ -1352,7 +1335,7 @@
aria-label={$i18n.t('Send message')}
class="{content !== '' || files.length !== 0
? 'bg-black text-white hover:bg-gray-900 dark:bg-white dark:text-black dark:hover:bg-gray-100 '
: 'text-white bg-gray-200 dark:text-gray-900 dark:bg-gray-700 disabled'} transition rounded-full size-7 flex items-center justify-center self-center"
: 'text-white bg-gray-200 dark:text-gray-900 dark:bg-gray-700 disabled'} transition rounded-full p-[0.3125rem] self-center"
type="submit"
disabled={content === '' && files.length === 0}
>
@@ -1360,7 +1343,7 @@
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
fill="currentColor"
class="size-4"
class="size-5"
>
<path
fill-rule="evenodd"
+8 -13
View File
@@ -69,14 +69,9 @@
<ChannelInfoModal bind:show={showChannelInfoModal} {channel} {onUpdate} />
{/if}
<nav
class="sticky top-0 z-30 w-full px-1.5 md:px-3 py-1 -mb-8 flex items-center drag-region flex-col"
class="sticky top-0 z-30 w-full shrink-0 px-1.5 md:px-3 pt-0.5 pb-1 flex items-center drag-region flex-col"
>
<div
id="navbar-bg-gradient-to-b"
class=" bg-linear-to-b via-50% from-white via-white to-transparent dark:from-gray-900 dark:via-gray-900 dark:to-transparent pointer-events-none absolute inset-0 -bottom-7 z-[-1]"
></div>
<div class=" flex max-w-full w-full mx-auto pt-0.5 bg-transparent">
<div class=" flex max-w-full w-full mx-auto bg-transparent">
<div class="grid grid-cols-[auto_minmax(0,1fr)_auto] items-center w-full max-w-full">
{#if $mobile && !pageTab}
<div
@@ -90,7 +85,7 @@
>
<button
id="sidebar-toggle-button"
class=" cursor-pointer flex rounded-lg hover:bg-gray-100 dark:hover:bg-gray-850 transition cursor-"
class="flex cursor-pointer rounded-lg text-gray-500 transition hover:bg-gray-50/40 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800/40 dark:hover:text-gray-200"
aria-label={$showSidebar ? $i18n.t('Close Sidebar') : $i18n.t('Open Sidebar')}
on:click={() => {
showSidebar.set(!$showSidebar);
@@ -105,7 +100,7 @@
{/if}
<div
class="col-start-2 row-start-1 min-w-0 overflow-hidden max-w-full py-0.5 flex items-center
class="col-start-2 row-start-1 min-w-0 overflow-hidden max-w-full flex items-center
{$showSidebar ? 'ml-1' : ''}
"
>
@@ -153,7 +148,7 @@
{/if}
<div
class=" min-w-0 truncate text-left text-sm leading-5 text-gray-700 dark:text-gray-300"
class="min-w-0 truncate text-left text-[0.9375rem] font-normal text-gray-700 dark:text-gray-300"
>
{#if channel?.name}
{channel.name}
@@ -176,7 +171,7 @@
{#if channel}
<Tooltip content={$i18n.t('Pinned Messages')}>
<button
class=" flex size-7 items-center justify-center cursor-pointer rounded-lg text-gray-500 dark:text-gray-400 hover:bg-gray-50/60 dark:hover:bg-gray-800/60 transition-colors"
class="flex size-6 items-center justify-center cursor-pointer rounded-lg text-gray-500 transition hover:bg-gray-50/40 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800/40 dark:hover:text-gray-200"
aria-label={$i18n.t('Pinned Messages')}
type="button"
on:click={() => {
@@ -192,7 +187,7 @@
{#if channel?.user_count !== undefined}
<Tooltip content={$i18n.t('Users')}>
<button
class=" flex h-7 items-center cursor-pointer shrink-0 px-1.5 rounded-lg text-gray-500 dark:text-gray-400 hover:bg-gray-50/60 dark:hover:bg-gray-800/60 transition-colors"
class="flex h-6 items-center cursor-pointer shrink-0 px-1.5 rounded-lg text-gray-500 transition hover:bg-gray-50/40 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800/40 dark:hover:text-gray-200"
type="button"
on:click={() => {
showChannelInfoModal = true;
@@ -211,7 +206,7 @@
{/if}
<Tooltip content={$i18n.t('Search')}>
<button
class=" flex size-7 items-center justify-center cursor-pointer rounded-lg text-gray-500 dark:text-gray-400 hover:bg-gray-50/60 dark:hover:bg-gray-800/60 transition-colors"
class="flex size-6 items-center justify-center cursor-pointer rounded-lg text-gray-500 transition hover:bg-gray-50/40 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800/40 dark:hover:text-gray-200"
aria-label={$i18n.t('Search')}
type="button"
on:click={() => {
+1 -1
View File
@@ -5956,7 +5956,7 @@
style="background-image: url({backgroundImage})"
/>
<div
class="pointer-events-none absolute top-0 left-0 w-full h-full bg-linear-to-t from-white to-white/85 dark:from-gray-900 dark:to-gray-900/90 z-0"
class="pointer-events-none absolute top-0 left-0 w-full h-full bg-linear-to-t from-white/95 to-white/70 dark:from-gray-900/95 dark:to-gray-900/75 z-0"
></div>
{/if}
+1 -1
View File
@@ -2234,7 +2234,7 @@
? 'border-dashed border-gray-300/70 dark:border-gray-700/70'
: ' border-gray-200 dark:border-gray-850'} {($settings?.highContrastMode ?? false)
? 'focus-within:outline focus-within:outline-2 focus-within:-outline-offset-2 focus-within:outline-blue-500 [&_.ProseMirror:focus-visible]:outline-none!'
: ''} transition px-0.5 bg-white/5 dark:bg-gray-500/5 backdrop-blur-sm dark:text-gray-100"
: ''} transition px-0.5 bg-white/60 dark:bg-gray-900/50 backdrop-blur-md dark:text-gray-100"
dir={$settings?.chatDirection ?? 'auto'}
>
{#if atSelectedModel !== undefined}
@@ -77,7 +77,6 @@
{#if history.messages[messageId]}
{#if history.messages[messageId].role === 'user'}
<UserMessage
{selectedModels}
{user}
{chatId}
{history}
@@ -137,8 +137,10 @@
let messageSource = history.messages[messageId];
let message: MessageType = structuredClone(messageSource);
$: canBranch =
!message.model?.startsWith('agent:') && !selectedModels.some((id) => id.startsWith('agent:'));
$: isAgent =
message.model?.startsWith('agent:') || selectedModels.some((id) => id.startsWith('agent:'));
// Agents regenerate on a fork of their own conversation; continuing or copying a reply has no turn to fork.
$: canBranch = !isAgent;
$: if (history.messages) {
const source = history.messages[messageId];
if (source) {
@@ -1470,7 +1472,7 @@
{/if}
{#if (!readOnly && (!message.user_id || message.user_id === $user?.id)) || writeAccess}
{#if canBranch && ($user?.role === 'admin' || ($user?.permissions?.chat?.regenerate_response ?? true))}
{#if $user?.role === 'admin' || ($user?.permissions?.chat?.regenerate_response ?? true)}
{#if $settings?.regenerateMenu ?? true}
<button
type="button"
@@ -1511,7 +1513,12 @@
});
}}
>
<Tooltip content={$i18n.t('Regenerate')} placement="bottom">
<Tooltip
content={isAgent
? $i18n.t('Regenerate (file changes are not undone)')
: $i18n.t('Regenerate')}
placement="bottom"
>
<button
type="button"
aria-label={$i18n.t('Regenerate')}
@@ -1556,7 +1563,12 @@
</Tooltip>
</RegenerateMenu>
{:else}
<Tooltip content={$i18n.t('Regenerate')} placement="bottom">
<Tooltip
content={isAgent
? $i18n.t('Regenerate (file changes are not undone)')
: $i18n.t('Regenerate')}
placement="bottom"
>
<button
type="button"
aria-label={$i18n.t('Regenerate')}
@@ -38,7 +38,6 @@
export let chatId;
export let history;
export let messageId;
export let selectedModels: string[] = [];
export let siblings;
@@ -72,9 +71,6 @@
let editScrollContainer: HTMLDivElement;
let message = structuredClone(history.messages[messageId]);
$: canBranch = ![...selectedModels, ...(message.models ?? [])].some((id) =>
id.startsWith('agent:')
);
$: authorId = message.user_id || message.user?.id || user?.id;
$: author =
message.user?.id === authorId
@@ -124,7 +120,6 @@
};
const editMessageConfirmHandler = async (submit = true) => {
if (submit && !canBranch) return;
if (!editedContent && (editedFiles ?? []).length === 0) {
toast.error($i18n.t('Please enter a message or attach a file.'));
return;
@@ -372,17 +367,15 @@
{$i18n.t('Cancel')}
</button>
{#if canBranch}
<button
id="confirm-edit-message-button"
class="flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-lg bg-gray-900 px-2.5 text-xs font-normal text-white transition hover:bg-black disabled:opacity-60 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-white"
on:click={() => {
editMessageConfirmHandler();
}}
>
{$i18n.t('Send')}
</button>
{/if}
<button
id="confirm-edit-message-button"
class="flex h-7 shrink-0 items-center justify-center gap-1.5 rounded-lg bg-gray-900 px-2.5 text-xs font-normal text-white transition hover:bg-black disabled:opacity-60 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-white"
on:click={() => {
editMessageConfirmHandler();
}}
>
{$i18n.t('Send')}
</button>
</div>
</div>
</div>
@@ -134,9 +134,9 @@
{#each groups as group (group.id)}
{@const chats = group.page?.chats ?? []}
{#if group.label}
<!-- An opaque strip behind the header hides rows above it and behind its rounded corners. -->
<div class="sticky top-0 z-[1] mt-1 bg-white pt-0.5 first:mt-0 dark:bg-gray-900">
<div class="group-header flex h-8 items-center gap-2 rounded-xl pl-2 pr-3">
<!-- The header itself is frosted, so rows scrolling under it blur and a chat background image still shows around it. -->
<div class="sticky top-0 z-[1] mt-1 pt-0.5 first:mt-0">
<div class="group-header flex h-8 items-center gap-2 rounded-xl pl-2 pr-3 backdrop-blur-md">
<button
type="button"
class="flex size-5 items-center justify-center rounded-md text-gray-400 hover:text-gray-700 dark:text-gray-500 dark:hover:text-gray-200"
@@ -334,12 +334,12 @@
</div>
<style>
/* A soft, opaque band: the old tint mixed into the page background, so rows never show through. */
/* A translucent tint, so the frosted header picks up the page background. */
.group-header {
background: color-mix(in oklab, var(--color-gray-50) 60%, var(--color-white));
background: color-mix(in oklab, var(--color-gray-50) 80%, transparent);
}
:global(.dark) .group-header {
background: color-mix(in oklab, var(--color-gray-850) 30%, var(--color-gray-900));
background: color-mix(in oklab, var(--color-gray-850) 60%, transparent);
}
/* The menu replaces the date on hover, focus, or while open; touch shows the menu. */
@@ -310,7 +310,9 @@
aria-label={$i18n.t('Conversation board')}
>
<div class="inline-flex min-w-full flex-col">
<div class="sticky top-0 z-[2] flex gap-2 bg-white pb-1 dark:bg-gray-900">
<div
class="sticky top-0 z-[2] flex gap-2 bg-white/80 pb-1 backdrop-blur-md dark:bg-gray-900/80"
>
{#each columns as column (column.id)}
<div class="w-72 shrink-0 rounded-2xl bg-gray-50/80 dark:bg-gray-850/40">
{@render columnHeader(column)}
@@ -10,7 +10,7 @@
: $settings?.chatDirection === 'LTR'
? 'ltr'
: 'auto'}
class="flex-1 flex flex-col relative w-full shadow-sm rounded-2xl border border-gray-100/60 dark:border-gray-800/50 hover:border-gray-100 focus-within:border-gray-100 hover:dark:border-gray-800 focus-within:dark:border-gray-800 transition bg-white dark:bg-gray-400/5 dark:text-gray-100"
class="flex-1 flex flex-col relative w-full shadow-[0_6px_24px_-4px_rgba(0,0,0,0.1)] rounded-3xl border border-gray-200 dark:border-gray-850 transition px-0.5 bg-white/60 dark:bg-gray-900/50 backdrop-blur-md dark:text-gray-100"
>
<slot />
</div>
@@ -22,53 +22,110 @@
import EmojiPicker from '../EmojiPicker.svelte';
import FaceSmile from '$lib/components/icons/FaceSmile.svelte';
import ChevronDown from '$lib/components/icons/ChevronDown.svelte';
import { shortCodesToEmojis } from '$lib/stores';
const headings = [
{ level: 1, label: 'Heading 1', icon: H1 },
{ level: 2, label: 'Heading 2', icon: H2 },
{ level: 3, label: 'Heading 3', icon: H3 }
];
let showHeadingMenu = false;
let headingMenuElement = null;
// Re-evaluated on every editor transaction, since the parent re-renders with the new editor state.
$: activeHeading = editor
? (headings.find((heading) => editor.isActive('heading', { level: heading.level })) ?? null)
: null;
</script>
<svelte:window
on:mousedown={(event) => {
if (
showHeadingMenu &&
event.target instanceof Node &&
!headingMenuElement?.contains(event.target)
) {
showHeadingMenu = false;
}
}}
on:keydown={(event) => {
if (event.key === 'Escape' && showHeadingMenu) showHeadingMenu = false;
}}
/>
<div
class="flex gap-0.5 p-0.5 rounded-xl shadow-lg bg-white text-gray-800 dark:text-white dark:bg-gray-850 min-w-fit border border-gray-100 dark:border-gray-800"
>
<Tooltip placement="top" content={$i18n.t('H1')}>
<button
aria-label={$i18n.t('H1')}
aria-pressed={editor?.isActive('heading', { level: 1 })}
on:click={() => editor?.chain().focus().toggleHeading({ level: 1 }).run()}
class="{editor?.isActive('heading', { level: 1 })
? 'bg-gray-50 dark:bg-gray-700'
: ''} hover:bg-gray-50 dark:hover:bg-gray-700 rounded-lg p-1.5 transition-all"
type="button"
>
<H1 />
</button>
</Tooltip>
<div class="relative flex" bind:this={headingMenuElement}>
<Tooltip placement="top" content={$i18n.t('Heading')}>
<button
aria-label={$i18n.t('Heading')}
aria-haspopup="menu"
aria-expanded={showHeadingMenu}
on:mousedown|preventDefault
on:click={() => (showHeadingMenu = !showHeadingMenu)}
class="{activeHeading || showHeadingMenu
? 'bg-gray-50 dark:bg-gray-700'
: ''} flex items-center gap-0.5 hover:bg-gray-50 dark:hover:bg-gray-700 rounded-lg p-1.5 transition-all"
type="button"
>
{#if activeHeading}
<svelte:component this={activeHeading.icon} />
{:else}
<span class="flex size-4 items-center justify-center text-sm font-medium leading-none"
>T</span
>
{/if}
<ChevronDown className="size-3" strokeWidth="2" />
</button>
</Tooltip>
<Tooltip placement="top" content={$i18n.t('H2')}>
<button
aria-label={$i18n.t('H2')}
aria-pressed={editor?.isActive('heading', { level: 2 })}
on:click={() => editor?.chain().focus().toggleHeading({ level: 2 }).run()}
class="{editor?.isActive('heading', { level: 2 })
? 'bg-gray-50 dark:bg-gray-700'
: ''} hover:bg-gray-50 dark:hover:bg-gray-700 rounded-lg p-1.5 transition-all"
type="button"
>
<H2 />
</button>
</Tooltip>
<Tooltip placement="top" content={$i18n.t('H3')}>
<button
aria-label={$i18n.t('H3')}
aria-pressed={editor?.isActive('heading', { level: 3 })}
on:click={() => editor?.chain().focus().toggleHeading({ level: 3 }).run()}
class="{editor?.isActive('heading', { level: 3 })
? 'bg-gray-50 dark:bg-gray-700'
: ''} hover:bg-gray-50 dark:hover:bg-gray-700 rounded-lg p-1.5 transition-all"
type="button"
>
<H3 />
</button>
</Tooltip>
{#if showHeadingMenu}
<div
role="menu"
class="absolute left-0 top-full mt-1 z-10 flex min-w-36 flex-col gap-0.5 p-1 rounded-xl shadow-lg bg-white text-gray-800 dark:text-white dark:bg-gray-850 border border-gray-100 dark:border-gray-800"
>
<button
role="menuitemradio"
aria-checked={!activeHeading}
on:mousedown|preventDefault
on:click={() => {
editor?.chain().focus().setParagraph().run();
showHeadingMenu = false;
}}
class="{!activeHeading
? 'bg-gray-50 dark:bg-gray-700'
: ''} flex items-center gap-2 px-2 py-1 rounded-lg text-sm hover:bg-gray-50 dark:hover:bg-gray-700 transition-all"
type="button"
>
<span class="flex size-4 items-center justify-center text-sm font-medium leading-none"
>T</span
>
{$i18n.t('Text')}
</button>
{#each headings as heading}
<button
role="menuitemradio"
aria-checked={activeHeading?.level === heading.level}
on:mousedown|preventDefault
on:click={() => {
editor?.chain().focus().toggleHeading({ level: heading.level }).run();
showHeadingMenu = false;
}}
class="{activeHeading?.level === heading.level
? 'bg-gray-50 dark:bg-gray-700'
: ''} flex items-center gap-2 px-2 py-1 rounded-lg text-sm hover:bg-gray-50 dark:hover:bg-gray-700 transition-all"
type="button"
>
<svelte:component this={heading.icon} />
{$i18n.t(heading.label)}
</button>
{/each}
</div>
{/if}
</div>
{#if editor?.isActive('bulletList') || editor?.isActive('orderedList') || editor?.isActive('taskList')}
<Tooltip placement="top" content={$i18n.t('Lift List')}>
+6 -8
View File
@@ -1282,6 +1282,12 @@ ${content}
</button>
</Tooltip>
<CommentButton
className="p-1 bg-transparent hover:bg-white/5 transition rounded-lg"
onComment={(request) => (currentNoteComments = request)}
resource={{ resource_type: 'note', resource_id: note.id }}
/>
{#if note?.write_access}
<RecordMenu
onRecord={async () => {
@@ -1390,14 +1396,6 @@ ${content}
>
<EllipsisHorizontal className="size-5" />
</button>
<svelte:fragment slot="actions" let:close>
<CommentButton
menu
onOpen={close}
onComment={(request) => (currentNoteComments = request)}
resource={{ resource_type: 'note', resource_id: note.id }}
/>
</svelte:fragment>
</NoteMenu>
{#if liveParticipants.length > 0}
@@ -165,8 +165,6 @@
</DropdownSub>
{/if}
<slot name="actions" close={() => (show = false)} />
{#if onPin}
<button
class="select-none flex h-[1.6875rem] w-full cursor-pointer items-center gap-2 rounded-xl bg-transparent px-2 text-[0.8125rem] hover:text-gray-900 dark:hover:text-gray-100"
@@ -1608,6 +1608,10 @@
"Head branch": "",
"Headers": "",
"Headers must be a valid JSON object": "",
"Heading": "",
"Heading 1": "",
"Heading 2": "",
"Heading 3": "",
"Height": "",
"Hello, {{name}}": "",
"Help": "",