mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-23 22:11:28 -05:00
refac
This commit is contained in:
1 parent
58926cfe7b
commit
3e24a08f8e
5 files changed
+211
-89
No files matched your search
@@ -18,6 +18,7 @@ export type GitStatus = {
|
||||
branch: string;
|
||||
head?: string;
|
||||
upstream?: string;
|
||||
remote_url?: string;
|
||||
ahead: number;
|
||||
behind: number;
|
||||
files: GitFile[];
|
||||
@@ -31,6 +32,22 @@ export type GitCommit = {
|
||||
};
|
||||
export type GitBranch = { name: string; current: boolean; upstream: string; is_local?: boolean };
|
||||
|
||||
export function gitRemoteWebUrl(remote = ''): string {
|
||||
const scp = remote.match(/^[^/@:\s]+@([^/:\s]+):(.+)$/);
|
||||
try {
|
||||
const url = new URL(scp ? `https://${scp[1]}/${scp[2]}` : remote);
|
||||
if (url.protocol === 'ssh:') {
|
||||
return new URL(`https://${url.hostname}${url.pathname.replace(/\.git\/?$/, '')}`).href;
|
||||
}
|
||||
if (!['http:', 'https:'].includes(url.protocol)) return '';
|
||||
url.username = url.password = url.search = url.hash = '';
|
||||
url.pathname = url.pathname.replace(/\.git\/?$/, '');
|
||||
return url.href;
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
export async function gitRequest<T>(
|
||||
connection: TerminalConnection,
|
||||
chatId: string | null,
|
||||
@@ -53,8 +70,17 @@ export async function gitRequest<T>(
|
||||
});
|
||||
if (!response.ok) {
|
||||
const error = await response.json().catch(() => null);
|
||||
if (response.status === 404 && error?.detail === 'Not Found') {
|
||||
throw new Error(
|
||||
'Git support is unavailable on this connection. Update and restart Open Terminal.'
|
||||
);
|
||||
}
|
||||
throw new Error(
|
||||
typeof error?.detail === 'string' ? error.detail : `Git request failed (${response.status})`
|
||||
typeof error?.detail === 'string'
|
||||
? error.detail
|
||||
: typeof error?.error === 'string'
|
||||
? error.error
|
||||
: `Git request failed (${response.status})`
|
||||
);
|
||||
}
|
||||
return response.json();
|
||||
|
||||
@@ -684,6 +684,7 @@
|
||||
class:hidden={!$showTabs || !panelTarget}
|
||||
use:placePanel={$showTabs ? panelTarget : null}
|
||||
class="h-full w-full min-h-0 flex flex-col"
|
||||
style:--chat-tabs-dark-background={largeScreen ? 'var(--color-gray-900)' : 'var(--color-gray-850)'}
|
||||
id="controls-container"
|
||||
>
|
||||
<div class="flex items-center px-2 pt-1 pb-1 gap-1 shrink-0 select-none">
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import {
|
||||
gitRequest,
|
||||
gitAction,
|
||||
gitRemoteWebUrl,
|
||||
type GitStatus,
|
||||
type GitFile,
|
||||
type GitCommit,
|
||||
@@ -11,6 +12,7 @@
|
||||
} from '$lib/apis/terminal/git';
|
||||
import Icon from '../FileNav/Icon.svelte';
|
||||
import GitDiff from './GitDiff.svelte';
|
||||
import { parseDiffRows } from '../Messages/diff';
|
||||
import Dropdown from '../../common/Dropdown.svelte';
|
||||
import DropdownMenu from '../../common/DropdownMenu.svelte';
|
||||
import ConfirmDialog from '../../common/ConfirmDialog.svelte';
|
||||
@@ -34,6 +36,14 @@
|
||||
let selected: { path: string; staged: boolean; untracked: boolean } | null = null;
|
||||
let selectedCommit: GitCommit | null = null;
|
||||
let diff = '';
|
||||
$: diffStats = parseDiffRows(diff).reduce(
|
||||
(counts, row) => {
|
||||
if (row.type === 'addition') counts.additions++;
|
||||
if (row.type === 'deletion') counts.deletions++;
|
||||
return counts;
|
||||
},
|
||||
{ additions: 0, deletions: 0 }
|
||||
);
|
||||
let commits: GitCommit[] = [];
|
||||
let branches: GitBranch[] = [];
|
||||
let branchSearch = '';
|
||||
@@ -54,6 +64,7 @@
|
||||
let summary = '';
|
||||
let description = '';
|
||||
let error = '';
|
||||
let detectionError = '';
|
||||
let busy = false;
|
||||
let loadingDiff = false;
|
||||
let confirmDiscard = false;
|
||||
@@ -76,6 +87,16 @@
|
||||
$: additions = status?.files.reduce((sum, file) => sum + file.additions, 0) ?? 0;
|
||||
$: deletions = status?.files.reduce((sum, file) => sum + file.deletions, 0) ?? 0;
|
||||
$: branchLabel = status?.branch === '(detached)' ? status.head?.slice(0, 7) : status?.branch;
|
||||
$: remoteWebUrl = gitRemoteWebUrl(status?.remote_url);
|
||||
$: remoteHost = remoteWebUrl ? new URL(remoteWebUrl).hostname : '';
|
||||
$: remotePlatform =
|
||||
remoteHost === 'github.com'
|
||||
? 'GitHub'
|
||||
: remoteHost.includes('gitlab')
|
||||
? 'GitLab'
|
||||
: remoteHost === 'bitbucket.org'
|
||||
? 'Bitbucket'
|
||||
: remoteHost;
|
||||
$: syncAction = !status?.upstream
|
||||
? 'publish'
|
||||
: status.behind > 0
|
||||
@@ -110,6 +131,7 @@
|
||||
const task = gitRequest<GitStatus>(connection, chatId, directory, 'status')
|
||||
.then((next) => {
|
||||
if (current !== generation) return;
|
||||
detectionError = '';
|
||||
if (status?.root && status.root !== next.root) resetSelection();
|
||||
status = next.is_repo ? next : null;
|
||||
if (next.root && next.root !== prRoot) {
|
||||
@@ -131,8 +153,11 @@
|
||||
)
|
||||
resetSelection();
|
||||
})
|
||||
.catch(() => {
|
||||
if (current === generation) status = null;
|
||||
.catch((reason) => {
|
||||
if (current === generation) {
|
||||
status = null;
|
||||
detectionError = String(reason instanceof Error ? reason.message : reason);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
if (current === generation) pending = null;
|
||||
@@ -155,6 +180,7 @@
|
||||
pending = null;
|
||||
status = null;
|
||||
error = '';
|
||||
detectionError = '';
|
||||
expanded = false;
|
||||
showBranches =
|
||||
showWorktrees =
|
||||
@@ -278,9 +304,6 @@
|
||||
files.flatMap((file) => [file.path, ...(file.original_path ? [file.original_path] : [])])
|
||||
)
|
||||
];
|
||||
const openFile = () => {
|
||||
if (selected && status?.root) onOpenFile(`${status.root}/${selected.path}`);
|
||||
};
|
||||
const toggle = () => {
|
||||
expanded = !expanded;
|
||||
if (expanded) {
|
||||
@@ -343,14 +366,14 @@
|
||||
}}
|
||||
></div>
|
||||
{/if}
|
||||
<div class="flex min-w-0 items-center h-7 px-3 text-gray-400 dark:text-gray-600">
|
||||
<div class="flex min-w-0 items-center h-7 pl-3 pr-1 text-gray-400 dark:text-gray-600">
|
||||
<Dropdown side="top" maxHeight="15rem" bind:show={showBranches} onOpenChange={loadBranches}>
|
||||
<button
|
||||
class="flex min-w-0 max-w-32 shrink items-center gap-1.5 h-6 -ml-1.5 px-1.5 rounded-md hover:bg-gray-100/30 dark:hover:bg-gray-800/20 transition-colors duration-75"
|
||||
class="group/selector flex min-w-0 max-w-32 shrink items-center gap-1.5 h-6 -ml-1.5 px-1.5 rounded-md hover:text-gray-700 dark:hover:text-gray-300 transition-colors duration-75"
|
||||
aria-label={$i18n.t('Switch branch')}
|
||||
disabled={busy}
|
||||
><Icon name="git-branch" size={12} /><span
|
||||
class="min-w-0 truncate whitespace-nowrap text-[0.6875rem] text-gray-600 dark:text-gray-400 font-mono"
|
||||
class="min-w-0 truncate whitespace-nowrap text-[0.6875rem] text-gray-600 dark:text-gray-400 group-hover/selector:text-gray-700 dark:group-hover/selector:text-gray-300 font-mono"
|
||||
>{branchLabel}</span
|
||||
><Icon name="chevron-down" size={9} /></button
|
||||
>
|
||||
@@ -454,12 +477,12 @@
|
||||
</Dropdown>
|
||||
<Dropdown side="top" maxHeight="15rem" bind:show={showWorktrees} onOpenChange={loadWorktrees}>
|
||||
<button
|
||||
class="flex min-w-0 max-w-32 shrink items-center gap-1.5 h-6 px-1.5 rounded-md hover:bg-gray-100/30 dark:hover:bg-gray-800/20 transition-colors duration-75"
|
||||
class="group/selector flex min-w-0 max-w-32 shrink items-center gap-1.5 h-6 px-1.5 rounded-md hover:text-gray-700 dark:hover:text-gray-300 transition-colors duration-75"
|
||||
aria-label={$i18n.t('Worktrees')}
|
||||
disabled={busy}
|
||||
>
|
||||
<Icon name="folder" size={12} /><span
|
||||
class="min-w-0 truncate whitespace-nowrap text-[0.6875rem] text-gray-500 dark:text-gray-500 font-mono"
|
||||
class="min-w-0 truncate whitespace-nowrap text-[0.6875rem] text-gray-500 dark:text-gray-500 group-hover/selector:text-gray-700 dark:group-hover/selector:text-gray-300 font-mono"
|
||||
>{status.root?.split('/').pop()}</span
|
||||
><Icon name="chevron-down" size={9} />
|
||||
</button>
|
||||
@@ -545,22 +568,18 @@
|
||||
></span
|
||||
>{/if}
|
||||
</button>
|
||||
<Tooltip content={$i18n.t(syncLabel)}>
|
||||
<button
|
||||
class="flex shrink-0 items-center justify-center h-6 w-6 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors duration-75"
|
||||
aria-label={$i18n.t(syncLabel)}
|
||||
on:click={() => act(syncAction)}
|
||||
disabled={busy}><Icon name={syncIcon} size={10} /></button
|
||||
>
|
||||
</Tooltip>
|
||||
<button
|
||||
class="flex shrink-0 items-center gap-1 h-6 px-2 rounded-md text-[0.6875rem] text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100/30 dark:hover:bg-gray-800/20 transition-colors duration-75"
|
||||
on:click={() => act(syncAction)}
|
||||
disabled={busy}
|
||||
><Icon name={syncIcon} size={12} /><span class="whitespace-nowrap"
|
||||
>{$i18n.t(syncLabel)}{syncAction === 'push'
|
||||
? ` ↑${status.ahead}`
|
||||
: syncAction === 'pull'
|
||||
? ` ↓${status.behind}`
|
||||
: ''}</span
|
||||
></button
|
||||
>
|
||||
<button
|
||||
class="flex h-6 w-3 items-center justify-center text-gray-300 dark:text-gray-700 ml-0.5 shrink-0"
|
||||
class="flex h-6 w-5 items-center justify-center text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 ml-0.5 shrink-0"
|
||||
aria-label={expanded ? $i18n.t('Collapse Git panel') : $i18n.t('Expand Git panel')}
|
||||
on:click={toggle}><Icon name={expanded ? 'chevron-down' : 'chevron-up'} size={10} /></button
|
||||
on:click={toggle}><Icon name={expanded ? 'chevron-down' : 'chevron-up'} size={14} /></button
|
||||
>
|
||||
</div>
|
||||
{#if error}<div role="alert" class="px-3 py-2 text-xs text-red-500 break-words">
|
||||
@@ -568,14 +587,14 @@
|
||||
</div>{/if}
|
||||
{#if expanded}
|
||||
<div
|
||||
class="flex flex-col min-h-0 max-h-[65dvh] border-t border-gray-100 dark:border-white/4"
|
||||
class="flex flex-col min-h-0 max-h-[65dvh] border-t border-gray-100/50 dark:border-white/2"
|
||||
style:height={`${height + 32}px`}
|
||||
>
|
||||
<div
|
||||
class="flex items-center gap-0.5 px-1 h-8 shrink-0 border-b border-gray-100 dark:border-white/4"
|
||||
class="flex items-center gap-0.5 px-1 h-8 shrink-0 border-b border-gray-100/50 dark:border-white/2"
|
||||
>
|
||||
{#each ['changes', 'history', ...(prCapabilities?.available ? ['pull requests'] : [])] as section}<button
|
||||
class="px-2.5 h-6 shrink-0 rounded-md text-[0.6875rem] font-normal transition-colors duration-75 {view ===
|
||||
class="px-2.5 py-0.5 shrink-0 rounded-md text-[0.6875rem] font-normal transition-colors duration-75 {view ===
|
||||
section
|
||||
? 'bg-gray-100/40 dark:bg-gray-800/25 text-gray-900 dark:text-white'
|
||||
: 'text-gray-400 hover:text-gray-600 dark:hover:text-gray-300'}"
|
||||
@@ -595,10 +614,22 @@
|
||||
>{/if}</button
|
||||
>{/each}
|
||||
<div class="flex-1"></div>
|
||||
{#if remoteWebUrl}
|
||||
<Tooltip content={$i18n.t('View on {{platform}}', { platform: remotePlatform })}>
|
||||
<a
|
||||
href={remoteWebUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
aria-label={$i18n.t('View on {{platform}}', { platform: remotePlatform })}
|
||||
class="flex items-center justify-center w-5 h-4 py-0.5 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"
|
||||
><Icon name="external-link" size={10} /></a
|
||||
>
|
||||
</Tooltip>
|
||||
{/if}
|
||||
<Dropdown side="top" align="end">
|
||||
<button
|
||||
class="flex items-center justify-center w-6 h-6 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/6"
|
||||
aria-label={$i18n.t('Diff settings')}><Icon name="settings" size={12} /></button
|
||||
class="flex items-center justify-center w-5 h-4 py-0.5 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"
|
||||
aria-label={$i18n.t('Diff settings')}><Icon name="settings" size={10} /></button
|
||||
>
|
||||
<div slot="content">
|
||||
<DropdownMenu className="w-48"
|
||||
@@ -662,14 +693,14 @@
|
||||
{#if view === 'changes'}
|
||||
{#if status.files.length}
|
||||
<button
|
||||
class="flex min-w-0 items-center gap-1.5 h-7 px-2.5 border-b border-gray-100 dark:border-white/4 hover:bg-gray-50 dark:hover:bg-white/3 shrink-0"
|
||||
class="flex min-w-0 items-center gap-1.5 h-7 px-2.5 border-b border-gray-100/50 dark:border-white/2 hover:bg-gray-50 dark:hover:bg-white/3 shrink-0"
|
||||
disabled={busy}
|
||||
aria-label={$i18n.t(allStaged ? 'Unstage all' : 'Stage all')}
|
||||
on:click={() =>
|
||||
act(allStaged ? 'unstage' : 'stage', { paths: paths(status?.files ?? []) })}
|
||||
>
|
||||
<span
|
||||
class="flex items-center justify-center w-3 h-3 rounded border shrink-0 border-gray-300 dark:border-gray-600 {allStaged
|
||||
class="flex items-center justify-center w-3 h-3 me-1 rounded border shrink-0 border-gray-300 dark:border-gray-600 {allStaged
|
||||
? 'bg-gray-800 dark:bg-white'
|
||||
: someStaged
|
||||
? 'bg-gray-400 dark:bg-gray-500'
|
||||
@@ -697,7 +728,7 @@
|
||||
: 'hover:bg-gray-50 dark:hover:bg-white/3'}"
|
||||
>
|
||||
<button
|
||||
class="flex items-center justify-center w-3 h-3 rounded border shrink-0 border-gray-300 dark:border-gray-600 {file.staged
|
||||
class="flex items-center justify-center w-3 h-3 me-1 rounded border shrink-0 border-gray-300 dark:border-gray-600 {file.staged
|
||||
? 'bg-gray-800 dark:bg-white'
|
||||
: 'hover:border-gray-500 dark:hover:border-gray-400'}"
|
||||
disabled={busy}
|
||||
@@ -711,20 +742,27 @@
|
||||
class="text-white dark:text-black"
|
||||
/>{/if}
|
||||
</button>
|
||||
<button
|
||||
class="flex min-w-0 flex-1 items-center gap-1.5 text-left h-full"
|
||||
aria-label={`${$i18n.t('View changes')} ${file.path}`}
|
||||
on:click={() => selectFile(file, file.staged)}
|
||||
>
|
||||
{#if file.path.includes('/')}<span
|
||||
<div class="flex min-w-0 flex-1 items-center gap-0.5 h-full">
|
||||
{#if file.path.includes('/')}<button
|
||||
class="min-w-0 truncate text-[0.625rem] text-gray-400 dark:text-gray-600"
|
||||
>{file.path.slice(0, file.path.lastIndexOf('/') + 1)}</span
|
||||
aria-label={`${$i18n.t('View changes')} ${file.path}`}
|
||||
on:click={() => selectFile(file, file.staged)}
|
||||
>{file.path.slice(0, file.path.lastIndexOf('/') + 1)}</button
|
||||
>{/if}
|
||||
<span
|
||||
class="min-w-0 truncate text-[0.6875rem] text-gray-800 dark:text-gray-200"
|
||||
>{file.path.split('/').pop()}</span
|
||||
<button
|
||||
class="min-w-0 truncate text-[0.6875rem] text-gray-800 dark:text-gray-200 hover:underline"
|
||||
aria-label={`${$i18n.t('Open file')} ${file.path}`}
|
||||
on:click={() => {
|
||||
if (status?.root)
|
||||
onOpenFile(`${status.root.replace(/\/$/, '')}/${file.path}`);
|
||||
}}>{file.path.split('/').pop()}</button
|
||||
>
|
||||
</button>
|
||||
<button
|
||||
class="min-w-0 flex-1 self-stretch"
|
||||
aria-label={`${$i18n.t('View changes')} ${file.path}`}
|
||||
on:click={() => selectFile(file, file.staged)}
|
||||
></button>
|
||||
</div>
|
||||
{#if file.binary}<span
|
||||
class="text-[0.625rem] font-mono font-normal text-gray-400"
|
||||
title={file.status}
|
||||
@@ -775,7 +813,7 @@
|
||||
</div>{/if}
|
||||
</div>
|
||||
<form
|
||||
class="border-t border-gray-100 dark:border-white/4 px-2 pb-1.5 shrink-0"
|
||||
class="border-t border-gray-100/50 dark:border-white/2 px-2 pb-1.5 shrink-0"
|
||||
on:submit|preventDefault={() =>
|
||||
act('commit', {
|
||||
message: [summary.trim(), description.trim()].filter(Boolean).join('\n\n')
|
||||
@@ -789,7 +827,7 @@
|
||||
bind:value={summary}
|
||||
/>
|
||||
<textarea
|
||||
class="block w-full px-1 py-1 bg-transparent text-[0.6875rem] text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-gray-600 outline-none resize-none border-t border-gray-100 dark:border-white/4"
|
||||
class="block w-full px-1 py-1 bg-transparent text-[0.6875rem] text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-gray-600 outline-none resize-none border-t border-gray-100/50 dark:border-white/2"
|
||||
rows="3"
|
||||
aria-label={$i18n.t('Description')}
|
||||
placeholder={$i18n.t('Description')}
|
||||
@@ -816,29 +854,30 @@
|
||||
{:else}
|
||||
<div class="min-h-0 flex-1 overflow-y-auto scrollbar-hidden">
|
||||
{#each commits as commit, index}<div
|
||||
class="group flex min-w-0 items-center border-b border-gray-50 dark:border-white/3 transition-colors duration-75 {selectedCommit?.hash === commit.hash
|
||||
class="group flex min-w-0 items-center border-b border-gray-50/50 dark:border-white/2 transition-colors duration-75 {selectedCommit?.hash ===
|
||||
commit.hash
|
||||
? 'bg-gray-100/40 dark:bg-gray-800/25'
|
||||
: 'hover:bg-gray-100/30 dark:hover:bg-gray-800/20'}"
|
||||
>
|
||||
<Tooltip content={commit.hash} className="flex min-w-0 flex-1"><button
|
||||
class="flex min-w-0 flex-1 items-center gap-1.5 px-2.5 py-1.5 text-left"
|
||||
on:click={() => selectCommit(commit)}
|
||||
>
|
||||
{#if index < status.ahead}<span
|
||||
class="w-1.5 h-1.5 rounded-full bg-blue-500 dark:bg-blue-400 shrink-0"
|
||||
title={$i18n.t('Unpushed')}
|
||||
></span>{/if}
|
||||
<div class="flex flex-col min-w-0 flex-1">
|
||||
<span class="text-xs text-gray-800 dark:text-gray-200 truncate"
|
||||
>{commit.message}</span
|
||||
><span
|
||||
class="text-[0.625rem] text-gray-400 dark:text-gray-600 font-mono truncate"
|
||||
>{commit.author} · {relativeTime(
|
||||
commit.date
|
||||
)}</span
|
||||
>
|
||||
</div>
|
||||
</button></Tooltip><Dropdown side="top" align="end" closeOnSelect
|
||||
<Tooltip content={commit.hash} className="flex min-w-0 flex-1"
|
||||
><button
|
||||
class="flex min-w-0 flex-1 items-center gap-1.5 px-2.5 py-1.5 text-left"
|
||||
on:click={() => selectCommit(commit)}
|
||||
>
|
||||
{#if index < status.ahead}<span
|
||||
class="w-1.5 h-1.5 rounded-full bg-blue-500 dark:bg-blue-400 shrink-0"
|
||||
title={$i18n.t('Unpushed')}
|
||||
></span>{/if}
|
||||
<div class="flex flex-col min-w-0 flex-1">
|
||||
<span class="text-xs text-gray-800 dark:text-gray-200 truncate"
|
||||
>{commit.message}</span
|
||||
><span
|
||||
class="text-[0.625rem] text-gray-400 dark:text-gray-600 font-mono truncate"
|
||||
>{commit.author} · {relativeTime(commit.date)}</span
|
||||
>
|
||||
</div>
|
||||
</button></Tooltip
|
||||
><Dropdown side="top" align="end" closeOnSelect
|
||||
><button
|
||||
class="flex items-center justify-center w-5 h-5 mr-1 rounded shrink-0 opacity-0 group-hover:opacity-100 focus:opacity-100 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"
|
||||
aria-label={`${$i18n.t('Commit actions')} ${commit.short_hash}`}
|
||||
@@ -877,7 +916,7 @@
|
||||
>
|
||||
{#if selected || selectedCommit}
|
||||
<div
|
||||
class="flex items-center gap-2 px-2 h-6 shrink-0 border-b border-gray-100 dark:border-white/4 text-[0.625rem] font-mono text-gray-400 dark:text-gray-600"
|
||||
class="flex items-center gap-2 px-2 h-6 shrink-0 border-b border-gray-100/50 dark:border-white/2 text-[0.625rem] font-mono text-gray-400 dark:text-gray-600"
|
||||
>
|
||||
<button
|
||||
class="git-back"
|
||||
@@ -887,10 +926,11 @@
|
||||
>{selected?.path ??
|
||||
`${selectedCommit?.short_hash} · ${selectedCommit?.message}`}</span
|
||||
>
|
||||
{#if selected}<button
|
||||
class="shrink-0"
|
||||
aria-label={$i18n.t('Open file')}
|
||||
on:click={openFile}><Icon name="external-link" size={12} /></button
|
||||
{#if diff && !loadingDiff}<span
|
||||
class="ml-2 shrink-0 text-green-600 dark:text-green-400"
|
||||
>+{diffStats.additions}</span
|
||||
><span class="shrink-0 text-red-500 dark:text-red-400"
|
||||
>-{diffStats.deletions}</span
|
||||
>{/if}
|
||||
</div>
|
||||
<div class="min-h-0 flex-1 overflow-auto scrollbar-hidden text-[0.6875rem]">
|
||||
@@ -921,6 +961,20 @@
|
||||
</div>
|
||||
{/if}
|
||||
</section>
|
||||
{:else if detectionError}
|
||||
<div
|
||||
class="flex h-7 shrink-0 items-center gap-1.5 border-t border-gray-200 dark:border-white/6 px-3 text-[0.6875rem] text-gray-500 dark:text-gray-400"
|
||||
>
|
||||
<Icon name="git-branch" size={12} />
|
||||
<Tooltip content={detectionError} className="min-w-0 flex-1"
|
||||
><span>{$i18n.t('Git unavailable')}</span></Tooltip
|
||||
>
|
||||
<button
|
||||
class="flex h-6 w-6 items-center justify-center rounded-md hover:bg-gray-100/30 dark:hover:bg-gray-800/20"
|
||||
aria-label={$i18n.t('Retry Git detection')}
|
||||
on:click={() => refresh(true)}><Icon name="refresh" size={12} /></button
|
||||
>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<ConfirmDialog
|
||||
@@ -975,7 +1029,7 @@
|
||||
.git-list.showing-diff {
|
||||
display: flex;
|
||||
flex: 0 0 240px;
|
||||
border-inline-end: 1px solid #80808018;
|
||||
border-inline-end: 1px solid #8080800c;
|
||||
}
|
||||
.git-detail {
|
||||
display: flex;
|
||||
|
||||
@@ -36,13 +36,13 @@
|
||||
<div class="git-diff font-mono text-[0.6875rem] leading-[1.125rem]" class:split={mode === 'split'}>
|
||||
{#each files as file}
|
||||
{#if files.length > 1}<div
|
||||
class="px-2 py-1 text-[0.625rem] text-gray-500 dark:text-gray-400 border-b border-gray-100 dark:border-white/4"
|
||||
class="sticky top-0 z-10 bg-white dark:bg-[var(--chat-tabs-dark-background,var(--color-gray-900))] px-2 py-1 text-[0.625rem] text-gray-500 dark:text-gray-400 border-b border-gray-100/50 dark:border-white/2"
|
||||
>
|
||||
{file.path}
|
||||
</div>{/if}
|
||||
{#each file.hunks as hunk, index}
|
||||
<div
|
||||
class="border-b border-gray-100 bg-gray-50 px-2 py-0.5 text-gray-400 dark:border-white/4 dark:bg-white/3 dark:text-gray-600"
|
||||
class="border-b border-gray-100/50 bg-gray-50 px-2 py-0.5 text-gray-400 dark:border-white/2 dark:bg-white/3 dark:text-gray-600"
|
||||
>
|
||||
{file.headers[index]}
|
||||
</div>
|
||||
@@ -73,6 +73,7 @@
|
||||
.line {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
min-height: 1.125rem;
|
||||
}
|
||||
.prefix {
|
||||
width: 1.25rem;
|
||||
@@ -96,14 +97,14 @@
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.split-row > .line + .line {
|
||||
border-left: 1px solid #80808018;
|
||||
border-left: 1px solid #8080800c;
|
||||
}
|
||||
.added {
|
||||
background: var(--color-green-100);
|
||||
background-color: var(--color-green-100);
|
||||
color: var(--color-green-900);
|
||||
}
|
||||
.removed {
|
||||
background: var(--color-red-100);
|
||||
background-color: var(--color-red-100);
|
||||
color: var(--color-red-900);
|
||||
}
|
||||
.added .prefix {
|
||||
@@ -112,21 +113,61 @@
|
||||
.removed .prefix {
|
||||
color: var(--color-red-500);
|
||||
}
|
||||
.git-diff:not(.split) .added {
|
||||
box-shadow: inset 0.1875rem 0 0 #22c55e;
|
||||
}
|
||||
.git-diff:not(.split) .removed {
|
||||
background-image: repeating-linear-gradient(
|
||||
-45deg,
|
||||
#ef4444 0,
|
||||
#ef4444 1px,
|
||||
transparent 1px,
|
||||
transparent 0.1875rem
|
||||
);
|
||||
background-position: left top;
|
||||
background-repeat: repeat-y;
|
||||
background-size: 0.1875rem 0.1875rem;
|
||||
}
|
||||
.changed {
|
||||
border-radius: 0.125rem;
|
||||
box-decoration-break: clone;
|
||||
-webkit-box-decoration-break: clone;
|
||||
padding: 0.0625rem 0.125rem;
|
||||
}
|
||||
.added .changed {
|
||||
background: #16a34a35;
|
||||
background: rgba(22, 163, 74, 0.38);
|
||||
box-shadow: inset 0 -0.125rem 0 rgba(21, 128, 61, 0.42);
|
||||
}
|
||||
.removed .changed {
|
||||
background: #dc262630;
|
||||
background: rgba(220, 38, 38, 0.32);
|
||||
box-shadow: inset 0 -0.125rem 0 rgba(185, 28, 28, 0.38);
|
||||
}
|
||||
:global(.dark) .git-diff {
|
||||
color: var(--color-gray-400);
|
||||
}
|
||||
:global(.dark) .added {
|
||||
background: #22c55e26;
|
||||
background-color: #22c55e26;
|
||||
color: var(--color-green-300);
|
||||
}
|
||||
:global(.dark) .removed {
|
||||
background: #ef444426;
|
||||
background-color: #ef444426;
|
||||
color: var(--color-red-300);
|
||||
}
|
||||
:global(.dark) .git-diff:not(.split) .added {
|
||||
box-shadow: inset 0.1875rem 0 0 #4ade80;
|
||||
}
|
||||
:global(.dark) .added .prefix {
|
||||
color: var(--color-green-400);
|
||||
}
|
||||
:global(.dark) .removed .prefix {
|
||||
color: var(--color-red-400);
|
||||
}
|
||||
:global(.dark) .added .changed {
|
||||
background: rgba(34, 197, 94, 0.42);
|
||||
box-shadow: inset 0 -0.125rem 0 rgba(134, 239, 172, 0.5);
|
||||
}
|
||||
:global(.dark) .removed .changed {
|
||||
background: rgba(248, 113, 113, 0.4);
|
||||
box-shadow: inset 0 -0.125rem 0 rgba(252, 165, 165, 0.48);
|
||||
}
|
||||
</style>
|
||||
@@ -162,7 +162,7 @@
|
||||
class="pr-list flex min-h-0 min-w-0 flex-1 flex-col"
|
||||
class:has-selection={!!selected || creating || editing}
|
||||
>
|
||||
<div class="border-b border-gray-100 p-2 dark:border-white/4">
|
||||
<div class="border-b border-gray-100/50 p-2 dark:border-white/2">
|
||||
<div class="flex min-w-0 items-center gap-1">
|
||||
{#each ['open', 'closed', 'all'] as option}<button
|
||||
class="h-6 rounded-md px-2 text-[0.6875rem] font-normal transition-colors duration-75 {state ===
|
||||
@@ -213,7 +213,7 @@
|
||||
</p>{:else}{#each prs.filter((pr) => `${pr.number} ${pr.title}`
|
||||
.toLowerCase()
|
||||
.includes(search.toLowerCase())) as pr}<button
|
||||
class="flex min-w-0 items-center gap-1.5 w-full px-2.5 py-1.5 text-left border-b border-gray-50 dark:border-white/3 {selected?.number ===
|
||||
class="flex min-w-0 items-center gap-1.5 w-full px-2.5 py-1.5 text-left border-b border-gray-50/50 dark:border-white/2 {selected?.number ===
|
||||
pr.number
|
||||
? 'bg-gray-100/40 dark:bg-gray-800/25'
|
||||
: 'hover:bg-gray-50 dark:hover:bg-white/3'}"
|
||||
@@ -238,7 +238,7 @@
|
||||
class:has-selection={!!selected || creating || editing}
|
||||
>
|
||||
<div
|
||||
class="flex items-center gap-2 px-2 h-7 shrink-0 border-b border-gray-100 dark:border-white/4 text-gray-500 dark:text-gray-400"
|
||||
class="flex items-center gap-2 px-2 h-7 shrink-0 border-b border-gray-100/50 dark:border-white/2 text-gray-500 dark:text-gray-400"
|
||||
>
|
||||
{#if selected || creating || editing}<button
|
||||
class="pr-back"
|
||||
@@ -327,7 +327,7 @@
|
||||
</form>
|
||||
{:else if selected}
|
||||
<div
|
||||
class="flex gap-1 px-2 h-7 items-center shrink-0 border-b border-gray-100 dark:border-white/4"
|
||||
class="flex gap-1 px-2 h-7 items-center shrink-0 border-b border-gray-100/50 dark:border-white/2"
|
||||
>
|
||||
{#each ['summary', 'code', 'checks', 'activity'] as tab}<button
|
||||
class="h-5 rounded px-1.5 text-[0.625rem] font-normal {view === tab
|
||||
@@ -372,7 +372,7 @@
|
||||
class="truncate">{selected.mergeable ?? 'unknown'}</span
|
||||
>
|
||||
</div>
|
||||
<div class="mt-2 border-t border-gray-100 pt-2 dark:border-white/4">
|
||||
<div class="mt-2 border-t border-gray-100/50 pt-2 dark:border-white/2">
|
||||
<div class="mb-1 text-[0.625rem] uppercase text-gray-300 dark:text-gray-600">
|
||||
{$i18n.t('Description')}
|
||||
</div>
|
||||
@@ -383,7 +383,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="mt-2 flex flex-wrap gap-1 border-t border-gray-100 pt-2 dark:border-white/4"
|
||||
class="mt-2 flex flex-wrap gap-1 border-t border-gray-100/50 pt-2 dark:border-white/2"
|
||||
>
|
||||
{#if selected.state === 'OPEN'}<button
|
||||
class="pr-action"
|
||||
@@ -417,7 +417,7 @@
|
||||
</div>
|
||||
{:else if view === 'checks'}<div class="min-h-0">
|
||||
{#each selected.statusCheckRollup ?? [] as check}<div
|
||||
class="flex items-center justify-between gap-2 border-b border-gray-50 px-2.5 py-1.5 dark:border-white/3"
|
||||
class="flex items-center justify-between gap-2 border-b border-gray-50/50 px-2.5 py-1.5 dark:border-white/2"
|
||||
>
|
||||
<span class="truncate">{check.name ?? check.context}</span><span
|
||||
class="text-gray-400 text-[10px]"
|
||||
@@ -488,7 +488,7 @@
|
||||
.pr-list.has-selection {
|
||||
display: flex;
|
||||
flex: 0 0 240px;
|
||||
border-inline-end: 1px solid #80808018;
|
||||
border-inline-end: 1px solid #8080800c;
|
||||
}
|
||||
.pr-detail {
|
||||
display: flex;
|
||||
|
||||
Reference in new issue
Block a user