mirror of
https://github.com/open-webui/computer.git
synced 2026-11-23 06:00:43 -05:00
25 files changed
+562
-207
No files matched your search
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.8.8] - 2026-07-09
|
||||
|
||||
### Added
|
||||
|
||||
- ✨ **More flexible layouts.** Split any view again and again, resize each section, and drag tabs exactly where you want them.
|
||||
- 🤖 **Commit-writing help.** Get a suggested commit title and description from your staged work.
|
||||
- 📁 **Create folders as you browse.** Make a new folder without leaving the workspace picker.
|
||||
- 💬 **An easy way to share feedback.** Send feature ideas from the sidebar.
|
||||
|
||||
### Fixed
|
||||
|
||||
- 👀 **Updates stay dismissed.** Closing the update notes no longer brings them back after a quick refresh.
|
||||
|
||||
## [0.8.7] - 2026-07-09
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -68,6 +68,12 @@ export const discardChanges = (root: string, files: string[]) =>
|
||||
export const gitCommit = (root: string, message: string) =>
|
||||
fetchJSON('/api/git/commit', jsonBody({ root, message }));
|
||||
|
||||
export const generateGitCommitMessage = (root: string, modelId?: string) =>
|
||||
fetchJSON<{ summary: string; description: string }>(
|
||||
'/api/git/message',
|
||||
jsonBody({ root, model_id: modelId || undefined })
|
||||
);
|
||||
|
||||
export const gitPull = (root: string) => fetchJSON('/api/git/pull', jsonBody({ root }));
|
||||
|
||||
export const gitFetch = (root: string) => fetchJSON('/api/git/fetch', jsonBody({ root }));
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
active: direction === 'horizontal',
|
||||
onclick: () => {
|
||||
setSplitDirection('horizontal');
|
||||
if (!$splitActive) splitCurrentTab('horizontal');
|
||||
splitCurrentTab('horizontal');
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -44,7 +44,7 @@
|
||||
active: direction === 'vertical',
|
||||
onclick: () => {
|
||||
setSplitDirection('vertical');
|
||||
if (!$splitActive) splitCurrentTab('vertical');
|
||||
splitCurrentTab('vertical');
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { fetchJSON } from '$lib/apis';
|
||||
import Modal from './Modal.svelte';
|
||||
import Icon from './Icon.svelte';
|
||||
import { savePreferences } from '$lib/apis/state';
|
||||
import { appVersion, lastSeenVersion, showChangelog } from '$lib/stores';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
import { t } from '$lib/i18n';
|
||||
@@ -29,6 +30,8 @@
|
||||
function handleClose() {
|
||||
if ($appVersion) {
|
||||
lastSeenVersion.set($appVersion);
|
||||
// Persist immediately so Done and the close button survive a quick reload.
|
||||
savePreferences({ version: $appVersion }).catch(() => {});
|
||||
}
|
||||
showChangelog.set(false);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { goto } from '$app/navigation';
|
||||
import { addWorkspace } from '$lib/stores';
|
||||
import { getWelcome } from '$lib/apis/state';
|
||||
import { listDir } from '$lib/apis/files';
|
||||
import { createEntry, listDir } from '$lib/apis/files';
|
||||
import Icon from './Icon.svelte';
|
||||
import Modal from './Modal.svelte';
|
||||
import DropdownMenu from './DropdownMenu.svelte';
|
||||
@@ -33,6 +33,8 @@
|
||||
let actionsBtnEl: HTMLButtonElement | undefined = $state();
|
||||
let listEl: HTMLDivElement | undefined = $state();
|
||||
let history = $state<string[]>([]);
|
||||
let creatingFolder = $state(false);
|
||||
let folderName = $state('');
|
||||
|
||||
// ── Editable path bar ───────────────────────────────────────
|
||||
let editingPath = $state(false);
|
||||
@@ -283,6 +285,32 @@
|
||||
function toggleHidden() {
|
||||
showHidden = !showHidden;
|
||||
}
|
||||
|
||||
function startCreatingFolder() {
|
||||
creatingFolder = true;
|
||||
folderName = '';
|
||||
actionsMenuOpen = false;
|
||||
}
|
||||
|
||||
async function createFolder() {
|
||||
const name = folderName.trim();
|
||||
if (!name) return;
|
||||
const path = currentPath === '/' ? `/${name}` : `${currentPath}/${name}`;
|
||||
try {
|
||||
await createEntry(path, 'directory');
|
||||
await fetchDirectories(currentPath);
|
||||
} catch (e: any) {
|
||||
error = e.message || $t('files.failedToLoad');
|
||||
} finally {
|
||||
creatingFolder = false;
|
||||
folderName = '';
|
||||
}
|
||||
}
|
||||
|
||||
function cancelCreatingFolder() {
|
||||
creatingFolder = false;
|
||||
folderName = '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={handleKeydown} />
|
||||
@@ -393,6 +421,37 @@
|
||||
|
||||
<!-- Directory listing -->
|
||||
<div bind:this={listEl} class="overflow-y-auto px-1.5 pb-1.5 flex-1 min-h-0">
|
||||
{#if creatingFolder}
|
||||
<div class="flex items-center gap-2 h-7 px-2">
|
||||
<Icon name="folder" size={14} class="text-gray-400 shrink-0" />
|
||||
<input
|
||||
type="text"
|
||||
class="flex-1 border-none outline-none bg-transparent text-xs text-gray-900 dark:text-white"
|
||||
placeholder={$t('files.folderNamePlaceholder')}
|
||||
bind:value={folderName}
|
||||
onkeydown={(e) => {
|
||||
if (e.key === 'Enter') createFolder();
|
||||
if (e.key === 'Escape') cancelCreatingFolder();
|
||||
}}
|
||||
autofocus
|
||||
/>
|
||||
<button
|
||||
class="flex items-center justify-center w-5 h-5 rounded text-green-500 hover:bg-green-50 dark:hover:bg-green-500/10 transition-colors duration-75"
|
||||
onclick={createFolder}
|
||||
aria-label={$t('files.newFolder')}
|
||||
>
|
||||
<Icon name="check" size={12} />
|
||||
</button>
|
||||
<button
|
||||
class="flex items-center justify-center w-5 h-5 rounded text-gray-400 hover:bg-gray-100 dark:hover:bg-white/6 transition-colors duration-75"
|
||||
onclick={cancelCreatingFolder}
|
||||
aria-label={$t('directory.cancel')}
|
||||
>
|
||||
<Icon name="xmark" size={12} />
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if loading}
|
||||
<div class="flex items-center justify-center py-8">
|
||||
<Spinner size={16} />
|
||||
@@ -459,6 +518,11 @@
|
||||
anchor={actionsBtnEl}
|
||||
align="end"
|
||||
items={[
|
||||
{
|
||||
label: $t('files.newFolder'),
|
||||
icon: 'folder',
|
||||
onclick: () => startCreatingFolder()
|
||||
},
|
||||
{
|
||||
label: showHidden ? $t('files.hideHidden') : $t('files.showHidden'),
|
||||
icon: 'eye',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { activeWorkspace, addWorkspace, openFileTab } from '$lib/stores';
|
||||
import { activeWorkspace, addWorkspace, openFileTab, selectedModelId } from '$lib/stores';
|
||||
import {
|
||||
getGitLog,
|
||||
getGitDiff,
|
||||
@@ -13,6 +13,7 @@
|
||||
unstageFiles,
|
||||
discardChanges,
|
||||
gitCommit,
|
||||
generateGitCommitMessage,
|
||||
gitFetch,
|
||||
gitPull,
|
||||
gitPush,
|
||||
@@ -109,6 +110,7 @@
|
||||
let commitDescription = $state('');
|
||||
let actionMsg = $state('');
|
||||
let loading = $state(false);
|
||||
let generatingCommitMessage = $state(false);
|
||||
let panelHeight = $state(280);
|
||||
let prevHeight = $state(280);
|
||||
let isMaximized = $state(false);
|
||||
@@ -376,6 +378,20 @@
|
||||
await refresh();
|
||||
}
|
||||
|
||||
async function generateCommitMessage() {
|
||||
if (!stagedFiles.length || generatingCommitMessage) return;
|
||||
generatingCommitMessage = true;
|
||||
try {
|
||||
const message = await generateGitCommitMessage(workspacePath, $selectedModelId || undefined);
|
||||
commitSummary = message.summary;
|
||||
commitDescription = message.description;
|
||||
} catch (e) {
|
||||
flash(e instanceof Error ? e.message : $t('git.generateMessageFailed'));
|
||||
} finally {
|
||||
generatingCommitMessage = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function doUncommit() {
|
||||
loading = true;
|
||||
try {
|
||||
@@ -1340,15 +1356,31 @@
|
||||
<div
|
||||
class="rounded-lg border border-gray-200 dark:border-white/8 overflow-hidden focus-within:border-gray-300 dark:focus-within:border-white/15 transition-colors"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
class="w-full h-7 px-2 bg-transparent text-[0.6875rem] text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-gray-600 outline-none"
|
||||
placeholder={$t('git.summaryRequired')}
|
||||
bind:value={commitSummary}
|
||||
onkeydown={(e) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) doCommit();
|
||||
}}
|
||||
/>
|
||||
<div class="relative">
|
||||
<input
|
||||
type="text"
|
||||
class="w-full h-7 pl-2 pr-7 bg-transparent text-[0.6875rem] text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-gray-600 outline-none"
|
||||
placeholder={$t('git.summaryRequired')}
|
||||
bind:value={commitSummary}
|
||||
onkeydown={(e) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) doCommit();
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
class="absolute right-1 top-1 flex h-5 w-5 items-center justify-center rounded text-gray-400 transition-colors hover:bg-gray-100 hover:text-gray-700 disabled:cursor-default disabled:opacity-50 dark:text-gray-600 dark:hover:bg-white/10 dark:hover:text-gray-300"
|
||||
type="button"
|
||||
disabled={!stagedFiles.length || generatingCommitMessage}
|
||||
use:tooltip={$t('git.generateMessage')}
|
||||
aria-label={$t('git.generateMessage')}
|
||||
onclick={generateCommitMessage}
|
||||
>
|
||||
{#if generatingCommitMessage}
|
||||
<Spinner size={10} />
|
||||
{:else}
|
||||
<Icon name="spark" size={11} />
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
<textarea
|
||||
class="w-full px-2 py-1.5 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"
|
||||
rows="2"
|
||||
|
||||
@@ -32,12 +32,13 @@
|
||||
import { TAB_DRAG_MIME } from '$lib/constants';
|
||||
|
||||
interface Props {
|
||||
group: EditorGroup;
|
||||
canClose?: boolean;
|
||||
isPrimary?: boolean;
|
||||
}
|
||||
group: EditorGroup;
|
||||
canClose?: boolean;
|
||||
isPrimary?: boolean;
|
||||
onTabDragOver?: () => void;
|
||||
}
|
||||
|
||||
let { group, canClose = false, isPrimary = false }: Props = $props();
|
||||
let { group, canClose = false, isPrimary = false, onTabDragOver }: Props = $props();
|
||||
|
||||
let tabsEl: HTMLDivElement | undefined = $state();
|
||||
let sortable: Sortable | null = null;
|
||||
@@ -142,6 +143,8 @@
|
||||
// Only accept tab drags (not file uploads)
|
||||
if (!e.dataTransfer || !hasTabDrag(e.dataTransfer)) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
onTabDragOver?.();
|
||||
e.dataTransfer.dropEffect = 'move';
|
||||
dropHighlight = true;
|
||||
}
|
||||
@@ -155,8 +158,9 @@
|
||||
if (!e.dataTransfer) return;
|
||||
const payload = readTabDragPayload(e.dataTransfer);
|
||||
if (!payload) return;
|
||||
if (payload.groupId === group.id) return; // same group, ignore
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
if (payload.groupId === group.id) return; // same group, ignore
|
||||
moveTabToGroup(payload.tabId, payload.groupId, group.id);
|
||||
}
|
||||
|
||||
@@ -208,7 +212,7 @@
|
||||
const tab = contextMenu.tab;
|
||||
const items: { label: string; icon?: string; onclick: () => void; divider?: boolean }[] = [];
|
||||
|
||||
if (isWideScreen && tab.type === 'file' && tab.filePath && !$splitActive) {
|
||||
if (isWideScreen && tab.type === 'file' && tab.filePath) {
|
||||
items.push({
|
||||
label: $t('bar.splitRight'),
|
||||
icon: 'split-horizontal',
|
||||
@@ -242,7 +246,7 @@
|
||||
active: direction === 'horizontal',
|
||||
onclick: () => {
|
||||
setSplitDirection('horizontal');
|
||||
if (!$splitActive) splitCurrentTab('horizontal');
|
||||
splitCurrentTab('horizontal');
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -251,7 +255,7 @@
|
||||
active: direction === 'vertical',
|
||||
onclick: () => {
|
||||
setSplitDirection('vertical');
|
||||
if (!$splitActive) splitCurrentTab('vertical');
|
||||
splitCurrentTab('vertical');
|
||||
}
|
||||
}
|
||||
];
|
||||
@@ -373,8 +377,8 @@
|
||||
|
||||
<!-- Right-side controls -->
|
||||
<div class="flex items-center gap-0.5 shrink-0">
|
||||
<!-- Split button (wide screens, primary group only) -->
|
||||
{#if isPrimary && isWideScreen}
|
||||
<!-- Split button (wide screens) -->
|
||||
{#if isWideScreen}
|
||||
<button
|
||||
bind:this={splitBtnEl}
|
||||
class="flex items-center justify-center w-7 h-7 rounded-lg transition-colors duration-100 shrink-0
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
let { onsettings, onsysteminfo }: Props = $props();
|
||||
let showMenu = $state(false);
|
||||
let menuButtonEl: HTMLButtonElement | undefined = $state();
|
||||
const FEATURE_REQUEST_URL = 'https://github.com/open-webui/computer/issues/new/choose';
|
||||
|
||||
function openSettings(tab?: string) {
|
||||
showMenu = false;
|
||||
@@ -79,6 +80,11 @@
|
||||
icon: 'info',
|
||||
onclick: openSystemInfo
|
||||
},
|
||||
{
|
||||
label: $t('sidebar.suggestFeature'),
|
||||
icon: 'external-link',
|
||||
onclick: () => window.open(FEATURE_REQUEST_URL, '_blank', 'noopener,noreferrer')
|
||||
},
|
||||
{ divider: true, label: '', onclick: () => {} },
|
||||
{ label: $t('sidebar.logOut'), icon: 'log-out', onclick: clearSession }
|
||||
]}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"sidebar.collapse": "Einklappen",
|
||||
"sidebar.noWorkspaces": "Noch keine Arbeitsbereiche",
|
||||
"sidebar.settings": "Einstellungen",
|
||||
"sidebar.suggestFeature": "Feedback",
|
||||
"sidebar.admin": "Verwaltung",
|
||||
"sidebar.logOut": "Abmelden",
|
||||
"sidebar.remove": "Entfernen",
|
||||
@@ -180,6 +181,8 @@
|
||||
"git.commitFilesToBranch_other": "{{count}} Dateien auf {{branch}} committen",
|
||||
"git.commitToBranch": "Auf {{branch}} committen",
|
||||
"git.summaryRequired": "Zusammenfassung (erforderlich)",
|
||||
"git.generateMessage": "Commit-Nachricht generieren",
|
||||
"git.generateMessageFailed": "Commit-Nachricht konnte nicht generiert werden",
|
||||
"git.description": "Beschreibung",
|
||||
"git.commit": "Committen",
|
||||
"git.commitMessage": "Commit-Nachricht...",
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"sidebar.collapse": "Collapse",
|
||||
"sidebar.noWorkspaces": "No workspaces yet",
|
||||
"sidebar.settings": "Settings",
|
||||
"sidebar.suggestFeature": "Feedback",
|
||||
"sidebar.admin": "Admin",
|
||||
"sidebar.logOut": "Log out",
|
||||
"sidebar.remove": "Remove",
|
||||
@@ -180,6 +181,8 @@
|
||||
"git.commitFilesToBranch_other": "Commit {{count}} files to {{branch}}",
|
||||
"git.commitToBranch": "Commit to {{branch}}",
|
||||
"git.summaryRequired": "Summary (required)",
|
||||
"git.generateMessage": "Generate commit message",
|
||||
"git.generateMessageFailed": "Could not generate a commit message",
|
||||
"git.description": "Description",
|
||||
"git.commit": "Commit",
|
||||
"git.commitMessage": "Commit message...",
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"sidebar.collapse": "Contraer",
|
||||
"sidebar.noWorkspaces": "Sin espacios de trabajo",
|
||||
"sidebar.settings": "Configuración",
|
||||
"sidebar.suggestFeature": "Comentarios",
|
||||
"sidebar.admin": "Administración",
|
||||
"sidebar.logOut": "Cerrar sesión",
|
||||
"sidebar.remove": "Eliminar",
|
||||
@@ -180,6 +181,8 @@
|
||||
"git.commitFilesToBranch_other": "Confirmar {{count}} archivos en {{branch}}",
|
||||
"git.commitToBranch": "Confirmar en {{branch}}",
|
||||
"git.summaryRequired": "Resumen (obligatorio)",
|
||||
"git.generateMessage": "Generar mensaje de commit",
|
||||
"git.generateMessageFailed": "No se pudo generar un mensaje de commit",
|
||||
"git.description": "Descripción",
|
||||
"git.commit": "Confirmar",
|
||||
"git.commitMessage": "Mensaje de confirmación...",
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"sidebar.collapse": "Réduire",
|
||||
"sidebar.noWorkspaces": "Aucun espace de travail",
|
||||
"sidebar.settings": "Paramètres",
|
||||
"sidebar.suggestFeature": "Commentaires",
|
||||
"sidebar.admin": "Administration",
|
||||
"sidebar.logOut": "Se déconnecter",
|
||||
"sidebar.remove": "Supprimer",
|
||||
@@ -180,6 +181,8 @@
|
||||
"git.commitFilesToBranch_other": "Valider {{count}} fichiers sur {{branch}}",
|
||||
"git.commitToBranch": "Valider sur {{branch}}",
|
||||
"git.summaryRequired": "Résumé (obligatoire)",
|
||||
"git.generateMessage": "Générer le message de commit",
|
||||
"git.generateMessageFailed": "Impossible de générer un message de commit",
|
||||
"git.description": "Détails",
|
||||
"git.commit": "Valider",
|
||||
"git.commitMessage": "Message de validation...",
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"sidebar.collapse": "折りたたむ",
|
||||
"sidebar.noWorkspaces": "ワークスペースがありません",
|
||||
"sidebar.settings": "設定",
|
||||
"sidebar.suggestFeature": "フィードバック",
|
||||
"sidebar.admin": "管理",
|
||||
"sidebar.logOut": "ログアウト",
|
||||
"sidebar.remove": "削除",
|
||||
@@ -180,6 +181,8 @@
|
||||
"git.commitFilesToBranch_other": "{{count}} 件のファイルを {{branch}} にコミット",
|
||||
"git.commitToBranch": "{{branch}} にコミット",
|
||||
"git.summaryRequired": "概要(必須)",
|
||||
"git.generateMessage": "コミットメッセージを生成",
|
||||
"git.generateMessageFailed": "コミットメッセージを生成できませんでした",
|
||||
"git.description": "説明",
|
||||
"git.commit": "コミット",
|
||||
"git.commitMessage": "コミットメッセージ...",
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"sidebar.collapse": "접기",
|
||||
"sidebar.noWorkspaces": "워크스페이스가 없습니다",
|
||||
"sidebar.settings": "설정",
|
||||
"sidebar.suggestFeature": "피드백",
|
||||
"sidebar.admin": "관리",
|
||||
"sidebar.logOut": "로그아웃",
|
||||
"sidebar.remove": "제거",
|
||||
@@ -180,6 +181,8 @@
|
||||
"git.commitFilesToBranch_other": "{{count}}개 파일을 {{branch}}에 커밋",
|
||||
"git.commitToBranch": "{{branch}}에 커밋",
|
||||
"git.summaryRequired": "요약 (필수)",
|
||||
"git.generateMessage": "커밋 메시지 생성",
|
||||
"git.generateMessageFailed": "커밋 메시지를 생성할 수 없습니다",
|
||||
"git.description": "설명",
|
||||
"git.commit": "커밋",
|
||||
"git.commitMessage": "커밋 메시지...",
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"sidebar.collapse": "Recolher",
|
||||
"sidebar.noWorkspaces": "Nenhuma área de trabalho",
|
||||
"sidebar.settings": "Configurações",
|
||||
"sidebar.suggestFeature": "Feedback",
|
||||
"sidebar.admin": "Administração",
|
||||
"sidebar.logOut": "Sair",
|
||||
"sidebar.remove": "Remover",
|
||||
@@ -180,6 +181,8 @@
|
||||
"git.commitFilesToBranch_other": "Commitar {{count}} arquivos em {{branch}}",
|
||||
"git.commitToBranch": "Commitar em {{branch}}",
|
||||
"git.summaryRequired": "Resumo (obrigatório)",
|
||||
"git.generateMessage": "Gerar mensagem de commit",
|
||||
"git.generateMessageFailed": "Não foi possível gerar uma mensagem de commit",
|
||||
"git.description": "Descrição",
|
||||
"git.commit": "Commitar",
|
||||
"git.commitMessage": "Mensagem do commit...",
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"sidebar.collapse": "Свернуть",
|
||||
"sidebar.noWorkspaces": "Нет рабочих областей",
|
||||
"sidebar.settings": "Настройки",
|
||||
"sidebar.suggestFeature": "Обратная связь",
|
||||
"sidebar.admin": "Управление",
|
||||
"sidebar.logOut": "Выйти",
|
||||
"sidebar.remove": "Удалить",
|
||||
@@ -180,6 +181,8 @@
|
||||
"git.commitFilesToBranch_other": "Закоммитить {{count}} файлов в {{branch}}",
|
||||
"git.commitToBranch": "Закоммитить в {{branch}}",
|
||||
"git.summaryRequired": "Описание (обязательно)",
|
||||
"git.generateMessage": "Создать сообщение коммита",
|
||||
"git.generateMessageFailed": "Не удалось создать сообщение коммита",
|
||||
"git.description": "Описание",
|
||||
"git.commit": "Коммит",
|
||||
"git.commitMessage": "Сообщение коммита...",
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"sidebar.collapse": "收起",
|
||||
"sidebar.noWorkspaces": "暂无工作区",
|
||||
"sidebar.settings": "设置",
|
||||
"sidebar.suggestFeature": "反馈",
|
||||
"sidebar.admin": "管理",
|
||||
"sidebar.logOut": "退出登录",
|
||||
"sidebar.remove": "移除",
|
||||
@@ -180,6 +181,8 @@
|
||||
"git.commitFilesToBranch_other": "提交 {{count}} 个文件到 {{branch}}",
|
||||
"git.commitToBranch": "提交到 {{branch}}",
|
||||
"git.summaryRequired": "摘要(必填)",
|
||||
"git.generateMessage": "生成提交信息",
|
||||
"git.generateMessageFailed": "无法生成提交信息",
|
||||
"git.description": "描述",
|
||||
"git.commit": "提交",
|
||||
"git.commitMessage": "提交信息...",
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"sidebar.collapse": "收合",
|
||||
"sidebar.noWorkspaces": "尚無工作區",
|
||||
"sidebar.settings": "設定",
|
||||
"sidebar.suggestFeature": "意見回饋",
|
||||
"sidebar.admin": "管理",
|
||||
"sidebar.logOut": "登出",
|
||||
"sidebar.remove": "移除",
|
||||
@@ -180,6 +181,8 @@
|
||||
"git.commitFilesToBranch_other": "提交 {{count}} 個檔案到 {{branch}}",
|
||||
"git.commitToBranch": "提交到 {{branch}}",
|
||||
"git.summaryRequired": "摘要(必填)",
|
||||
"git.generateMessage": "產生提交訊息",
|
||||
"git.generateMessageFailed": "無法產生提交訊息",
|
||||
"git.description": "描述",
|
||||
"git.commit": "提交",
|
||||
"git.commitMessage": "提交訊息...",
|
||||
|
||||
+160
-25
@@ -9,7 +9,7 @@
|
||||
* Architecture:
|
||||
* Workspace → EditorGroup[] (1 or more groups, each with independent tabs)
|
||||
* Each group has its own tab list and active tab, like VS Code editor groups.
|
||||
* When there are 2+ groups, a split view is rendered.
|
||||
* Groups are arranged in a nested split tree, like VS Code editor groups.
|
||||
*
|
||||
* Multiple browser tabs can independently view different workspaces without
|
||||
* interfering; each tab reads its workspace path from the URL and loads/saves
|
||||
@@ -65,11 +65,28 @@ export interface EditorGroup {
|
||||
tabHistory?: string[]; // MRU stack of tab IDs (most recent last)
|
||||
}
|
||||
|
||||
export type EditorLayout = EditorGroupLeaf | EditorSplit;
|
||||
|
||||
export interface EditorGroupLeaf {
|
||||
type: 'group';
|
||||
groupId: string;
|
||||
}
|
||||
|
||||
export interface EditorSplit {
|
||||
type: 'split';
|
||||
id: string;
|
||||
direction: SplitDirection;
|
||||
ratio: number;
|
||||
first: EditorLayout;
|
||||
second: EditorLayout;
|
||||
}
|
||||
|
||||
export interface WorkspaceState {
|
||||
name: string;
|
||||
path: string;
|
||||
groups: EditorGroup[];
|
||||
activeGroupId: string;
|
||||
layout: EditorLayout;
|
||||
splitDirection: SplitDirection;
|
||||
splitRatio: number; // 0-1, fraction for the first group
|
||||
fileBrowserCwd: string;
|
||||
@@ -119,12 +136,109 @@ function createDefaultWorkspace(path: string): WorkspaceState {
|
||||
path,
|
||||
groups: [createDefaultGroup()],
|
||||
activeGroupId: 'default',
|
||||
layout: { type: 'group', groupId: 'default' },
|
||||
splitDirection: 'horizontal',
|
||||
splitRatio: 0.5,
|
||||
fileBrowserCwd: path
|
||||
};
|
||||
}
|
||||
|
||||
function splitLayout(
|
||||
layout: EditorLayout,
|
||||
groupId: string,
|
||||
newGroupId: string,
|
||||
direction: SplitDirection,
|
||||
placement: 'before' | 'after' = 'after'
|
||||
): EditorLayout {
|
||||
if (layout.type === 'group') {
|
||||
if (layout.groupId !== groupId) return layout;
|
||||
const newLeaf: EditorGroupLeaf = { type: 'group', groupId: newGroupId };
|
||||
return {
|
||||
type: 'split',
|
||||
id: nextId(),
|
||||
direction,
|
||||
ratio: 0.5,
|
||||
first: placement === 'before' ? newLeaf : layout,
|
||||
second: placement === 'before' ? layout : newLeaf
|
||||
};
|
||||
}
|
||||
return {
|
||||
...layout,
|
||||
first: splitLayout(layout.first, groupId, newGroupId, direction, placement),
|
||||
second: splitLayout(layout.second, groupId, newGroupId, direction, placement)
|
||||
};
|
||||
}
|
||||
|
||||
function replaceLayoutGroup(layout: EditorLayout, groupId: string, replacementId: string): EditorLayout {
|
||||
if (layout.type === 'group') {
|
||||
return layout.groupId === groupId ? { type: 'group', groupId: replacementId } : layout;
|
||||
}
|
||||
return {
|
||||
...layout,
|
||||
first: replaceLayoutGroup(layout.first, groupId, replacementId),
|
||||
second: replaceLayoutGroup(layout.second, groupId, replacementId)
|
||||
};
|
||||
}
|
||||
|
||||
function removeLayoutGroup(layout: EditorLayout, groupId: string): EditorLayout | null {
|
||||
if (layout.type === 'group') return layout.groupId === groupId ? null : layout;
|
||||
const first = removeLayoutGroup(layout.first, groupId);
|
||||
const second = removeLayoutGroup(layout.second, groupId);
|
||||
if (!first) return second;
|
||||
if (!second) return first;
|
||||
return { ...layout, first, second };
|
||||
}
|
||||
|
||||
function layoutGroupIds(layout: EditorLayout): string[] {
|
||||
return layout.type === 'group'
|
||||
? [layout.groupId]
|
||||
: [...layoutGroupIds(layout.first), ...layoutGroupIds(layout.second)];
|
||||
}
|
||||
|
||||
function isEditorLayout(value: unknown): value is EditorLayout {
|
||||
if (!value || typeof value !== 'object') return false;
|
||||
const node = value as Partial<EditorLayout>;
|
||||
return node.type === 'group'
|
||||
? typeof node.groupId === 'string'
|
||||
: node.type === 'split' &&
|
||||
typeof node.id === 'string' &&
|
||||
(node.direction === 'horizontal' || node.direction === 'vertical') &&
|
||||
typeof node.ratio === 'number' &&
|
||||
isEditorLayout(node.first) &&
|
||||
isEditorLayout(node.second);
|
||||
}
|
||||
|
||||
function createLayout(groups: EditorGroup[], direction: SplitDirection, ratio: number): EditorLayout {
|
||||
let layout: EditorLayout = { type: 'group', groupId: groups[0].id };
|
||||
for (const group of groups.slice(1)) {
|
||||
layout = {
|
||||
type: 'split',
|
||||
id: nextId(),
|
||||
direction,
|
||||
ratio,
|
||||
first: layout,
|
||||
second: { type: 'group', groupId: group.id }
|
||||
};
|
||||
}
|
||||
return layout;
|
||||
}
|
||||
|
||||
function normalizeLayout(
|
||||
layout: unknown,
|
||||
groups: EditorGroup[],
|
||||
direction: SplitDirection,
|
||||
ratio: number
|
||||
): EditorLayout {
|
||||
if (!isEditorLayout(layout)) return createLayout(groups, direction, ratio);
|
||||
const ids = layoutGroupIds(layout);
|
||||
const groupIds = groups.map((group) => group.id);
|
||||
return ids.length === groupIds.length &&
|
||||
ids.every((id) => groupIds.includes(id)) &&
|
||||
new Set(ids).size === ids.length
|
||||
? layout
|
||||
: createLayout(groups, direction, ratio);
|
||||
}
|
||||
|
||||
// ── Stores ──────────────────────────────────────────────────────
|
||||
|
||||
/** The workspace currently displayed in THIS browser tab. Null = welcome page. */
|
||||
@@ -453,6 +567,7 @@ export async function loadWorkspace(path: string): Promise<void> {
|
||||
path: canonicalWorkspacePath,
|
||||
groups,
|
||||
activeGroupId,
|
||||
layout: normalizeLayout(ws.layout, groups, ws.splitDirection ?? 'horizontal', ws.splitRatio ?? 0.5),
|
||||
splitDirection: ws.splitDirection ?? 'horizontal',
|
||||
splitRatio: ws.splitRatio ?? 0.5,
|
||||
fileBrowserCwd: ws.fileBrowserCwd ?? canonicalWorkspacePath
|
||||
@@ -876,10 +991,14 @@ export function closeTab(tabId: string, groupId?: string): void {
|
||||
|
||||
// If active group was removed, switch to first remaining
|
||||
const activeGroupStillExists = newGroups.some((g) => g.id === ws.activeGroupId);
|
||||
const closedGroupStillExists = newGroups.some((g) => g.id === gid);
|
||||
|
||||
return {
|
||||
...ws,
|
||||
groups: newGroups,
|
||||
layout: closedGroupStillExists
|
||||
? ws.layout
|
||||
: removeLayoutGroup(ws.layout, gid) ?? { type: 'group', groupId: newGroups[0].id },
|
||||
activeGroupId: activeGroupStillExists ? ws.activeGroupId : newGroups[0].id
|
||||
};
|
||||
});
|
||||
@@ -962,22 +1081,13 @@ export function clearTabEdit(tabId: string): void {
|
||||
|
||||
// ── Split / Editor Group actions ────────────────────────────────
|
||||
|
||||
/** Open a file in a new split group (creates the group if needed) */
|
||||
/** Open a file in a new editor group. */
|
||||
export function openInSplit(filePath: string, direction?: SplitDirection): void {
|
||||
const ws = get(currentWorkspace);
|
||||
if (!ws) return;
|
||||
|
||||
const dir = direction ?? ws.splitDirection ?? 'horizontal';
|
||||
|
||||
// If there's already a second group, open in it
|
||||
if (ws.groups.length > 1) {
|
||||
const otherGroup = ws.groups.find((g) => g.id !== ws.activeGroupId);
|
||||
if (otherGroup) {
|
||||
openFileTab(filePath, otherGroup.id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a new group with this file
|
||||
const name = getPathDisplayName(filePath, filePath);
|
||||
const newTab: Tab = { id: nextId(), type: 'file', label: name, filePath };
|
||||
@@ -993,6 +1103,7 @@ export function openInSplit(filePath: string, direction?: SplitDirection): void
|
||||
...ws,
|
||||
groups: [...ws.groups, newGroup],
|
||||
activeGroupId: newGroup.id,
|
||||
layout: splitLayout(ws.layout, ws.activeGroupId, newGroup.id, dir),
|
||||
splitDirection: dir,
|
||||
splitRatio: ws.splitRatio ?? 0.5
|
||||
};
|
||||
@@ -1010,15 +1121,6 @@ export function splitCurrentTab(direction?: SplitDirection): void {
|
||||
|
||||
const dir = direction ?? ws.splitDirection ?? 'horizontal';
|
||||
|
||||
// If already split, focus the other group
|
||||
if (ws.groups.length > 1) {
|
||||
const otherGroup = ws.groups.find((g) => g.id !== ws.activeGroupId);
|
||||
if (otherGroup) {
|
||||
setActiveGroup(otherGroup.id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Copy the tab into a new group
|
||||
const newTab: Tab = { ...tab, id: nextId(), permanent: false };
|
||||
const newGroup: EditorGroup = {
|
||||
@@ -1033,6 +1135,7 @@ export function splitCurrentTab(direction?: SplitDirection): void {
|
||||
...ws,
|
||||
groups: [...ws.groups, newGroup],
|
||||
activeGroupId: newGroup.id,
|
||||
layout: splitLayout(ws.layout, group.id, newGroup.id, dir),
|
||||
splitDirection: dir,
|
||||
splitRatio: ws.splitRatio ?? 0.5
|
||||
};
|
||||
@@ -1070,7 +1173,8 @@ export function closeGroup(groupId: string): void {
|
||||
return {
|
||||
...ws,
|
||||
groups: newGroups,
|
||||
activeGroupId: targetGroup.id
|
||||
activeGroupId: targetGroup.id,
|
||||
layout: removeLayoutGroup(ws.layout, groupId) ?? { type: 'group', groupId: targetGroup.id }
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -1100,10 +1204,12 @@ export function moveTabToGroup(tabId: string, fromGroupId: string, toGroupId: st
|
||||
newGroups = newGroups.filter((g) => g.tabs.length > 0);
|
||||
if (newGroups.length === 0) newGroups = [createDefaultGroup()];
|
||||
|
||||
const sourceGroupStillExists = newGroups.some((g) => g.id === fromGroupId);
|
||||
const targetGroupStillExists = newGroups.some((g) => g.id === toGroupId);
|
||||
return {
|
||||
...ws,
|
||||
groups: newGroups,
|
||||
layout: sourceGroupStillExists ? ws.layout : removeLayoutGroup(ws.layout, fromGroupId) ?? ws.layout,
|
||||
activeGroupId: targetGroupStillExists ? toGroupId : newGroups[0].id
|
||||
};
|
||||
});
|
||||
@@ -1112,11 +1218,12 @@ export function moveTabToGroup(tabId: string, fromGroupId: string, toGroupId: st
|
||||
export function moveTabToNewSplit(
|
||||
tabId: string,
|
||||
fromGroupId: string,
|
||||
targetGroupId: string,
|
||||
direction: SplitDirection,
|
||||
placement: 'before' | 'after' = 'after'
|
||||
): void {
|
||||
currentWorkspace.update((ws) => {
|
||||
if (!ws || ws.groups.length > 1) return ws;
|
||||
if (!ws) return ws;
|
||||
const fromGroup = ws.groups.find((g) => g.id === fromGroupId);
|
||||
if (!fromGroup) return ws;
|
||||
const tab = fromGroup.tabs.find((t) => t.id === tabId);
|
||||
@@ -1132,12 +1239,25 @@ export function moveTabToNewSplit(
|
||||
const tabs = g.tabs.filter((t) => t.id !== tabId);
|
||||
return { ...g, tabs, activeTabId: tabs[0]?.id ?? '' };
|
||||
});
|
||||
const sourceGroupRemoved = groups.some((group) => group.id === fromGroupId && group.tabs.length === 0);
|
||||
groups = groups.filter((g) => g.tabs.length > 0);
|
||||
groups.push(newGroup);
|
||||
let layout = ws.layout;
|
||||
if (sourceGroupRemoved) {
|
||||
layout =
|
||||
fromGroupId === targetGroupId
|
||||
? replaceLayoutGroup(layout, fromGroupId, newGroup.id)
|
||||
: removeLayoutGroup(layout, fromGroupId) ?? layout;
|
||||
}
|
||||
if (!(sourceGroupRemoved && fromGroupId === targetGroupId)) {
|
||||
layout = splitLayout(layout, targetGroupId, newGroup.id, direction, placement);
|
||||
}
|
||||
|
||||
return {
|
||||
...ws,
|
||||
groups: placement === 'before' ? [newGroup, ...groups] : [...groups, newGroup],
|
||||
groups,
|
||||
activeGroupId: newGroup.id,
|
||||
layout,
|
||||
splitDirection: direction,
|
||||
splitRatio: ws.splitRatio ?? 0.5
|
||||
};
|
||||
@@ -1148,8 +1268,23 @@ export function setSplitDirection(direction: SplitDirection): void {
|
||||
currentWorkspace.update((ws) => (ws ? { ...ws, splitDirection: direction } : ws));
|
||||
}
|
||||
|
||||
export function setSplitRatio(ratio: number): void {
|
||||
export function setSplitRatio(splitId: string, ratio: number): void {
|
||||
currentWorkspace.update((ws) =>
|
||||
ws ? { ...ws, splitRatio: Math.max(0.2, Math.min(0.8, ratio)) } : ws
|
||||
ws
|
||||
? {
|
||||
...ws,
|
||||
layout: updateSplitRatio(ws.layout, splitId, ratio)
|
||||
}
|
||||
: ws
|
||||
);
|
||||
}
|
||||
|
||||
function updateSplitRatio(layout: EditorLayout, splitId: string, ratio: number): EditorLayout {
|
||||
if (layout.type === 'group') return layout;
|
||||
if (layout.id === splitId) return { ...layout, ratio: Math.max(0.2, Math.min(0.8, ratio)) };
|
||||
return {
|
||||
...layout,
|
||||
first: updateSplitRatio(layout.first, splitId, ratio),
|
||||
second: updateSplitRatio(layout.second, splitId, ratio)
|
||||
};
|
||||
}
|
||||
@@ -130,8 +130,7 @@
|
||||
// First-time load: initialize the last seen version to the current version so we don't pop up immediately
|
||||
lastSeenVersion.set(currentVer);
|
||||
} else {
|
||||
// Update: record this version as seen before showing the changelog so it doesn't reopen repeatedly.
|
||||
lastSeenVersion.set(currentVer);
|
||||
// Update: show the changelog until the user dismisses it.
|
||||
showChangelog.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
showSearch,
|
||||
pwaPreferences
|
||||
} from '$lib/stores';
|
||||
import type { Tab, EditorGroup, SplitDirection, WorkspaceState } from '$lib/stores';
|
||||
import type { Tab, EditorGroup, EditorLayout, SplitDirection, WorkspaceState } from '$lib/stores';
|
||||
import { t } from '$lib/i18n';
|
||||
import { get } from 'svelte/store';
|
||||
import { getWelcome, getWorkspaceState } from '$lib/apis/state';
|
||||
@@ -582,31 +582,34 @@
|
||||
|
||||
// ── Draggable divider ──────────────────────────────────────────
|
||||
|
||||
let isDragging = $state(false);
|
||||
let containerEl: HTMLDivElement | undefined = $state();
|
||||
let resizingSplit = $state<{
|
||||
splitId: string;
|
||||
direction: SplitDirection;
|
||||
element: HTMLElement;
|
||||
} | null>(null);
|
||||
|
||||
function handleDividerPointerDown(e: PointerEvent) {
|
||||
function handleDividerPointerDown(e: PointerEvent, split: Extract<EditorLayout, { type: 'split' }>) {
|
||||
e.preventDefault();
|
||||
isDragging = true;
|
||||
(e.target as HTMLElement).setPointerCapture(e.pointerId);
|
||||
const divider = e.currentTarget as HTMLElement;
|
||||
resizingSplit = { splitId: split.id, direction: split.direction, element: divider.parentElement! };
|
||||
divider.setPointerCapture(e.pointerId);
|
||||
}
|
||||
|
||||
function handleDividerPointerMove(e: PointerEvent) {
|
||||
if (!isDragging || !containerEl) return;
|
||||
const rect = containerEl.getBoundingClientRect();
|
||||
const direction = $currentWorkspace?.splitDirection ?? 'horizontal';
|
||||
if (!resizingSplit) return;
|
||||
const rect = resizingSplit.element.getBoundingClientRect();
|
||||
|
||||
let ratio: number;
|
||||
if (direction === 'horizontal') {
|
||||
if (resizingSplit.direction === 'horizontal') {
|
||||
ratio = (e.clientX - rect.left) / rect.width;
|
||||
} else {
|
||||
ratio = (e.clientY - rect.top) / rect.height;
|
||||
}
|
||||
setSplitRatio(ratio);
|
||||
setSplitRatio(resizingSplit.splitId, ratio);
|
||||
}
|
||||
|
||||
function handleDividerPointerUp() {
|
||||
isDragging = false;
|
||||
resizingSplit = null;
|
||||
}
|
||||
|
||||
// Computed
|
||||
@@ -622,16 +625,10 @@
|
||||
});
|
||||
|
||||
const allGroups = $derived($currentWorkspace?.groups ?? []);
|
||||
const splitDirection = $derived($currentWorkspace?.splitDirection ?? 'horizontal');
|
||||
const splitRatio = $derived($currentWorkspace?.splitRatio ?? 0.5);
|
||||
|
||||
// On mobile, collapse to just the active group
|
||||
const displayGroups = $derived(
|
||||
isWideScreen
|
||||
? allGroups
|
||||
: allGroups.filter((g) => g.id === $currentWorkspace?.activeGroupId).slice(0, 1)
|
||||
const layout = $derived($currentWorkspace?.layout ?? null);
|
||||
const activeGroup = $derived(
|
||||
allGroups.find((group) => group.id === $currentWorkspace?.activeGroupId) ?? allGroups[0] ?? null
|
||||
);
|
||||
const hasSplit = $derived(displayGroups.length > 1);
|
||||
|
||||
function getGroupActiveTab(group: EditorGroup): Tab | null {
|
||||
return group.tabs.find((t) => t.id === group.activeTabId) ?? null;
|
||||
@@ -644,7 +641,19 @@
|
||||
type SplitDropZone = 'left' | 'right' | 'top' | 'bottom';
|
||||
type TabDragPayload = { tabId: string; groupId: string };
|
||||
|
||||
let dragOverZone = $state<SplitDropZone | null>(null);
|
||||
let dragOverZone = $state<{ groupId: string; zone: SplitDropZone } | null>(null);
|
||||
|
||||
$effect(() => {
|
||||
const clearSplitPreview = () => (dragOverZone = null);
|
||||
document.addEventListener('dragend', clearSplitPreview, true);
|
||||
document.addEventListener('drop', clearSplitPreview, true);
|
||||
window.addEventListener('blur', clearSplitPreview);
|
||||
return () => {
|
||||
document.removeEventListener('dragend', clearSplitPreview, true);
|
||||
document.removeEventListener('drop', clearSplitPreview, true);
|
||||
window.removeEventListener('blur', clearSplitPreview);
|
||||
};
|
||||
});
|
||||
|
||||
function hasTabDrag(dataTransfer: DataTransfer): boolean {
|
||||
return dataTransfer.types.includes(TAB_DRAG_MIME) || dataTransfer.types.includes('text/tab-id');
|
||||
@@ -668,11 +677,11 @@
|
||||
return tabId && groupId ? { tabId, groupId } : null;
|
||||
}
|
||||
|
||||
function getSplitDropZone(e: DragEvent): SplitDropZone | null {
|
||||
if (!containerEl || !isWideScreen || hasSplit || !e.dataTransfer) return null;
|
||||
function getSplitDropZone(e: DragEvent, pane: HTMLElement): SplitDropZone | null {
|
||||
if (!isWideScreen || !e.dataTransfer) return null;
|
||||
if (e.dataTransfer.types.includes('Files') || !hasTabDrag(e.dataTransfer)) return null;
|
||||
|
||||
const rect = containerEl.getBoundingClientRect();
|
||||
const rect = pane.getBoundingClientRect();
|
||||
if (
|
||||
e.clientX < rect.left ||
|
||||
e.clientX > rect.right ||
|
||||
@@ -701,27 +710,29 @@
|
||||
return candidates[0]?.zone ?? null;
|
||||
}
|
||||
|
||||
function handleContainerDragOver(e: DragEvent) {
|
||||
const zone = getSplitDropZone(e);
|
||||
function handlePaneDragOver(e: DragEvent, groupId: string) {
|
||||
const zone = getSplitDropZone(e, e.currentTarget as HTMLElement);
|
||||
if (!zone) {
|
||||
dragOverZone = null;
|
||||
if (dragOverZone?.groupId === groupId) dragOverZone = null;
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
e.dataTransfer!.dropEffect = 'move';
|
||||
dragOverZone = zone;
|
||||
dragOverZone = { groupId, zone };
|
||||
}
|
||||
|
||||
function handleContainerDragLeave(e: DragEvent) {
|
||||
// Only reset if leaving the container entirely
|
||||
if (containerEl && !containerEl.contains(e.relatedTarget as Node)) {
|
||||
function handlePaneDragLeave(e: DragEvent, groupId: string) {
|
||||
if (!(e.currentTarget as HTMLElement).contains(e.relatedTarget as Node) && dragOverZone?.groupId === groupId) {
|
||||
dragOverZone = null;
|
||||
}
|
||||
}
|
||||
|
||||
function handleContainerDrop(e: DragEvent) {
|
||||
const zone = dragOverZone ?? getSplitDropZone(e);
|
||||
function handlePaneDrop(e: DragEvent, targetGroupId: string) {
|
||||
const zone =
|
||||
dragOverZone?.groupId === targetGroupId
|
||||
? dragOverZone.zone
|
||||
: getSplitDropZone(e, e.currentTarget as HTMLElement);
|
||||
|
||||
if (!zone || !e.dataTransfer) {
|
||||
dragOverZone = null;
|
||||
@@ -738,7 +749,7 @@
|
||||
const direction: SplitDirection =
|
||||
zone === 'left' || zone === 'right' ? 'horizontal' : 'vertical';
|
||||
const placement = zone === 'left' || zone === 'top' ? 'before' : 'after';
|
||||
moveTabToNewSplit(payload.tabId, payload.groupId, direction, placement);
|
||||
moveTabToNewSplit(payload.tabId, payload.groupId, targetGroupId, direction, placement);
|
||||
dragOverZone = null;
|
||||
}
|
||||
</script>
|
||||
@@ -890,114 +901,99 @@
|
||||
{:else}
|
||||
<!-- Editor groups layout -->
|
||||
<div
|
||||
bind:this={containerEl}
|
||||
class="split-container"
|
||||
class:split-horizontal={splitDirection === 'horizontal'}
|
||||
class:split-vertical={splitDirection === 'vertical'}
|
||||
class:is-dragging={isDragging}
|
||||
class:is-dragging={resizingSplit !== null}
|
||||
role="presentation"
|
||||
ondragover={handleContainerDragOver}
|
||||
ondragleave={handleContainerDragLeave}
|
||||
ondrop={handleContainerDrop}
|
||||
>
|
||||
{#each displayGroups as group, i (group.id)}
|
||||
{@const groupTab = getGroupActiveTab(group)}
|
||||
|
||||
{#if i > 0}
|
||||
<!-- Divider between groups -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
class="split-divider"
|
||||
class:split-divider-h={splitDirection === 'horizontal'}
|
||||
class:split-divider-v={splitDirection === 'vertical'}
|
||||
onpointerdown={handleDividerPointerDown}
|
||||
onpointermove={handleDividerPointerMove}
|
||||
onpointerup={handleDividerPointerUp}
|
||||
onpointercancel={handleDividerPointerUp}
|
||||
>
|
||||
<div class="split-divider-handle"></div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
class="split-pane"
|
||||
class:split-pane-single={!hasSplit}
|
||||
style={hasSplit
|
||||
? splitDirection === 'horizontal'
|
||||
? `width: ${i === 0 ? splitRatio * 100 : (1 - splitRatio) * 100}%;`
|
||||
: `height: ${i === 0 ? splitRatio * 100 : (1 - splitRatio) * 100}%;`
|
||||
: ''}
|
||||
onclick={() => setActiveGroup(group.id)}
|
||||
>
|
||||
<!-- Per-group tab bar -->
|
||||
<GroupTabBar {group} canClose={hasSplit} isPrimary={i === 0} />
|
||||
|
||||
<!-- Tab content -->
|
||||
<div class="pane-content">
|
||||
{#if $gitReviewOpen && i === 0}
|
||||
<GitView />
|
||||
{:else}
|
||||
<!-- Persist all tab instances so state survives tab switches (like VS Code) -->
|
||||
{#each group.tabs.filter((t) => t.type === 'file' && t.filePath) as tab (tab.id)}
|
||||
<div class="persisted-tab" class:persisted-tab-hidden={tab.id !== group.activeTabId}>
|
||||
<FileEditor filePath={tab.filePath!} tabId={tab.id} edit={tab.edit === true} />
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
{#each group.tabs.filter((t) => t.type === 'chat') as tab (tab.id)}
|
||||
<div class="persisted-tab" class:persisted-tab-hidden={tab.id !== group.activeTabId}>
|
||||
<ChatPanel
|
||||
workspace={$currentWorkspace.path}
|
||||
chatId={tab.path?.startsWith('new-') || tab.path?.startsWith('pending-')
|
||||
? undefined
|
||||
: tab.path}
|
||||
tabId={tab.id}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
{#each group.tabs.filter((t) => t.type === 'terminal' && t.sessionId) as tab (tab.id)}
|
||||
<div class="persisted-tab" class:persisted-tab-hidden={tab.id !== group.activeTabId}>
|
||||
<Terminal sessionId={tab.sessionId!} />
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
{#each group.tabs.filter((t) => t.type === 'preview' && t.port) as tab (tab.id)}
|
||||
<div class="persisted-tab" class:persisted-tab-hidden={tab.id !== group.activeTabId}>
|
||||
<PortPreview port={tab.port!} />
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
<!-- Fallback content for non-persisted states -->
|
||||
{#if !groupTab || groupTab.type === 'files'}
|
||||
<FileBrowser />
|
||||
{:else if groupTab.type === 'terminal' && !groupTab.sessionId}
|
||||
<div class="flex items-center justify-center h-full">
|
||||
<Spinner size={20} />
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
|
||||
<!-- Drop zone indicators for drag-to-split -->
|
||||
{#if dragOverZone === 'left'}
|
||||
<div class="split-drop-zone split-drop-left"></div>
|
||||
{/if}
|
||||
{#if dragOverZone === 'right'}
|
||||
<div class="split-drop-zone split-drop-right"></div>
|
||||
{/if}
|
||||
{#if dragOverZone === 'top'}
|
||||
<div class="split-drop-zone split-drop-top"></div>
|
||||
{/if}
|
||||
{#if dragOverZone === 'bottom'}
|
||||
<div class="split-drop-zone split-drop-bottom"></div>
|
||||
{#if isWideScreen && layout}
|
||||
{@render renderLayout(layout)}
|
||||
{:else if activeGroup}
|
||||
{@render renderPane(activeGroup)}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#snippet renderLayout(node: EditorLayout)}
|
||||
{#if node.type === 'group'}
|
||||
{@const group = allGroups.find((item) => item.id === node.groupId)}
|
||||
{#if group}{@render renderPane(group)}{/if}
|
||||
{:else}
|
||||
<div class="split-branch" class:split-branch-horizontal={node.direction === 'horizontal'} class:split-branch-vertical={node.direction === 'vertical'}>
|
||||
<div class="split-branch-child" style={`flex: ${node.ratio} 1 0%;`}>
|
||||
{@render renderLayout(node.first)}
|
||||
</div>
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
class="split-divider"
|
||||
class:split-divider-h={node.direction === 'horizontal'}
|
||||
class:split-divider-v={node.direction === 'vertical'}
|
||||
onpointerdown={(event) => handleDividerPointerDown(event, node)}
|
||||
onpointermove={handleDividerPointerMove}
|
||||
onpointerup={handleDividerPointerUp}
|
||||
onpointercancel={handleDividerPointerUp}
|
||||
></div>
|
||||
<div class="split-branch-child" style={`flex: ${1 - node.ratio} 1 0%;`}>
|
||||
{@render renderLayout(node.second)}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
{#snippet renderPane(group: EditorGroup)}
|
||||
{@const groupTab = getGroupActiveTab(group)}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
class="split-pane"
|
||||
onclick={() => setActiveGroup(group.id)}
|
||||
ondragover={(event) => handlePaneDragOver(event, group.id)}
|
||||
ondragleave={(event) => handlePaneDragLeave(event, group.id)}
|
||||
ondrop={(event) => handlePaneDrop(event, group.id)}
|
||||
>
|
||||
<GroupTabBar
|
||||
{group}
|
||||
canClose={allGroups.length > 1}
|
||||
isPrimary={group.id === allGroups[0]?.id}
|
||||
onTabDragOver={() => {
|
||||
if (dragOverZone?.groupId === group.id) dragOverZone = null;
|
||||
}}
|
||||
/>
|
||||
<div class="pane-content">
|
||||
{#if $gitReviewOpen && group.id === allGroups[0]?.id}
|
||||
<GitView />
|
||||
{:else}
|
||||
{#each group.tabs.filter((tab) => tab.type === 'file' && tab.filePath) as tab (tab.id)}
|
||||
<div class="persisted-tab" class:persisted-tab-hidden={tab.id !== group.activeTabId}>
|
||||
<FileEditor filePath={tab.filePath!} tabId={tab.id} edit={tab.edit === true} />
|
||||
</div>
|
||||
{/each}
|
||||
{#each group.tabs.filter((tab) => tab.type === 'chat') as tab (tab.id)}
|
||||
<div class="persisted-tab" class:persisted-tab-hidden={tab.id !== group.activeTabId}>
|
||||
<ChatPanel workspace={$currentWorkspace!.path} chatId={tab.path?.startsWith('new-') || tab.path?.startsWith('pending-') ? undefined : tab.path} tabId={tab.id} />
|
||||
</div>
|
||||
{/each}
|
||||
{#each group.tabs.filter((tab) => tab.type === 'terminal' && tab.sessionId) as tab (tab.id)}
|
||||
<div class="persisted-tab" class:persisted-tab-hidden={tab.id !== group.activeTabId}>
|
||||
<Terminal sessionId={tab.sessionId!} />
|
||||
</div>
|
||||
{/each}
|
||||
{#each group.tabs.filter((tab) => tab.type === 'preview' && tab.port) as tab (tab.id)}
|
||||
<div class="persisted-tab" class:persisted-tab-hidden={tab.id !== group.activeTabId}>
|
||||
<PortPreview port={tab.port!} />
|
||||
</div>
|
||||
{/each}
|
||||
{#if !groupTab || groupTab.type === 'files'}
|
||||
<FileBrowser />
|
||||
{:else if groupTab.type === 'terminal' && !groupTab.sessionId}
|
||||
<div class="flex items-center justify-center h-full"><Spinner size={20} /></div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
{#if dragOverZone?.groupId === group.id}
|
||||
<div class={`split-drop-zone split-drop-${dragOverZone.zone}`}></div>
|
||||
{/if}
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
{#if pendingIntent}
|
||||
<WorkspacePicker
|
||||
intent={pendingIntent}
|
||||
@@ -1032,30 +1028,40 @@
|
||||
color: var(--app-fg);
|
||||
}
|
||||
|
||||
.split-horizontal {
|
||||
.split-branch {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.split-branch-horizontal {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.split-vertical {
|
||||
.split-branch-vertical {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.split-branch-child {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Panes */
|
||||
.split-pane {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
/* Single pane takes all space even while preview overlays are mounted. */
|
||||
.split-pane-single {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.pane-content {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
@@ -1131,14 +1137,6 @@
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.is-dragging.split-horizontal {
|
||||
cursor: col-resize;
|
||||
}
|
||||
|
||||
.is-dragging.split-vertical {
|
||||
cursor: row-resize;
|
||||
}
|
||||
|
||||
/* ── Drop zones for drag-to-split ─────────────────── */
|
||||
.split-drop-zone {
|
||||
position: absolute;
|
||||
|
||||
+60
-1
@@ -8,7 +8,7 @@ from __future__ import annotations
|
||||
|
||||
from typing import List, Optional
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from fastapi import APIRouter, HTTPException, Request
|
||||
from pydantic import BaseModel
|
||||
|
||||
from cptr.utils.git import (
|
||||
@@ -32,6 +32,7 @@ from cptr.utils.git import (
|
||||
stash_list,
|
||||
stash_pop,
|
||||
stash_save,
|
||||
staged_diff,
|
||||
status,
|
||||
uncommit,
|
||||
unstage,
|
||||
@@ -146,6 +147,12 @@ class CommitRequest(BaseModel):
|
||||
message: str
|
||||
|
||||
|
||||
COMMIT_MESSAGE_PROMPT = """Write a conventional, concise Git commit message for this staged diff.
|
||||
Respond with ONLY JSON in this shape: {"summary":"...","description":"..."}.
|
||||
The summary must be imperative, under 72 characters, and have no trailing period.
|
||||
The description should be one short paragraph explaining the meaningful change. Do not invent details."""
|
||||
|
||||
|
||||
class CheckoutRequest(BaseModel):
|
||||
root: str
|
||||
branch: str
|
||||
@@ -178,6 +185,10 @@ class RootRequest(BaseModel):
|
||||
root: str
|
||||
|
||||
|
||||
class CommitMessageRequest(RootRequest):
|
||||
model_id: Optional[str] = None
|
||||
|
||||
|
||||
class PushRequest(BaseModel):
|
||||
root: str
|
||||
force: bool = False
|
||||
@@ -234,6 +245,54 @@ async def git_commit(body: CommitRequest):
|
||||
_handle_git_error(e)
|
||||
|
||||
|
||||
@router.post("/message")
|
||||
async def generate_commit_message(body: CommitMessageRequest, request: Request):
|
||||
"""Generate a commit summary and description from the staged diff."""
|
||||
await _require_repo(body.root)
|
||||
try:
|
||||
patch = await staged_diff(body.root)
|
||||
except GitError as e:
|
||||
_handle_git_error(e)
|
||||
if not patch:
|
||||
raise HTTPException(status_code=400, detail="No staged changes")
|
||||
|
||||
from cptr.utils.ai import chat_completion
|
||||
from cptr.utils.chat_task import _default_base_url
|
||||
from cptr.utils.config import _get_jwt_secret
|
||||
from cptr.utils.crypto import decrypt_key
|
||||
from cptr.utils.json_parser import extract_json
|
||||
from cptr.utils.model_targets import ApiModelTarget, resolve_model_target
|
||||
from cptr.models import Config
|
||||
|
||||
model_id = (body.model_id or await Config.get("chat.default_model") or "").strip()
|
||||
if not model_id:
|
||||
raise HTTPException(status_code=400, detail="No default chat model configured")
|
||||
target = await resolve_model_target(model_id, request.app.state)
|
||||
if not isinstance(target, ApiModelTarget):
|
||||
raise HTTPException(status_code=400, detail="Commit messages require an API model")
|
||||
connection = target.connection
|
||||
base_url = (connection.get("base_url") or _default_base_url(connection["provider"])).rstrip("/")
|
||||
try:
|
||||
text = await chat_completion(
|
||||
provider=connection["provider"],
|
||||
base_url=base_url,
|
||||
api_key=decrypt_key(connection.get("api_key", ""), _get_jwt_secret()),
|
||||
model=target.runtime_model,
|
||||
messages=[{"role": "user", "content": patch}],
|
||||
system=COMMIT_MESSAGE_PROMPT,
|
||||
max_tokens=180,
|
||||
api_type=connection.get("api_type", "chat_completions"),
|
||||
)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=502, detail="Could not generate a commit message") from e
|
||||
message = extract_json(text)
|
||||
summary = str(message.get("summary", "")).strip().splitlines()[0] if isinstance(message, dict) else ""
|
||||
description = str(message.get("description", "")).strip() if isinstance(message, dict) else ""
|
||||
if not summary:
|
||||
raise HTTPException(status_code=502, detail="Could not generate a commit message")
|
||||
return {"summary": summary[:72], "description": description}
|
||||
|
||||
|
||||
@router.post("/checkout")
|
||||
async def git_checkout(body: CheckoutRequest):
|
||||
"""Switch branch."""
|
||||
|
||||
@@ -234,6 +234,12 @@ async def diff(
|
||||
return _parse_diff(out)
|
||||
|
||||
|
||||
async def staged_diff(root: str, max_chars: int = 30000) -> str:
|
||||
"""Return the staged patch, capped for lightweight AI requests."""
|
||||
_, out, _ = await _run("diff", "--staged", "--unified=3", cwd=root)
|
||||
return out[:max_chars]
|
||||
|
||||
|
||||
def _parse_diff(raw: str) -> dict[str, Any]:
|
||||
"""Parse unified diff into structured format."""
|
||||
files: list[dict] = []
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "cptr"
|
||||
version = "0.8.7"
|
||||
version = "0.8.8"
|
||||
description = "Your computer, from anywhere. Code, manage, and control your machine from the web."
|
||||
license = {file = "LICENSE"}
|
||||
readme = "README.md"
|
||||
|
||||
Reference in new issue
Block a user