mirror of
https://github.com/open-webui/computer.git
synced 2026-11-19 12:21:49 +03:00
@@ -5,6 +5,29 @@ 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.5.3] - 2026-06-17
|
||||
|
||||
### Added
|
||||
|
||||
- 🔊 **Auto-stream TTS.** New toggle in Audio settings that automatically reads AI responses aloud as they stream in, without needing to manually enable playback each time.
|
||||
- 🔀 **Branch management.** You can now rename and delete branches directly from the Git panel. Right-click (or tap the action button) on any branch to see your options.
|
||||
- 🔍 **Branch search.** The branch picker now has a search bar so you can quickly find branches in large repos.
|
||||
- 💾 **Stash awareness when switching branches.** If you have uncommitted changes and try to switch or create a branch, you'll be asked whether to bring the changes along or leave them behind.
|
||||
|
||||
### Fixed
|
||||
|
||||
- 🧩 **MCP tool server errors are now helpful.** If the MCP package isn't installed, you'll get a clear message telling you how to install it instead of a confusing traceback.
|
||||
- 🔧 **AI tool calls no longer break on empty arrays.** Fixed a subtle issue where providers returning empty tool call lists could cause errors during streaming.
|
||||
- 🗂️ **Git file list no longer shows duplicates.** Files that were both staged and modified used to appear twice in the changed files list. They now show as a single entry with the correct status.
|
||||
|
||||
### Changed
|
||||
|
||||
- 📋 **Dropdown menus support action buttons.** Menu items can now have a secondary action icon on the right side, used for things like branch context menus.
|
||||
- 📂 **Home page lists are trimmed.** The recent files and folder suggestions on the welcome screen now show at most 5 items each to keep things tidy.
|
||||
- 📦 **Added an "all" install extra.** You can now `pip install cptr[all]` to get every optional dependency (MCP, document support, PAM) in one go.
|
||||
- 🔊 **Sticky save button in Audio settings.** The save button in Audio settings now stays visible at the bottom of the panel as you scroll.
|
||||
- 💾 **Stash includes untracked files.** When stashing changes, new files that haven't been committed yet are now included automatically.
|
||||
|
||||
## [0.5.2] - 2026-06-16
|
||||
|
||||
### Fixed
|
||||
|
||||
+2
-1
@@ -43,7 +43,8 @@ WORKDIR /home/cptr
|
||||
# Install the wheel into an isolated venv
|
||||
COPY --chown=cptr:cptr --from=backend-builder /dist/*.whl /tmp/
|
||||
RUN uv venv /home/cptr/.venv && \
|
||||
uv pip install --python /home/cptr/.venv/bin/python /tmp/*.whl && \
|
||||
set -- /tmp/*.whl && \
|
||||
uv pip install --python /home/cptr/.venv/bin/python "$1[all]" && \
|
||||
rm /tmp/*.whl
|
||||
|
||||
ENV PATH="/home/cptr/.venv/bin:$PATH"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
`cptr` (short for "computer") runs on your machine and serves your whole computer (files, terminal, editor, git) to any browser. It literally is your computer.
|
||||
|
||||
Phone, tablet, laptop, another computer, even the one it's running on. Designed to feel native on every screen. Plug in an AI that can actually read, write, and run things on your machine, or bring your favourite terminal agent. Terminal multiplexer, parallel AI agents, full workstation, one tool, any device.
|
||||
Use it from your phone, tablet, laptop, another computer, or the machine it's running on. Designed to feel native on every screen. Plug in an AI that can actually read, write, and run things on your machine, or bring your favourite terminal agent. Terminal multiplexer, parallel AI agents, full workstation, one tool, any device.
|
||||
|
||||
## Install
|
||||
|
||||
@@ -25,6 +25,10 @@ pip install cptr
|
||||
cptr run
|
||||
```
|
||||
|
||||
MCP tool servers require the optional MCP dependencies: `pip install 'cptr[mcp]'`.
|
||||
To install every optional feature group, use `pip install 'cptr[all]'`.
|
||||
The Docker image includes all optional feature groups.
|
||||
|
||||
Or with [uv](https://docs.astral.sh/uv/): `uvx cptr@latest run`
|
||||
|
||||
Opens in your browser at `http://localhost:8000`.
|
||||
|
||||
@@ -45,6 +45,9 @@ export const getGitShow = (root: string, ref: string) =>
|
||||
export const getGitBranches = (root: string) =>
|
||||
fetchJSON(`/api/git/branches?root=${encodeURIComponent(root)}`);
|
||||
|
||||
export const getGitStashes = (root: string) =>
|
||||
fetchJSON(`/api/git/stashes?root=${encodeURIComponent(root)}`);
|
||||
|
||||
export const stageFiles = (root: string, files: string[]) =>
|
||||
fetchJSON('/api/git/stage', jsonBody({ root, files }));
|
||||
|
||||
@@ -72,9 +75,29 @@ export const gitPush = (
|
||||
|
||||
export const gitUncommit = (root: string) => fetchJSON('/api/git/uncommit', jsonBody({ root }));
|
||||
|
||||
export const gitStash = (root: string, message?: string) =>
|
||||
fetchJSON('/api/git/stash', jsonBody({ root, message }));
|
||||
|
||||
export const gitUnstash = (root: string, index = 0) =>
|
||||
fetchJSON('/api/git/unstash', jsonBody({ root, index }));
|
||||
|
||||
export const createGitBranch = (root: string, name: string) =>
|
||||
fetchJSON('/api/git/branch', jsonBody({ root, name }));
|
||||
|
||||
export const renameGitBranch = (root: string, old_name: string, new_name: string) =>
|
||||
fetchJSON('/api/git/branch', {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ root, old_name, new_name })
|
||||
});
|
||||
|
||||
export const deleteGitBranch = (root: string, name: string) =>
|
||||
fetchJSON('/api/git/branch', {
|
||||
method: 'DELETE',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ root, name })
|
||||
});
|
||||
|
||||
export const checkoutBranch = (root: string, branch: string) =>
|
||||
fetchJSON('/api/git/checkout', jsonBody({ root, branch }));
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
let ttsVoice = $state('alloy');
|
||||
let ttsFormat = $state('mp3');
|
||||
let ttsPlaybackSpeed = $state(1);
|
||||
let ttsAutoStreamEnabled = $state(false);
|
||||
let hasExistingTtsKey = $state(false);
|
||||
let voiceModeSystemPrompt = $state('');
|
||||
let voiceModeSttMode = $state<'browser' | 'provider'>('browser');
|
||||
@@ -49,6 +50,7 @@
|
||||
ttsFormat = (config['audio.tts_format'] as string) || 'mp3';
|
||||
const speed = Number(config['audio.tts_playback_speed']);
|
||||
ttsPlaybackSpeed = Number.isFinite(speed) ? Math.min(Math.max(speed, 0.5), 2) : 1;
|
||||
ttsAutoStreamEnabled = config['audio.tts_auto_stream_enabled'] === true;
|
||||
hasExistingTtsKey = !!config['audio.tts_api_key'];
|
||||
voiceModeSystemPrompt = (config['audio.voice_mode_system_prompt'] as string) || '';
|
||||
voiceModeSttMode =
|
||||
@@ -72,6 +74,7 @@
|
||||
'audio.tts_voice': ttsVoice,
|
||||
'audio.tts_format': ttsFormat,
|
||||
'audio.tts_playback_speed': ttsPlaybackSpeed,
|
||||
'audio.tts_auto_stream_enabled': ttsAutoStreamEnabled,
|
||||
'audio.voice_mode_system_prompt': voiceModeSystemPrompt,
|
||||
'audio.voice_mode_stt_mode': voiceModeSttMode
|
||||
};
|
||||
@@ -105,23 +108,41 @@
|
||||
|
||||
<div class="flex flex-col gap-2.5">
|
||||
<label class="flex items-center justify-between cursor-pointer">
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('admin.audio.enableVoiceMemos')}</span>
|
||||
<ToggleSwitch value={voiceMemosEnabled} onchange={(v) => { voiceMemosEnabled = v; }} />
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400"
|
||||
>{$t('admin.audio.enableVoiceMemos')}</span
|
||||
>
|
||||
<ToggleSwitch
|
||||
value={voiceMemosEnabled}
|
||||
onchange={(v) => {
|
||||
voiceMemosEnabled = v;
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
|
||||
{$t('admin.audio.voiceMemosHint')}
|
||||
</p>
|
||||
|
||||
<label class="flex items-center justify-between cursor-pointer">
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('admin.audio.autoTranscribe')}</span>
|
||||
<ToggleSwitch value={transcribeEnabled} onchange={(v) => { transcribeEnabled = v; }} />
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400"
|
||||
>{$t('admin.audio.autoTranscribe')}</span
|
||||
>
|
||||
<ToggleSwitch
|
||||
value={transcribeEnabled}
|
||||
onchange={(v) => {
|
||||
transcribeEnabled = v;
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
|
||||
{transcribeEnabled ? $t('admin.audio.transcribeOnHint') : $t('admin.audio.transcribeOffHint')}
|
||||
{transcribeEnabled
|
||||
? $t('admin.audio.transcribeOnHint')
|
||||
: $t('admin.audio.transcribeOffHint')}
|
||||
</p>
|
||||
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('admin.audio.recordingQuality')}</span>
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400"
|
||||
>{$t('admin.audio.recordingQuality')}</span
|
||||
>
|
||||
<select
|
||||
bind:value={quality}
|
||||
class="bg-transparent text-xs text-gray-600 dark:text-gray-400 outline-none cursor-pointer"
|
||||
@@ -132,7 +153,11 @@
|
||||
</select>
|
||||
</div>
|
||||
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
|
||||
{quality === 'high' ? $t('admin.audio.qualityHintHigh') : quality === 'medium' ? $t('admin.audio.qualityHintMedium') : $t('admin.audio.qualityHintLow')}
|
||||
{quality === 'high'
|
||||
? $t('admin.audio.qualityHintHigh')
|
||||
: quality === 'medium'
|
||||
? $t('admin.audio.qualityHintMedium')
|
||||
: $t('admin.audio.qualityHintLow')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -141,7 +166,9 @@
|
||||
|
||||
<div class="flex flex-col gap-2.5">
|
||||
<div>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="stt-base-url">{$t('connections.baseUrl')}</label>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="stt-base-url"
|
||||
>{$t('connections.baseUrl')}</label
|
||||
>
|
||||
<input
|
||||
id="stt-base-url"
|
||||
type="text"
|
||||
@@ -151,7 +178,9 @@
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="stt-api-key">{$t('connections.apiKey')}</label>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="stt-api-key"
|
||||
>{$t('connections.apiKey')}</label
|
||||
>
|
||||
<input
|
||||
id="stt-api-key"
|
||||
type="password"
|
||||
@@ -161,7 +190,9 @@
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="stt-model">{$t('automations.model')}</label>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="stt-model"
|
||||
>{$t('automations.model')}</label
|
||||
>
|
||||
<input
|
||||
id="stt-model"
|
||||
type="text"
|
||||
@@ -181,13 +212,34 @@
|
||||
<div class="flex flex-col gap-2.5">
|
||||
<label class="flex items-center justify-between cursor-pointer">
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('admin.audio.enableTts')}</span>
|
||||
<ToggleSwitch value={ttsEnabled} onchange={(v) => { ttsEnabled = v; }} />
|
||||
<ToggleSwitch
|
||||
value={ttsEnabled}
|
||||
onchange={(v) => {
|
||||
ttsEnabled = v;
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
|
||||
{$t('admin.audio.ttsEnabledHint')}
|
||||
</p>
|
||||
<label class="flex items-center justify-between cursor-pointer">
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400"
|
||||
>{$t('admin.audio.ttsAutoStream')}</span
|
||||
>
|
||||
<ToggleSwitch
|
||||
value={ttsAutoStreamEnabled}
|
||||
onchange={(v) => {
|
||||
ttsAutoStreamEnabled = v;
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
|
||||
{$t('admin.audio.ttsAutoStreamHint')}
|
||||
</p>
|
||||
<div>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-base-url">{$t('connections.baseUrl')}</label>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-base-url"
|
||||
>{$t('connections.baseUrl')}</label
|
||||
>
|
||||
<input
|
||||
id="tts-base-url"
|
||||
type="text"
|
||||
@@ -197,7 +249,9 @@
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-api-key">{$t('connections.apiKey')}</label>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-api-key"
|
||||
>{$t('connections.apiKey')}</label
|
||||
>
|
||||
<input
|
||||
id="tts-api-key"
|
||||
type="password"
|
||||
@@ -207,7 +261,9 @@
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-model">{$t('automations.model')}</label>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-model"
|
||||
>{$t('automations.model')}</label
|
||||
>
|
||||
<input
|
||||
id="tts-model"
|
||||
type="text"
|
||||
@@ -217,7 +273,9 @@
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-voice">{$t('admin.audio.ttsVoice')}</label>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="tts-voice"
|
||||
>{$t('admin.audio.ttsVoice')}</label
|
||||
>
|
||||
<input
|
||||
id="tts-voice"
|
||||
type="text"
|
||||
@@ -254,7 +312,9 @@
|
||||
bind:value={ttsPlaybackSpeed}
|
||||
class="w-28 accent-gray-700 dark:accent-gray-300"
|
||||
/>
|
||||
<span class="w-9 text-right text-xs text-gray-500 dark:text-gray-400">{ttsPlaybackSpeed.toFixed(2)}x</span>
|
||||
<span class="w-9 text-right text-xs text-gray-500 dark:text-gray-400"
|
||||
>{ttsPlaybackSpeed.toFixed(2)}x</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-[11px] text-gray-400 dark:text-gray-600">
|
||||
@@ -263,11 +323,15 @@
|
||||
</div>
|
||||
|
||||
<!-- Voice Mode -->
|
||||
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">{$t('admin.audio.voiceMode')}</h3>
|
||||
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">
|
||||
{$t('admin.audio.voiceMode')}
|
||||
</h3>
|
||||
|
||||
<div class="flex flex-col gap-2.5">
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400">{$t('admin.audio.voiceModeSttMode')}</span>
|
||||
<span class="text-xs text-gray-600 dark:text-gray-400"
|
||||
>{$t('admin.audio.voiceModeSttMode')}</span
|
||||
>
|
||||
<select
|
||||
bind:value={voiceModeSttMode}
|
||||
class="bg-transparent text-xs text-gray-600 dark:text-gray-400 outline-none cursor-pointer"
|
||||
@@ -277,7 +341,9 @@
|
||||
</select>
|
||||
</div>
|
||||
<p class="text-[11px] text-gray-400 dark:text-gray-600 -mt-1">
|
||||
{voiceModeSttMode === 'browser' ? $t('admin.audio.voiceModeBrowserSttHint') : $t('admin.audio.voiceModeProviderSttHint')}
|
||||
{voiceModeSttMode === 'browser'
|
||||
? $t('admin.audio.voiceModeBrowserSttHint')
|
||||
: $t('admin.audio.voiceModeProviderSttHint')}
|
||||
</p>
|
||||
<div>
|
||||
<label class="text-xs text-gray-600 dark:text-gray-400" for="voice-mode-system-prompt">
|
||||
@@ -297,12 +363,14 @@
|
||||
</div>
|
||||
|
||||
<!-- Save -->
|
||||
<div class="mt-auto pt-6 flex justify-end">
|
||||
<div
|
||||
class="sticky bottom-0 -mx-4 md:-mx-5 mt-6 flex justify-end border-t border-gray-100 bg-white/95 px-4 py-3 backdrop-blur dark:border-white/6 dark:bg-black/95 md:px-5"
|
||||
>
|
||||
<button
|
||||
class="text-[13px] text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors duration-100 disabled:opacity-50"
|
||||
onclick={() => save()}
|
||||
disabled={saving}
|
||||
>{$t('settings.save')}</button>
|
||||
disabled={saving}>{$t('settings.save')}</button
|
||||
>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
check?: boolean;
|
||||
/** Optional keyboard shortcut hint displayed as a single pill on the right. */
|
||||
shortcut?: string;
|
||||
/** Optional trailing action button, e.g. row options. */
|
||||
actionIcon?: string;
|
||||
actionLabel?: string;
|
||||
actionOnclick?: (anchor: HTMLElement) => void;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
@@ -33,6 +37,12 @@
|
||||
maxHeight?: string;
|
||||
/** Optional header snippet rendered above items (e.g. search input). */
|
||||
header?: Snippet;
|
||||
/** Optional footer snippet rendered below items (e.g. pinned actions). */
|
||||
footer?: Snippet;
|
||||
/** Show a divider after the header. */
|
||||
headerDivider?: boolean;
|
||||
/** Show a divider before the footer. */
|
||||
footerDivider?: boolean;
|
||||
/** Optional snippet rendered when items array is empty. */
|
||||
empty?: Snippet;
|
||||
/** Additional CSS classes for the menu container. */
|
||||
@@ -51,6 +61,9 @@
|
||||
inlineAbove = false,
|
||||
maxHeight,
|
||||
header,
|
||||
footer,
|
||||
headerDivider = true,
|
||||
footerDivider = true,
|
||||
empty,
|
||||
className = '',
|
||||
align = 'start'
|
||||
@@ -120,15 +133,7 @@
|
||||
}
|
||||
|
||||
const rect = anchor.getBoundingClientRect();
|
||||
return [
|
||||
rect.left,
|
||||
rect.top,
|
||||
rect.right,
|
||||
rect.bottom,
|
||||
rect.width,
|
||||
rect.height,
|
||||
viewportState()
|
||||
]
|
||||
return [rect.left, rect.top, rect.right, rect.bottom, rect.width, rect.height, viewportState()]
|
||||
.map((value) => (typeof value === 'number' ? value.toFixed(2) : value))
|
||||
.join(':');
|
||||
}
|
||||
@@ -332,9 +337,9 @@
|
||||
: 'fixed'} z-[1001] min-w-36 rounded-xl bg-white dark:bg-[#1a1a1a] border border-gray-150 dark:border-white/6 shadow-xl p-0.5 flex flex-col overflow-hidden {className}"
|
||||
style="{inlineAbove
|
||||
? ''
|
||||
: `left: ${pos.x}px; ${pos.bottom != null ? `bottom: ${pos.bottom}px;` : `top: ${pos.top ?? -9999}px;`} ${menuMaxHeight
|
||||
? `max-height: ${menuMaxHeight}px;`
|
||||
: ''}`} {anchorWidth ? `width: ${anchorWidth}px;` : ''} opacity: {ready
|
||||
: `left: ${pos.x}px; ${pos.bottom != null ? `bottom: ${pos.bottom}px;` : `top: ${pos.top ?? -9999}px;`} ${
|
||||
menuMaxHeight ? `max-height: ${menuMaxHeight}px;` : ''
|
||||
}`} {anchorWidth ? `width: ${anchorWidth}px;` : ''} opacity: {ready
|
||||
? 1
|
||||
: 0}; pointer-events: {ready ? 'auto' : 'none'};"
|
||||
onclick={(e) => e.stopPropagation()}
|
||||
@@ -343,7 +348,9 @@
|
||||
{#if header}
|
||||
<div class="flex-none">
|
||||
{@render header()}
|
||||
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
|
||||
{#if headerDivider}
|
||||
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -355,41 +362,66 @@
|
||||
{#if item.divider}
|
||||
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
|
||||
{:else}
|
||||
<button
|
||||
class="flex items-center gap-2 w-full h-6 px-2 rounded-xl text-xs transition-colors duration-75
|
||||
<div
|
||||
class="group flex items-center gap-1 w-full h-6 rounded-xl text-xs transition-colors duration-75
|
||||
{item.active
|
||||
? 'text-gray-900 dark:text-white bg-gray-50 dark:bg-white/5'
|
||||
: 'text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white'}"
|
||||
onclick={() => {
|
||||
item.onclick();
|
||||
onclose();
|
||||
}}
|
||||
>
|
||||
{#if item.image}
|
||||
<img src={item.image} alt="" class="w-4 h-4 rounded-full object-cover shrink-0" />
|
||||
{:else if item.icon}
|
||||
<Icon name={item.icon} size={14} />
|
||||
{/if}
|
||||
<span class="flex-1 text-left truncate">{item.label}</span>
|
||||
{#if item.shortcut}
|
||||
<KeyPill text={item.shortcut} class="ml-auto shrink-0" />
|
||||
{/if}
|
||||
{#if item.check && item.active}
|
||||
<svg
|
||||
class="w-3 h-3 shrink-0 text-gray-400 dark:text-gray-500"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2.5"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
<button
|
||||
class="flex items-center gap-2 min-w-0 flex-1 h-full px-2 text-inherit"
|
||||
onclick={() => {
|
||||
item.onclick();
|
||||
onclose();
|
||||
}}
|
||||
>
|
||||
{#if item.image}
|
||||
<img src={item.image} alt="" class="w-4 h-4 rounded-full object-cover shrink-0" />
|
||||
{:else if item.icon}
|
||||
<Icon name={item.icon} size={14} />
|
||||
{/if}
|
||||
<span class="flex-1 text-left truncate">{item.label}</span>
|
||||
{#if item.shortcut}
|
||||
<KeyPill text={item.shortcut} class="ml-auto shrink-0" />
|
||||
{/if}
|
||||
{#if item.check && item.active}
|
||||
<svg
|
||||
class="w-3 h-3 shrink-0 text-gray-400 dark:text-gray-500"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2.5"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<polyline points="20 6 9 17 4 12" />
|
||||
</svg>
|
||||
{/if}
|
||||
</button>
|
||||
{#if item.actionIcon && item.actionOnclick}
|
||||
<button
|
||||
class="flex items-center justify-center w-5 h-5 mr-0.5 rounded-lg shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-200 dark:hover:bg-white/10 transition-all duration-75"
|
||||
aria-label={item.actionLabel}
|
||||
onclick={(e) => {
|
||||
e.stopPropagation();
|
||||
item.actionOnclick?.(e.currentTarget as HTMLElement);
|
||||
}}
|
||||
>
|
||||
<polyline points="20 6 9 17 4 12" />
|
||||
</svg>
|
||||
<Icon name={item.actionIcon} size={12} />
|
||||
</button>
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if footer}
|
||||
<div class="flex-none">
|
||||
{#if footerDivider}
|
||||
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
|
||||
{/if}
|
||||
{@render footer()}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
getGitDiff,
|
||||
getGitShow,
|
||||
getGitBranches,
|
||||
getGitStatusFresh,
|
||||
getGitStashes,
|
||||
stageFiles,
|
||||
unstageFiles,
|
||||
discardChanges,
|
||||
@@ -13,29 +15,60 @@
|
||||
gitPull,
|
||||
gitPush,
|
||||
gitUncommit,
|
||||
gitStash,
|
||||
gitUnstash,
|
||||
checkoutBranch,
|
||||
createGitBranch
|
||||
createGitBranch,
|
||||
deleteGitBranch,
|
||||
renameGitBranch
|
||||
} from '$lib/apis/git';
|
||||
import { gitStatusStore } from '$lib/stores/gitStatus.svelte';
|
||||
import Icon from './Icon.svelte';
|
||||
import DropdownMenu from './DropdownMenu.svelte';
|
||||
import Modal from './Modal.svelte';
|
||||
import { tooltip } from '$lib/tooltip';
|
||||
import { t } from '$lib/i18n';
|
||||
import Spinner from '$lib/components/common/Spinner.svelte';
|
||||
|
||||
type GitFile = { path: string; status: string; staged: boolean };
|
||||
type GitFile = {
|
||||
path: string;
|
||||
status: string;
|
||||
staged: boolean;
|
||||
unstaged?: boolean;
|
||||
staged_status?: string;
|
||||
unstaged_status?: string;
|
||||
};
|
||||
type DiffHunk = { header: string; lines: { type: string; content: string }[] };
|
||||
type DiffFile = { path: string; hunks: DiffHunk[] };
|
||||
type Commit = { hash: string; short_hash: string; author: string; date: string; message: string };
|
||||
type BranchItem = {
|
||||
name: string;
|
||||
is_current?: boolean;
|
||||
is_local?: boolean;
|
||||
is_remote?: boolean;
|
||||
upstream?: string | null;
|
||||
};
|
||||
|
||||
let expanded = $state(false);
|
||||
let view = $state<'changes' | 'history'>('changes');
|
||||
let showDiff = $state(false);
|
||||
let showBranches = $state(false);
|
||||
let branchBtnEl = $state<HTMLButtonElement | undefined>();
|
||||
let branchSearchInputEl = $state<HTMLInputElement | undefined>();
|
||||
let newBranchInputEl = $state<HTMLInputElement | undefined>();
|
||||
let commits = $state<Commit[]>([]);
|
||||
let branchData = $state<{ current: string; local: string[]; remote: string[] } | null>(null);
|
||||
let branchData = $state<{
|
||||
current: string;
|
||||
local: string[];
|
||||
remote: string[];
|
||||
all?: BranchItem[];
|
||||
} | null>(null);
|
||||
let branchSearch = $state('');
|
||||
let newBranchName = $state('');
|
||||
let creatingBranch = $state(false);
|
||||
let pendingCheckoutBranch = $state<string | null>(null);
|
||||
let pendingCreateBranch = $state<string | null>(null);
|
||||
let branchActionMenu = $state<{ branch: BranchItem; anchor: HTMLElement } | null>(null);
|
||||
let selectedFile = $state<string | null>(null);
|
||||
let selectedCommit = $state<Commit | null>(null);
|
||||
let fileDiff = $state<DiffFile[]>([]);
|
||||
@@ -71,6 +104,26 @@
|
||||
// Branch has never been pushed to remote
|
||||
const needsPublish = $derived(!gitStatus?.upstream);
|
||||
const unpushedCount = $derived(needsPublish ? (commits?.length ?? 0) : (gitStatus?.ahead ?? 0));
|
||||
const filteredBranches = $derived.by(() => {
|
||||
const branches = branchData?.all ?? [];
|
||||
const query = branchSearch.trim().toLowerCase();
|
||||
if (!query) return branches;
|
||||
return branches.filter((branch) => branch.name.toLowerCase().includes(query));
|
||||
});
|
||||
const branchMenuItems = $derived(
|
||||
filteredBranches.map((branch) => ({
|
||||
label: branch.name,
|
||||
icon: 'git-branch',
|
||||
active: Boolean(branch.is_current),
|
||||
check: true,
|
||||
onclick: () => switchBranch(branch.name),
|
||||
actionIcon: 'three-dots',
|
||||
actionLabel: 'Branch actions',
|
||||
actionOnclick: (anchor: HTMLElement) => {
|
||||
branchActionMenu = { branch, anchor };
|
||||
}
|
||||
}))
|
||||
);
|
||||
|
||||
// Convert git remote URL to browser URL
|
||||
const remoteWebUrl = $derived.by(() => {
|
||||
@@ -175,6 +228,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleBranches(e: MouseEvent) {
|
||||
e.stopPropagation();
|
||||
if (showBranches) {
|
||||
showBranches = false;
|
||||
return;
|
||||
}
|
||||
showBranches = true;
|
||||
branchSearch = '';
|
||||
creatingBranch = false;
|
||||
newBranchName = '';
|
||||
await loadBranches();
|
||||
setTimeout(() => branchSearchInputEl?.focus(), 0);
|
||||
}
|
||||
|
||||
function switchView(v: 'changes' | 'history') {
|
||||
view = v;
|
||||
showDiff = false;
|
||||
@@ -212,6 +279,10 @@
|
||||
async function doCommit() {
|
||||
if (!commitSummary.trim() || !stagedFiles.length) return;
|
||||
loading = true;
|
||||
await stageFiles(
|
||||
workspacePath,
|
||||
stagedFiles.map((f) => f.path)
|
||||
);
|
||||
const msg = commitDescription.trim()
|
||||
? `${commitSummary.trim()}\n\n${commitDescription.trim()}`
|
||||
: commitSummary.trim();
|
||||
@@ -273,22 +344,106 @@
|
||||
}
|
||||
|
||||
async function switchBranch(branch: string) {
|
||||
if (branch === gitStatus?.branch) {
|
||||
showBranches = false;
|
||||
return;
|
||||
}
|
||||
if (totalChanges > 0) {
|
||||
pendingCheckoutBranch = branch;
|
||||
showBranches = false;
|
||||
return;
|
||||
}
|
||||
await performBranchCheckout(branch, 'bring');
|
||||
}
|
||||
|
||||
async function restoreStashedChangesForBranch(branch: string) {
|
||||
const stashes = (await getGitStashes(workspacePath)) as { message?: string }[];
|
||||
const index = stashes.findIndex((stash) => {
|
||||
const message = stash.message ?? '';
|
||||
return (
|
||||
message.includes(`cptr-branch-switch:${branch}`) ||
|
||||
message.includes(`Changes on ${branch} before checking out`)
|
||||
);
|
||||
});
|
||||
if (index < 0) return;
|
||||
|
||||
const freshStatus = (await getGitStatusFresh(workspacePath)) as { files?: GitFile[] };
|
||||
if ((freshStatus.files ?? []).length > 0) return;
|
||||
|
||||
const result = (await gitUnstash(workspacePath, index)) as { ok?: boolean; message?: string };
|
||||
if (result.ok) {
|
||||
flash(`Restored changes for ${branch}`);
|
||||
} else {
|
||||
flash(result.message || `Could not restore changes for ${branch}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function performBranchCheckout(branch: string, changeMode: 'bring' | 'leave') {
|
||||
loading = true;
|
||||
await checkoutBranch(workspacePath, branch);
|
||||
showBranches = false;
|
||||
loading = false;
|
||||
await refresh();
|
||||
try {
|
||||
if (changeMode === 'leave') {
|
||||
const currentBranch = gitStatus?.branch || 'current branch';
|
||||
const message = `cptr-branch-switch:${currentBranch}`;
|
||||
const stashResult = (await gitStash(workspacePath, message)) as {
|
||||
ok?: boolean;
|
||||
message?: string;
|
||||
};
|
||||
if (!stashResult.ok) {
|
||||
flash(stashResult.message || 'No changes stashed');
|
||||
return;
|
||||
}
|
||||
}
|
||||
await checkoutBranch(workspacePath, branch);
|
||||
pendingCheckoutBranch = null;
|
||||
await restoreStashedChangesForBranch(branch);
|
||||
} catch (e) {
|
||||
flash(e instanceof Error ? e.message : 'Failed to switch branch');
|
||||
} finally {
|
||||
loading = false;
|
||||
await refresh();
|
||||
}
|
||||
}
|
||||
|
||||
async function createBranch() {
|
||||
if (!newBranchName.trim()) return;
|
||||
const branch = newBranchName.trim();
|
||||
if (totalChanges > 0) {
|
||||
pendingCreateBranch = branch;
|
||||
creatingBranch = false;
|
||||
showBranches = false;
|
||||
return;
|
||||
}
|
||||
await performBranchCreate(branch, 'bring');
|
||||
}
|
||||
|
||||
async function performBranchCreate(branch: string, changeMode: 'bring' | 'leave') {
|
||||
loading = true;
|
||||
await createGitBranch(workspacePath, newBranchName.trim());
|
||||
newBranchName = '';
|
||||
creatingBranch = false;
|
||||
showBranches = false;
|
||||
loading = false;
|
||||
await refresh();
|
||||
try {
|
||||
if (changeMode === 'leave') {
|
||||
const currentBranch = gitStatus?.branch || 'current branch';
|
||||
const stashResult = (await gitStash(
|
||||
workspacePath,
|
||||
`cptr-branch-switch:${currentBranch}`
|
||||
)) as {
|
||||
ok?: boolean;
|
||||
message?: string;
|
||||
};
|
||||
if (!stashResult.ok) {
|
||||
flash(stashResult.message || 'No changes stashed');
|
||||
return;
|
||||
}
|
||||
}
|
||||
await createGitBranch(workspacePath, branch);
|
||||
newBranchName = '';
|
||||
creatingBranch = false;
|
||||
showBranches = false;
|
||||
pendingCreateBranch = null;
|
||||
} catch (e) {
|
||||
flash(e instanceof Error ? e.message : 'Failed to create branch');
|
||||
} finally {
|
||||
loading = false;
|
||||
await refresh();
|
||||
}
|
||||
}
|
||||
|
||||
function flash(m: string) {
|
||||
@@ -320,6 +475,45 @@
|
||||
commitMenu = null;
|
||||
}
|
||||
|
||||
function closeBranchActionMenu() {
|
||||
branchActionMenu = null;
|
||||
}
|
||||
|
||||
async function renameBranch(branch: BranchItem) {
|
||||
if (!branch.is_local) return;
|
||||
const nextName = window.prompt('Rename branch', branch.name)?.trim();
|
||||
if (!nextName || nextName === branch.name) return;
|
||||
try {
|
||||
await renameGitBranch(workspacePath, branch.name, nextName);
|
||||
flash('Branch renamed');
|
||||
closeBranchActionMenu();
|
||||
await refresh({ force: true });
|
||||
await loadBranches();
|
||||
} catch (e) {
|
||||
flash(e instanceof Error ? e.message : 'Failed to rename branch');
|
||||
}
|
||||
}
|
||||
|
||||
function copyBranchName(branch: BranchItem) {
|
||||
navigator.clipboard.writeText(branch.name);
|
||||
flash('Branch name copied');
|
||||
closeBranchActionMenu();
|
||||
}
|
||||
|
||||
async function deleteBranch(branch: BranchItem) {
|
||||
if (!branch.is_local || branch.is_current) return;
|
||||
if (!confirm(`Delete branch "${branch.name}"?`)) return;
|
||||
try {
|
||||
await deleteGitBranch(workspacePath, branch.name);
|
||||
flash('Branch deleted');
|
||||
closeBranchActionMenu();
|
||||
await refresh({ force: true });
|
||||
await loadBranches();
|
||||
} catch (e) {
|
||||
flash(e instanceof Error ? e.message : 'Failed to delete branch');
|
||||
}
|
||||
}
|
||||
|
||||
async function discardFile(path: string) {
|
||||
await discardChanges(workspacePath, [path]);
|
||||
if (selectedFile === path) {
|
||||
@@ -490,12 +684,9 @@
|
||||
>
|
||||
<!-- Branch button (opens branch picker, stops expand) -->
|
||||
<button
|
||||
bind:this={branchBtnEl}
|
||||
class="flex items-center gap-1.5 h-6 px-1.5 -ml-1.5 rounded-md hover:bg-gray-100 dark:hover:bg-white/6 transition-colors duration-75"
|
||||
onclick={(e) => {
|
||||
e.stopPropagation();
|
||||
showBranches = !showBranches;
|
||||
if (showBranches) loadBranches();
|
||||
}}
|
||||
onclick={toggleBranches}
|
||||
>
|
||||
<Icon name="git-branch" size={12} class="text-gray-400 dark:text-gray-600 shrink-0" />
|
||||
<span class="text-[11px] text-gray-600 dark:text-gray-400 font-mono"
|
||||
@@ -545,65 +736,99 @@
|
||||
</div>
|
||||
|
||||
<!-- Branch picker dropdown -->
|
||||
{#if showBranches}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div class="fixed inset-0 z-40" onclick={() => (showBranches = false)}></div>
|
||||
<div
|
||||
class="absolute bottom-full left-2 mb-1 w-56 max-h-64 overflow-y-auto rounded-xl border border-gray-150 dark:border-white/6 bg-white dark:bg-[#1a1a1a] shadow-xl z-50 p-0.5"
|
||||
{#if showBranches && branchBtnEl}
|
||||
<DropdownMenu
|
||||
items={branchMenuItems}
|
||||
anchor={branchBtnEl}
|
||||
onclose={() => {
|
||||
showBranches = false;
|
||||
creatingBranch = false;
|
||||
newBranchName = '';
|
||||
}}
|
||||
preferAbove
|
||||
forceAbove
|
||||
maxHeight="15rem"
|
||||
className="w-56"
|
||||
align="start"
|
||||
headerDivider={false}
|
||||
footerDivider={false}
|
||||
>
|
||||
<!-- New branch -->
|
||||
{#if creatingBranch}
|
||||
<div
|
||||
class="flex items-center gap-1.5 px-2 py-1.5 border-b border-gray-100 dark:border-white/4"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
class="flex-1 h-6 px-1.5 rounded border border-gray-200 dark:border-white/10 bg-transparent text-xs text-gray-900 dark:text-white placeholder:text-gray-400 outline-none"
|
||||
placeholder={$t('git.branchName')}
|
||||
bind:value={newBranchName}
|
||||
onkeydown={(e) => {
|
||||
if (e.key === 'Enter') createBranch();
|
||||
if (e.key === 'Escape') {
|
||||
{#snippet header()}
|
||||
<div class="px-2 pb-0.5">
|
||||
<div class="flex items-center gap-1.5 h-6 mt-0.5">
|
||||
<Icon name="search" size={13} class="shrink-0 text-gray-300 dark:text-gray-600" />
|
||||
<input
|
||||
bind:this={branchSearchInputEl}
|
||||
bind:value={branchSearch}
|
||||
placeholder="Search branches"
|
||||
class="w-full bg-transparent text-[11px] text-gray-500 dark:text-gray-400 placeholder:text-gray-300 dark:placeholder:text-gray-600 outline-none"
|
||||
onkeydown={(e) => {
|
||||
if (e.key === 'Escape') showBranches = false;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{#if !branchData}
|
||||
<div class="flex items-center justify-center h-10">
|
||||
<Spinner size={14} />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/snippet}
|
||||
{#snippet empty()}
|
||||
{#if branchData}
|
||||
<div class="px-3 py-2 text-[11px] text-gray-400 dark:text-gray-500 text-center">
|
||||
No branches found
|
||||
</div>
|
||||
{/if}
|
||||
{/snippet}
|
||||
{#snippet footer()}
|
||||
{#if creatingBranch}
|
||||
<div class="flex items-center gap-2 h-7 px-2">
|
||||
<Icon name="git-branch" size={14} class="text-gray-400 shrink-0" />
|
||||
<input
|
||||
bind:this={newBranchInputEl}
|
||||
type="text"
|
||||
class="flex-1 border-none outline-none bg-transparent text-xs text-gray-900 dark:text-white placeholder:text-gray-400"
|
||||
placeholder={$t('git.branchName')}
|
||||
bind:value={newBranchName}
|
||||
onkeydown={(e) => {
|
||||
if (e.key === 'Enter') createBranch();
|
||||
if (e.key === 'Escape') {
|
||||
creatingBranch = false;
|
||||
newBranchName = '';
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<button
|
||||
class="flex items-center justify-center w-5 h-5 rounded text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/6 transition-colors duration-75"
|
||||
onclick={() => {
|
||||
creatingBranch = false;
|
||||
newBranchName = '';
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Icon name="xmark" size={12} />
|
||||
</button>
|
||||
<button
|
||||
class="flex items-center justify-center w-5 h-5 rounded text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/6 transition-colors duration-75"
|
||||
onclick={createBranch}
|
||||
>
|
||||
<Icon name="check" size={12} />
|
||||
</button>
|
||||
</div>
|
||||
{:else}
|
||||
<button
|
||||
class="flex items-center gap-2 w-full h-7 px-2 rounded-xl text-xs text-gray-600 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-white/5 hover:text-gray-900 dark:hover:text-white transition-colors"
|
||||
onclick={() => {
|
||||
creatingBranch = true;
|
||||
setTimeout(() => newBranchInputEl?.focus(), 0);
|
||||
}}
|
||||
autofocus
|
||||
/>
|
||||
<button
|
||||
class="text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"
|
||||
onclick={createBranch}
|
||||
>
|
||||
<Icon name="check" size={12} />
|
||||
<Icon name="plus" size={14} />
|
||||
<span class="truncate">New branch</span>
|
||||
</button>
|
||||
</div>
|
||||
{:else}
|
||||
<button
|
||||
class="flex items-center gap-1.5 w-full h-7 px-2.5 text-[11px] text-gray-500 hover:bg-gray-50 dark:hover:bg-white/4 transition-colors border-b border-gray-100 dark:border-white/4"
|
||||
onclick={() => (creatingBranch = true)}
|
||||
>
|
||||
<Icon name="plus" size={11} />
|
||||
<span>{$t('git.newBranch')}</span>
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
{#if branchData}
|
||||
{#each branchData.all ?? [] as b}
|
||||
<button
|
||||
class="flex items-center gap-1.5 w-full h-7 px-2.5 text-left transition-colors duration-75
|
||||
{b.is_current ? 'bg-gray-50 dark:bg-white/4' : 'hover:bg-gray-50 dark:hover:bg-white/3'}"
|
||||
onclick={() => switchBranch(b.name)}
|
||||
>
|
||||
<span class="w-3 shrink-0">{b.is_current ? '✓' : ''}</span>
|
||||
<span class="text-xs text-gray-800 dark:text-gray-200 truncate">{b.name}</span>
|
||||
</button>
|
||||
{/each}
|
||||
{:else}
|
||||
<div class="flex items-center justify-center h-10">
|
||||
<Spinner size={14} />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</DropdownMenu>
|
||||
{/if}
|
||||
|
||||
{#if expanded}
|
||||
@@ -704,7 +929,7 @@
|
||||
|
||||
<!-- File list -->
|
||||
<div class="flex-1 overflow-y-auto">
|
||||
{#each gitStatus?.files ?? [] as file (`${file.path}:${file.staged}`)}
|
||||
{#each gitStatus?.files ?? [] as file (file.path)}
|
||||
{@const fp = fPath(file.path)}
|
||||
{@const sc = statusChar(file.status)}
|
||||
<button
|
||||
@@ -948,6 +1173,110 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if pendingCheckoutBranch}
|
||||
<Modal onclose={() => (pendingCheckoutBranch = null)} class="w-full max-w-sm mx-4">
|
||||
<div class="p-4">
|
||||
<h2 class="text-sm font-medium text-gray-900 dark:text-white">Switch branches?</h2>
|
||||
<p class="mt-1.5 text-xs leading-relaxed text-gray-500 dark:text-gray-400">
|
||||
You have {totalChanges} changed {totalChanges === 1 ? 'file' : 'files'} on
|
||||
<span class="font-mono text-gray-700 dark:text-gray-300">{gitStatus?.branch}</span>. Choose
|
||||
whether to leave those changes here or bring them to
|
||||
<span class="font-mono text-gray-700 dark:text-gray-300">{pendingCheckoutBranch}</span>.
|
||||
</p>
|
||||
<div class="mt-4 flex items-center justify-end gap-2">
|
||||
<button
|
||||
class="px-2.5 py-1 text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors"
|
||||
onclick={() => (pendingCheckoutBranch = null)}
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
class="px-2.5 py-1 text-xs text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white transition-colors"
|
||||
onclick={() => performBranchCheckout(pendingCheckoutBranch!, 'leave')}
|
||||
disabled={loading}
|
||||
>
|
||||
Leave changes
|
||||
</button>
|
||||
<button
|
||||
class="px-3.5 py-1.5 text-xs bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition-colors rounded-full disabled:opacity-50"
|
||||
onclick={() => performBranchCheckout(pendingCheckoutBranch!, 'bring')}
|
||||
disabled={loading}
|
||||
>
|
||||
Bring changes
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
{/if}
|
||||
|
||||
{#if pendingCreateBranch}
|
||||
<Modal onclose={() => (pendingCreateBranch = null)} class="w-full max-w-sm mx-4">
|
||||
<div class="p-4">
|
||||
<h2 class="text-sm font-medium text-gray-900 dark:text-white">Create branch?</h2>
|
||||
<p class="mt-1.5 text-xs leading-relaxed text-gray-500 dark:text-gray-400">
|
||||
You have {totalChanges} changed {totalChanges === 1 ? 'file' : 'files'} on
|
||||
<span class="font-mono text-gray-700 dark:text-gray-300">{gitStatus?.branch}</span>. Choose
|
||||
whether to leave those changes here or bring them to
|
||||
<span class="font-mono text-gray-700 dark:text-gray-300">{pendingCreateBranch}</span>.
|
||||
</p>
|
||||
<div class="mt-4 flex items-center justify-end gap-2">
|
||||
<button
|
||||
class="px-2.5 py-1 text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors"
|
||||
onclick={() => (pendingCreateBranch = null)}
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
class="px-2.5 py-1 text-xs text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white transition-colors"
|
||||
onclick={() => performBranchCreate(pendingCreateBranch!, 'leave')}
|
||||
disabled={loading}
|
||||
>
|
||||
Leave changes
|
||||
</button>
|
||||
<button
|
||||
class="px-3.5 py-1.5 text-xs bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition-colors rounded-full disabled:opacity-50"
|
||||
onclick={() => performBranchCreate(pendingCreateBranch!, 'bring')}
|
||||
disabled={loading}
|
||||
>
|
||||
Bring changes
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
{/if}
|
||||
|
||||
{#if branchActionMenu}
|
||||
<DropdownMenu
|
||||
anchor={branchActionMenu.anchor}
|
||||
items={[
|
||||
...(branchActionMenu.branch.is_local
|
||||
? [
|
||||
{
|
||||
label: 'Rename',
|
||||
icon: 'pencil',
|
||||
onclick: () => renameBranch(branchActionMenu!.branch)
|
||||
}
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: 'Copy branch name',
|
||||
icon: 'copy',
|
||||
onclick: () => copyBranchName(branchActionMenu!.branch)
|
||||
},
|
||||
...(branchActionMenu.branch.is_local && !branchActionMenu.branch.is_current
|
||||
? [
|
||||
{
|
||||
label: 'Delete',
|
||||
icon: 'xmark',
|
||||
onclick: () => deleteBranch(branchActionMenu!.branch)
|
||||
}
|
||||
]
|
||||
: [])
|
||||
]}
|
||||
onclose={closeBranchActionMenu}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if contextMenu}
|
||||
<DropdownMenu
|
||||
anchor={contextMenu.anchor}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
ttsConfigured,
|
||||
ttsFormat,
|
||||
setTtsAudioPlaybackSource,
|
||||
ttsAutoStreamEnabled,
|
||||
ttsPlaybackEnabled,
|
||||
ttsVoice,
|
||||
unlockTtsAudioPlayback,
|
||||
@@ -511,7 +512,10 @@
|
||||
voiceModeEnabled.set(false);
|
||||
ttsPlaybackEnabled.set(false);
|
||||
stopTtsPlayback();
|
||||
} else if ((!$ttsPlaybackEnabled && !$voiceModeEnabled) || !$ttsConfigured) {
|
||||
} else if (
|
||||
(!$ttsPlaybackEnabled && !$voiceModeEnabled && !$ttsAutoStreamEnabled) ||
|
||||
!$ttsConfigured
|
||||
) {
|
||||
stopTtsPlayback();
|
||||
}
|
||||
});
|
||||
@@ -598,6 +602,7 @@
|
||||
if (!text || !selectedModel) return;
|
||||
if (sending) return;
|
||||
stopTtsPlayback();
|
||||
if (shouldStreamTts()) void unlockTtsAudioPlayback();
|
||||
sending = true;
|
||||
const files = chatInputEl?.getFiles() ?? [];
|
||||
// Transform TipTap mention format to markdown file links
|
||||
@@ -949,7 +954,15 @@
|
||||
}
|
||||
|
||||
function shouldUseTts() {
|
||||
return $ttsEnabled && $ttsConfigured && ($ttsPlaybackEnabled || $voiceModeEnabled);
|
||||
return (
|
||||
$ttsEnabled &&
|
||||
$ttsConfigured &&
|
||||
($ttsPlaybackEnabled || $voiceModeEnabled || $ttsAutoStreamEnabled)
|
||||
);
|
||||
}
|
||||
|
||||
function shouldStreamTts() {
|
||||
return $ttsEnabled && $ttsConfigured && ($voiceModeEnabled || $ttsAutoStreamEnabled);
|
||||
}
|
||||
|
||||
function resetTtsBuffer() {
|
||||
@@ -1023,7 +1036,7 @@
|
||||
}
|
||||
|
||||
function handleTtsDelta(messageId: string, delta: string) {
|
||||
if (!shouldUseTts()) return;
|
||||
if (!shouldStreamTts()) return;
|
||||
if (!delta.trim()) return;
|
||||
|
||||
const active = allMessages.find((m) => m.id === messageId);
|
||||
@@ -1043,7 +1056,7 @@
|
||||
}
|
||||
|
||||
function flushTtsBuffer() {
|
||||
if (!shouldUseTts()) return;
|
||||
if (!shouldStreamTts()) return;
|
||||
const chunk = cleanSpeechText(ttsBuffer);
|
||||
resetTtsBuffer();
|
||||
if (chunk.length > 1) enqueueSpeech(chunk);
|
||||
@@ -1242,6 +1255,7 @@
|
||||
if (generation === ttsGeneration) ttsPlaying = false;
|
||||
if (generation === ttsGeneration) speakingMessageId = null;
|
||||
if (generation === ttsGeneration) ttsStopRequested = false;
|
||||
if (generation === ttsGeneration && !$voiceModeEnabled) ttsPlaybackEnabled.set(false);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -478,6 +478,8 @@
|
||||
"admin.audio.tts": "Text-to-Speech",
|
||||
"admin.audio.enableTts": "Text-to-Speech aktivieren",
|
||||
"admin.audio.ttsEnabledHint": "Aktiviert den Sprachmodus und die Vorlesen-Schaltflächen, wenn ein TTS-Schlüssel verfügbar ist.",
|
||||
"admin.audio.ttsAutoStream": "Stream-Antworten vorlesen",
|
||||
"admin.audio.ttsAutoStreamHint": "Liest jede Assistentenantwort beim Streamen laut vor, auch außerhalb des Sprachmodus.",
|
||||
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
|
||||
"admin.audio.ttsVoice": "Voice",
|
||||
"admin.audio.ttsFormat": "Format",
|
||||
|
||||
@@ -593,6 +593,8 @@
|
||||
"admin.audio.tts": "Text-to-Speech",
|
||||
"admin.audio.enableTts": "Enable Text-to-Speech",
|
||||
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
|
||||
"admin.audio.ttsAutoStream": "Speak streamed responses",
|
||||
"admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
|
||||
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
|
||||
"admin.audio.ttsVoice": "Voice",
|
||||
"admin.audio.ttsFormat": "Format",
|
||||
|
||||
@@ -478,6 +478,8 @@
|
||||
"admin.audio.tts": "Text-to-Speech",
|
||||
"admin.audio.enableTts": "Enable Text-to-Speech",
|
||||
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
|
||||
"admin.audio.ttsAutoStream": "Speak streamed responses",
|
||||
"admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
|
||||
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
|
||||
"admin.audio.ttsVoice": "Voice",
|
||||
"admin.audio.ttsFormat": "Format",
|
||||
|
||||
@@ -477,6 +477,8 @@
|
||||
"admin.audio.tts": "Text-to-Speech",
|
||||
"admin.audio.enableTts": "Enable Text-to-Speech",
|
||||
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
|
||||
"admin.audio.ttsAutoStream": "Speak streamed responses",
|
||||
"admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
|
||||
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
|
||||
"admin.audio.ttsVoice": "Voice",
|
||||
"admin.audio.ttsFormat": "Format",
|
||||
|
||||
@@ -478,6 +478,8 @@
|
||||
"admin.audio.tts": "Text-to-Speech",
|
||||
"admin.audio.enableTts": "Enable Text-to-Speech",
|
||||
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
|
||||
"admin.audio.ttsAutoStream": "Speak streamed responses",
|
||||
"admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
|
||||
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
|
||||
"admin.audio.ttsVoice": "Voice",
|
||||
"admin.audio.ttsFormat": "Format",
|
||||
|
||||
@@ -478,6 +478,8 @@
|
||||
"admin.audio.tts": "Text-to-Speech",
|
||||
"admin.audio.enableTts": "Enable Text-to-Speech",
|
||||
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
|
||||
"admin.audio.ttsAutoStream": "Speak streamed responses",
|
||||
"admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
|
||||
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
|
||||
"admin.audio.ttsVoice": "Voice",
|
||||
"admin.audio.ttsFormat": "Format",
|
||||
|
||||
@@ -478,6 +478,8 @@
|
||||
"admin.audio.tts": "Text-to-Speech",
|
||||
"admin.audio.enableTts": "Enable Text-to-Speech",
|
||||
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
|
||||
"admin.audio.ttsAutoStream": "Speak streamed responses",
|
||||
"admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
|
||||
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
|
||||
"admin.audio.ttsVoice": "Voice",
|
||||
"admin.audio.ttsFormat": "Format",
|
||||
|
||||
@@ -478,6 +478,8 @@
|
||||
"admin.audio.tts": "Text-to-Speech",
|
||||
"admin.audio.enableTts": "Enable Text-to-Speech",
|
||||
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
|
||||
"admin.audio.ttsAutoStream": "Speak streamed responses",
|
||||
"admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
|
||||
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
|
||||
"admin.audio.ttsVoice": "Voice",
|
||||
"admin.audio.ttsFormat": "Format",
|
||||
|
||||
@@ -478,6 +478,8 @@
|
||||
"admin.audio.tts": "Text-to-Speech",
|
||||
"admin.audio.enableTts": "Enable Text-to-Speech",
|
||||
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
|
||||
"admin.audio.ttsAutoStream": "Speak streamed responses",
|
||||
"admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
|
||||
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
|
||||
"admin.audio.ttsVoice": "Voice",
|
||||
"admin.audio.ttsFormat": "Format",
|
||||
|
||||
@@ -478,6 +478,8 @@
|
||||
"admin.audio.tts": "Text-to-Speech",
|
||||
"admin.audio.enableTts": "Enable Text-to-Speech",
|
||||
"admin.audio.ttsEnabledHint": "Enables voice mode and assistant speak buttons when a TTS key is available.",
|
||||
"admin.audio.ttsAutoStream": "Speak streamed responses",
|
||||
"admin.audio.ttsAutoStreamHint": "Read every assistant response aloud as it streams, even outside voice mode.",
|
||||
"admin.audio.ttsKeyPlaceholder": "Leave blank to reuse STT key",
|
||||
"admin.audio.ttsVoice": "Voice",
|
||||
"admin.audio.ttsFormat": "Format",
|
||||
|
||||
@@ -22,10 +22,13 @@ export const ttsConfigured = writable<boolean>(false);
|
||||
export const ttsVoice = writable<string>('alloy');
|
||||
export const ttsFormat = writable<string>('mp3');
|
||||
export const ttsPlaybackSpeed = writable<number>(1);
|
||||
export const ttsAutoStreamEnabled = writable<boolean>(false);
|
||||
export const voiceModeEnabled = writable<boolean>(false);
|
||||
export const voiceModeSttMode = writable<'browser' | 'provider'>('browser');
|
||||
export const ttsPlaybackEnabled = writable<boolean>(
|
||||
typeof localStorage !== 'undefined' ? localStorage.getItem('ttsPlaybackEnabled') === 'true' : false
|
||||
typeof localStorage !== 'undefined'
|
||||
? localStorage.getItem('ttsPlaybackEnabled') === 'true'
|
||||
: false
|
||||
);
|
||||
|
||||
const SILENT_WAV =
|
||||
@@ -74,7 +77,8 @@ export async function unlockTtsAudioPlayback() {
|
||||
|
||||
const unlocks: Promise<unknown>[] = [];
|
||||
const AudioContextCtor =
|
||||
window.AudioContext || (window as Window & { webkitAudioContext?: typeof AudioContext }).webkitAudioContext;
|
||||
window.AudioContext ||
|
||||
(window as Window & { webkitAudioContext?: typeof AudioContext }).webkitAudioContext;
|
||||
try {
|
||||
if (AudioContextCtor) {
|
||||
ttsAudioContext ??= new AudioContextCtor();
|
||||
@@ -128,6 +132,7 @@ export async function refreshAudioState() {
|
||||
tts_voice: string;
|
||||
tts_format: string;
|
||||
tts_playback_speed?: number;
|
||||
tts_auto_stream_enabled?: boolean;
|
||||
voice_mode_stt_mode?: string;
|
||||
}>('/api/audio/state');
|
||||
voiceMemosEnabled.set(data.voice_memos_enabled === true);
|
||||
@@ -142,6 +147,7 @@ export async function refreshAudioState() {
|
||||
ttsFormat.set(data.tts_format || 'mp3');
|
||||
const speed = Number(data.tts_playback_speed);
|
||||
ttsPlaybackSpeed.set(Number.isFinite(speed) ? Math.min(Math.max(speed, 0.5), 2) : 1);
|
||||
ttsAutoStreamEnabled.set(data.tts_auto_stream_enabled === true);
|
||||
voiceModeSttMode.set(data.voice_mode_stt_mode === 'provider' ? 'provider' : 'browser');
|
||||
} catch {
|
||||
voiceMemosEnabled.set(false);
|
||||
@@ -149,6 +155,7 @@ export async function refreshAudioState() {
|
||||
ttsEnabled.set(false);
|
||||
ttsConfigured.set(false);
|
||||
ttsPlaybackSpeed.set(1);
|
||||
ttsAutoStreamEnabled.set(false);
|
||||
voiceModeSttMode.set('browser');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ export interface GitFile {
|
||||
path: string;
|
||||
status: string;
|
||||
staged: boolean;
|
||||
unstaged?: boolean;
|
||||
staged_status?: string;
|
||||
unstaged_status?: string;
|
||||
}
|
||||
|
||||
export interface GitStatus {
|
||||
|
||||
@@ -348,7 +348,7 @@
|
||||
<div class="mb-6">
|
||||
<h2 class="text-xs text-gray-400 dark:text-gray-600 mb-2">{$t('home.recent')}</h2>
|
||||
<div class="flex flex-col">
|
||||
{#each welcomeData.recent as item}
|
||||
{#each welcomeData.recent.slice(0, 5) as item}
|
||||
<button
|
||||
class="flex items-center gap-3 py-1.5 group text-left transition-colors duration-100"
|
||||
onclick={() => quickOpen(item.path)}
|
||||
@@ -371,7 +371,7 @@
|
||||
<div>
|
||||
<h2 class="text-xs text-gray-400 dark:text-gray-600 mb-2">{$t('home.folders')}</h2>
|
||||
<div class="flex flex-col">
|
||||
{#each welcomeData.suggestions as item}
|
||||
{#each welcomeData.suggestions.slice(0, 5) as item}
|
||||
<button
|
||||
class="flex items-center gap-2 py-1.5 text-[13px] text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors duration-100"
|
||||
onclick={() => quickOpen(item.path)}
|
||||
|
||||
@@ -646,5 +646,15 @@ async def verify_tool_server(server_id: str, request: Request):
|
||||
tools = convert_openapi_to_tool_specs(spec)
|
||||
return {"ok": True, "tools": tools}
|
||||
|
||||
except ModuleNotFoundError as e:
|
||||
if e.name == "mcp":
|
||||
return JSONResponse(
|
||||
{
|
||||
"ok": False,
|
||||
"message": "MCP support is not installed. Run: pip install 'cptr[mcp]'",
|
||||
},
|
||||
400,
|
||||
)
|
||||
return JSONResponse({"ok": False, "message": str(e)}, 400)
|
||||
except Exception as e:
|
||||
return JSONResponse({"ok": False, "message": str(e)}, 400)
|
||||
|
||||
@@ -55,6 +55,7 @@ class AudioStateResponse(BaseModel):
|
||||
tts_voice: str
|
||||
tts_format: str
|
||||
tts_playback_speed: float
|
||||
tts_auto_stream_enabled: bool
|
||||
voice_mode_stt_mode: str
|
||||
|
||||
|
||||
@@ -218,6 +219,7 @@ async def audio_state(request: Request):
|
||||
tts_voice=str((await Config.get("audio.tts_voice")) or "alloy"),
|
||||
tts_format=str((await Config.get("audio.tts_format")) or "mp3"),
|
||||
tts_playback_speed=playback_speed,
|
||||
tts_auto_stream_enabled=await Config.get("audio.tts_auto_stream_enabled") is True,
|
||||
voice_mode_stt_mode=str((await Config.get("audio.voice_mode_stt_mode")) or "browser"),
|
||||
)
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ from cptr.utils.git import (
|
||||
log,
|
||||
pull,
|
||||
push,
|
||||
rename_branch,
|
||||
show,
|
||||
stage,
|
||||
stash_list,
|
||||
@@ -145,6 +146,12 @@ class DeleteBranchRequest(BaseModel):
|
||||
name: str
|
||||
|
||||
|
||||
class RenameBranchRequest(BaseModel):
|
||||
root: str
|
||||
old_name: str
|
||||
new_name: str
|
||||
|
||||
|
||||
class RootRequest(BaseModel):
|
||||
root: str
|
||||
|
||||
@@ -235,6 +242,16 @@ async def git_delete_branch(body: DeleteBranchRequest):
|
||||
_handle_git_error(e)
|
||||
|
||||
|
||||
@router.patch("/branch")
|
||||
async def git_rename_branch(body: RenameBranchRequest):
|
||||
"""Rename a local branch."""
|
||||
try:
|
||||
await rename_branch(body.root, body.old_name, body.new_name)
|
||||
return {"ok": True}
|
||||
except GitError as e:
|
||||
_handle_git_error(e)
|
||||
|
||||
|
||||
@router.post("/pull")
|
||||
async def git_pull(body: RootRequest):
|
||||
"""Pull from remote."""
|
||||
|
||||
+2
-2
@@ -448,7 +448,7 @@ def _to_openai_messages(messages: list[dict], instructions: str) -> list[dict]:
|
||||
if rc:
|
||||
out["reasoning_content"] = rc
|
||||
# Clean tool_calls: remove fc_id which is Responses-API-only
|
||||
if "tool_calls" in out:
|
||||
if out.get("tool_calls"):
|
||||
out["tool_calls"] = [
|
||||
{k: v for k, v in tc.items() if k != "fc_id"} for tc in out["tool_calls"]
|
||||
]
|
||||
@@ -554,7 +554,7 @@ async def stream_openai_completions(
|
||||
emitted = True
|
||||
yield {"type": "output", "item": item}
|
||||
|
||||
for tc in delta.get("tool_calls", []):
|
||||
for tc in delta.get("tool_calls") or []:
|
||||
idx = tc["index"]
|
||||
if idx not in tool_calls:
|
||||
tool_calls[idx] = {
|
||||
|
||||
+37
-19
@@ -68,7 +68,32 @@ async def status(root: str) -> dict[str, Any]:
|
||||
ahead = 0
|
||||
behind = 0
|
||||
has_ab = False
|
||||
files: list[dict] = []
|
||||
files_by_path: dict[str, dict[str, Any]] = {}
|
||||
|
||||
def add_file(
|
||||
path: str,
|
||||
status_text: str,
|
||||
*,
|
||||
staged: bool = False,
|
||||
unstaged: bool = False,
|
||||
) -> None:
|
||||
entry = files_by_path.setdefault(
|
||||
path,
|
||||
{
|
||||
"path": path,
|
||||
"status": status_text,
|
||||
"staged": False,
|
||||
"unstaged": False,
|
||||
},
|
||||
)
|
||||
if staged:
|
||||
entry["staged"] = True
|
||||
entry["staged_status"] = status_text
|
||||
if unstaged:
|
||||
entry["unstaged"] = True
|
||||
entry["unstaged_status"] = status_text
|
||||
# Prefer the working-tree status for the row label when both sides exist.
|
||||
entry["status"] = status_text
|
||||
|
||||
for line in out.splitlines():
|
||||
if line.startswith("# branch.head "):
|
||||
@@ -94,30 +119,18 @@ async def status(root: str) -> dict[str, Any]:
|
||||
staged_code = xy[0]
|
||||
unstaged_code = xy[1]
|
||||
if staged_code != ".":
|
||||
files.append(
|
||||
{
|
||||
"path": path,
|
||||
"status": _status_char(staged_code),
|
||||
"staged": True,
|
||||
}
|
||||
)
|
||||
add_file(path, _status_char(staged_code), staged=True)
|
||||
if unstaged_code != ".":
|
||||
files.append(
|
||||
{
|
||||
"path": path,
|
||||
"status": _status_char(unstaged_code),
|
||||
"staged": False,
|
||||
}
|
||||
)
|
||||
add_file(path, _status_char(unstaged_code), unstaged=True)
|
||||
elif line.startswith("? "):
|
||||
# Untracked
|
||||
path = line[2:]
|
||||
files.append({"path": path, "status": "untracked", "staged": False})
|
||||
add_file(path, "untracked", unstaged=True)
|
||||
elif line.startswith("u "):
|
||||
# Unmerged
|
||||
parts = line.split(" ", 10)
|
||||
path = parts[-1]
|
||||
files.append({"path": path, "status": "conflict", "staged": False})
|
||||
add_file(path, "conflict", unstaged=True)
|
||||
|
||||
# upstream is set but remote branch doesn't exist yet (no ab line)
|
||||
# — treat as unpublished so the frontend shows "Publish"
|
||||
@@ -136,7 +149,7 @@ async def status(root: str) -> dict[str, Any]:
|
||||
"remote_url": remote_url,
|
||||
"ahead": ahead,
|
||||
"behind": behind,
|
||||
"files": files,
|
||||
"files": list(files_by_path.values()),
|
||||
}
|
||||
|
||||
|
||||
@@ -472,6 +485,11 @@ async def delete_branch(root: str, name: str) -> None:
|
||||
await _run("branch", "-d", name, cwd=root)
|
||||
|
||||
|
||||
async def rename_branch(root: str, old_name: str, new_name: str) -> None:
|
||||
"""Rename a local branch."""
|
||||
await _run("branch", "-m", old_name, new_name, cwd=root)
|
||||
|
||||
|
||||
async def pull(root: str) -> dict[str, Any]:
|
||||
"""Pull from remote."""
|
||||
code, out, err = await _run("pull", cwd=root, check=False)
|
||||
@@ -539,7 +557,7 @@ async def stash_list(root: str) -> list[dict[str, str]]:
|
||||
|
||||
async def stash_save(root: str, message: str | None = None) -> dict[str, Any]:
|
||||
"""Stash changes."""
|
||||
args = ["stash", "push"]
|
||||
args = ["stash", "push", "--include-untracked"]
|
||||
if message:
|
||||
args.extend(["-m", message])
|
||||
code, out, err = await _run(*args, cwd=root, check=False)
|
||||
|
||||
+8
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "cptr"
|
||||
version = "0.5.2"
|
||||
version = "0.5.3"
|
||||
description = "Your computer, from anywhere. Code, manage, and control your machine from the web."
|
||||
license = {file = "LICENSE"}
|
||||
readme = "README.md"
|
||||
@@ -27,6 +27,13 @@ dependencies = [
|
||||
pam = ["python-pam>=2.0"]
|
||||
mcp = ["mcp>=1.8"]
|
||||
docs = ["pypdf>=4.0", "python-docx>=1.0", "openpyxl>=3.1"]
|
||||
all = [
|
||||
"mcp>=1.8",
|
||||
"pypdf>=4.0",
|
||||
"python-docx>=1.0",
|
||||
"openpyxl>=3.1",
|
||||
"python-pam>=2.0",
|
||||
]
|
||||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
|
||||
@@ -265,7 +265,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "cptr"
|
||||
version = "0.4.10"
|
||||
version = "0.5.2"
|
||||
source = { editable = "." }
|
||||
dependencies = [
|
||||
{ name = "aiosqlite" },
|
||||
@@ -286,6 +286,13 @@ dependencies = [
|
||||
]
|
||||
|
||||
[package.optional-dependencies]
|
||||
all = [
|
||||
{ name = "mcp" },
|
||||
{ name = "openpyxl" },
|
||||
{ name = "pypdf" },
|
||||
{ name = "python-docx" },
|
||||
{ name = "python-pam" },
|
||||
]
|
||||
docs = [
|
||||
{ name = "openpyxl" },
|
||||
{ name = "pypdf" },
|
||||
@@ -313,12 +320,17 @@ requires-dist = [
|
||||
{ name = "fastapi", extras = ["standard"], specifier = ">=0.128.8" },
|
||||
{ name = "httpx", specifier = ">=0.28.1" },
|
||||
{ name = "loguru", specifier = ">=0.7.3" },
|
||||
{ name = "mcp", marker = "extra == 'all'", specifier = ">=1.8" },
|
||||
{ name = "mcp", marker = "extra == 'mcp'", specifier = ">=1.8" },
|
||||
{ name = "openpyxl", marker = "extra == 'all'", specifier = ">=3.1" },
|
||||
{ name = "openpyxl", marker = "extra == 'docs'", specifier = ">=3.1" },
|
||||
{ name = "pyjwt", specifier = ">=2.8" },
|
||||
{ name = "pypdf", marker = "extra == 'all'", specifier = ">=4.0" },
|
||||
{ name = "pypdf", marker = "extra == 'docs'", specifier = ">=4.0" },
|
||||
{ name = "python-dateutil", specifier = ">=2.8" },
|
||||
{ name = "python-docx", marker = "extra == 'all'", specifier = ">=1.0" },
|
||||
{ name = "python-docx", marker = "extra == 'docs'", specifier = ">=1.0" },
|
||||
{ name = "python-pam", marker = "extra == 'all'", specifier = ">=2.0" },
|
||||
{ name = "python-pam", marker = "extra == 'pam'", specifier = ">=2.0" },
|
||||
{ name = "python-socketio", extras = ["asgi"], specifier = ">=5.11" },
|
||||
{ name = "pywinpty", marker = "sys_platform == 'win32'", specifier = ">=2.0" },
|
||||
|
||||
Reference in New Issue
Block a user