mirror of
https://github.com/open-webui/computer.git
synced 2026-11-22 21:50:43 -05:00
8 files changed
+410
-127
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.4.9] - 2026-06-15
|
||||
|
||||
### Fixed
|
||||
|
||||
- 📱 **Mobile keyboard no longer covers the chat.** On iOS and mobile browsers, opening the on-screen keyboard could push content behind it or clip the bottom of the screen. The layout now properly adjusts to keep everything visible above the keyboard.
|
||||
- 🗑️ **Discarding staged files works correctly.** Previously, discarding a file that was already staged (added to a commit) could leave it in a broken state. Staged changes are now properly unstaged and cleaned up in one step.
|
||||
- 🔄 **Git file list no longer flickers when staging.** Toggling a file between staged and unstaged could briefly cause a visual glitch where the list jumped. The file list now updates smoothly.
|
||||
|
||||
### Improved
|
||||
|
||||
- 📋 **Dropdown menus stay on screen.** Dropdown menus (like the model picker) now correctly reposition themselves to stay within the visible area, especially when the keyboard is open or on smaller screens.
|
||||
- 📖 **README updated with badges and clearer tunnel docs.** Added project badges (stars, language, Discord) to the top of the README, and clarified the remote access / tunnel instructions.
|
||||
|
||||
## [0.4.8] - 2026-06-15
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# cptr
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
[](https://discord.gg/5rJgQTnV4s)
|
||||
[](https://github.com/sponsors/tjbck)
|
||||
|
||||

|
||||
|
||||
The computer used to be a room. Then a desk. Then a bag. Now it's a URL.
|
||||
@@ -35,12 +45,14 @@ cptr run --host 0.0.0.0
|
||||
|
||||
Open `http://<your-computer-ip>:8000` on your phone.
|
||||
|
||||
Not on the same network? Use a tunnel:
|
||||
Not on the same network? Use a tunnel to reach your machine remotely:
|
||||
|
||||
- **[Tailscale](https://tailscale.com)** creates a private mesh network between your devices. Recommended.
|
||||
- **[Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/)** gives you a permanent URL through Cloudflare's edge.
|
||||
- **[ngrok](https://ngrok.com)** gives you a public URL in one command.
|
||||
|
||||
Most tunnels forward to `localhost`, so the default `cptr run` works. If your tunnel connects to a specific interface, bind accordingly with `--host`.
|
||||
|
||||
Or skip networking entirely and connect a [messaging bot](#messaging-bots) instead.
|
||||
|
||||
## What you get
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
matchWidth?: boolean;
|
||||
/** Prefer opening above the anchor instead of below. */
|
||||
preferAbove?: boolean;
|
||||
/** Keep the menu above the anchor and shrink it to fit the visible viewport. */
|
||||
forceAbove?: boolean;
|
||||
/** Position above the trigger in normal layout instead of fixed to the viewport. */
|
||||
inlineAbove?: boolean;
|
||||
/** Max height for the items list (CSS value). */
|
||||
maxHeight?: string;
|
||||
/** Optional header snippet rendered above items (e.g. search input). */
|
||||
@@ -43,6 +47,8 @@
|
||||
onclose,
|
||||
matchWidth = false,
|
||||
preferAbove = false,
|
||||
forceAbove = false,
|
||||
inlineAbove = false,
|
||||
maxHeight,
|
||||
header,
|
||||
empty,
|
||||
@@ -51,13 +57,106 @@
|
||||
}: Props = $props();
|
||||
|
||||
let menuEl: HTMLDivElement | undefined = $state();
|
||||
let pos = $state<{ x: number; top?: number; bottom?: number }>({ x: -9999 });
|
||||
let pos = $state<{ x: number; top: number }>({ x: -9999, top: -9999 });
|
||||
let anchorWidth = $state(0);
|
||||
let menuMaxHeight = $state<number | undefined>();
|
||||
let ready = $state(false);
|
||||
let frame: number | undefined;
|
||||
let anchorFrame: number | undefined;
|
||||
let settleTimers: number[] = [];
|
||||
let lastViewportState = '';
|
||||
let lastAnchorState = '';
|
||||
|
||||
function portal(node: HTMLElement, enabled = true) {
|
||||
const parent = node.parentNode;
|
||||
const sibling = node.nextSibling;
|
||||
|
||||
function move() {
|
||||
if (enabled && node.parentNode !== document.body) {
|
||||
document.body.appendChild(node);
|
||||
} else if (!enabled && parent && node.parentNode === document.body) {
|
||||
parent.insertBefore(node, sibling);
|
||||
}
|
||||
}
|
||||
|
||||
move();
|
||||
|
||||
return {
|
||||
update(nextEnabled: boolean) {
|
||||
enabled = nextEnabled;
|
||||
move();
|
||||
},
|
||||
destroy() {
|
||||
node.remove();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function visualViewportRect() {
|
||||
const vv = window.visualViewport;
|
||||
return {
|
||||
left: vv?.offsetLeft ?? 0,
|
||||
top: vv?.offsetTop ?? 0,
|
||||
width: vv?.width ?? window.innerWidth,
|
||||
height: vv?.height ?? window.innerHeight
|
||||
};
|
||||
}
|
||||
|
||||
function viewportState() {
|
||||
const viewport = visualViewportRect();
|
||||
return [
|
||||
viewport.left,
|
||||
viewport.top,
|
||||
viewport.width,
|
||||
viewport.height,
|
||||
window.innerWidth,
|
||||
window.innerHeight
|
||||
].join(':');
|
||||
}
|
||||
|
||||
function anchorState() {
|
||||
if (!(anchor instanceof HTMLElement)) {
|
||||
return `${anchor.x}:${anchor.y}:${viewportState()}`;
|
||||
}
|
||||
|
||||
const rect = anchor.getBoundingClientRect();
|
||||
return [
|
||||
rect.left,
|
||||
rect.top,
|
||||
rect.right,
|
||||
rect.bottom,
|
||||
rect.width,
|
||||
rect.height,
|
||||
viewportState()
|
||||
]
|
||||
.map((value) => (typeof value === 'number' ? value.toFixed(2) : value))
|
||||
.join(':');
|
||||
}
|
||||
|
||||
function measureMenu() {
|
||||
if (!menuEl) return { width: 0, height: 0 };
|
||||
|
||||
const previousMaxHeight = menuEl.style.maxHeight;
|
||||
menuEl.style.maxHeight = '';
|
||||
const size = {
|
||||
width: menuEl.offsetWidth,
|
||||
height: menuEl.offsetHeight
|
||||
};
|
||||
menuEl.style.maxHeight = previousMaxHeight;
|
||||
return size;
|
||||
}
|
||||
|
||||
function updatePosition() {
|
||||
if (!menuEl) return;
|
||||
|
||||
if (inlineAbove) {
|
||||
if (matchWidth && anchor instanceof HTMLElement) {
|
||||
anchorWidth = anchor.getBoundingClientRect().width;
|
||||
}
|
||||
ready = true;
|
||||
return;
|
||||
}
|
||||
|
||||
let ax: number;
|
||||
let anchorTop: number;
|
||||
let anchorBottom: number;
|
||||
@@ -74,10 +173,10 @@
|
||||
anchorBottom = anchor.y;
|
||||
}
|
||||
|
||||
const mw = menuEl.offsetWidth;
|
||||
const mh = menuEl.offsetHeight;
|
||||
const vw = window.innerWidth;
|
||||
const vh = window.innerHeight;
|
||||
const { width: mw, height: mh } = measureMenu();
|
||||
const viewport = visualViewportRect();
|
||||
const viewportRight = viewport.left + viewport.width;
|
||||
const viewportBottom = viewport.top + viewport.height;
|
||||
const pad = 8;
|
||||
const gap = 4;
|
||||
|
||||
@@ -86,46 +185,135 @@
|
||||
const rect = anchor.getBoundingClientRect();
|
||||
ax = rect.right - mw;
|
||||
}
|
||||
if (ax + mw > vw - pad) ax = vw - mw - pad;
|
||||
if (ax < pad) ax = pad;
|
||||
if (ax + mw > viewportRight - pad) ax = viewportRight - mw - pad;
|
||||
if (ax < viewport.left + pad) ax = viewport.left + pad;
|
||||
|
||||
// Vertical: collision detection
|
||||
const spaceAbove = anchorTop - gap - pad;
|
||||
const spaceBelow = vh - anchorBottom - gap - pad;
|
||||
const spaceAbove = anchorTop - viewport.top - gap - pad;
|
||||
const spaceBelow = viewportBottom - anchorBottom - gap - pad;
|
||||
|
||||
if (preferAbove) {
|
||||
if (mh <= spaceAbove) {
|
||||
pos = { x: ax, bottom: vh - anchorTop + gap };
|
||||
} else {
|
||||
pos = { x: ax, top: anchorBottom + gap };
|
||||
}
|
||||
let nextTop: number;
|
||||
let availableHeight: number;
|
||||
|
||||
if (forceAbove || (preferAbove && (mh <= spaceAbove || spaceAbove >= spaceBelow))) {
|
||||
availableHeight = spaceAbove;
|
||||
const visibleMenuHeight = Math.min(mh, Math.max(0, availableHeight));
|
||||
nextTop = anchorTop - gap - visibleMenuHeight;
|
||||
} else {
|
||||
if (mh <= spaceBelow) {
|
||||
pos = { x: ax, top: anchorBottom + gap };
|
||||
availableHeight = spaceBelow;
|
||||
nextTop = anchorBottom + gap;
|
||||
} else {
|
||||
pos = { x: ax, bottom: vh - anchorTop + gap };
|
||||
availableHeight = spaceAbove;
|
||||
const visibleMenuHeight = Math.min(mh, Math.max(0, availableHeight));
|
||||
nextTop = anchorTop - gap - visibleMenuHeight;
|
||||
}
|
||||
}
|
||||
|
||||
menuMaxHeight =
|
||||
availableHeight >= 0 && (forceAbove || mh > availableHeight || menuMaxHeight != null)
|
||||
? Math.max(0, availableHeight)
|
||||
: undefined;
|
||||
const maxTop = viewportBottom - pad - (menuMaxHeight ?? mh);
|
||||
nextTop = Math.min(Math.max(nextTop, viewport.top + pad), Math.max(viewport.top + pad, maxTop));
|
||||
pos = { x: ax, top: nextTop };
|
||||
ready = true;
|
||||
}
|
||||
|
||||
function scheduleUpdate() {
|
||||
if (frame != null) cancelAnimationFrame(frame);
|
||||
frame = requestAnimationFrame(() => {
|
||||
frame = undefined;
|
||||
updatePosition();
|
||||
});
|
||||
}
|
||||
|
||||
function scheduleSettledUpdates() {
|
||||
for (const timer of settleTimers) window.clearTimeout(timer);
|
||||
settleTimers = [];
|
||||
scheduleUpdate();
|
||||
for (const delay of [50, 150, 300]) {
|
||||
settleTimers.push(window.setTimeout(scheduleUpdate, delay));
|
||||
}
|
||||
}
|
||||
|
||||
function handleViewportChange() {
|
||||
const nextViewportState = viewportState();
|
||||
if (nextViewportState === lastViewportState) return;
|
||||
lastViewportState = nextViewportState;
|
||||
scheduleSettledUpdates();
|
||||
}
|
||||
|
||||
function handleFocusIn(event: FocusEvent) {
|
||||
if (event.target instanceof Node && menuEl?.contains(event.target)) {
|
||||
scheduleSettledUpdates();
|
||||
}
|
||||
}
|
||||
|
||||
function trackAnchor() {
|
||||
const nextAnchorState = anchorState();
|
||||
if (nextAnchorState !== lastAnchorState) {
|
||||
lastAnchorState = nextAnchorState;
|
||||
updatePosition();
|
||||
}
|
||||
anchorFrame = requestAnimationFrame(trackAnchor);
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
requestAnimationFrame(updatePosition);
|
||||
let dvhProbe: HTMLDivElement | undefined;
|
||||
let dvhObserver: ResizeObserver | undefined;
|
||||
|
||||
lastViewportState = viewportState();
|
||||
lastAnchorState = anchorState();
|
||||
scheduleUpdate();
|
||||
anchorFrame = requestAnimationFrame(trackAnchor);
|
||||
|
||||
// Follow anchor on scroll/resize
|
||||
window.addEventListener('scroll', updatePosition, true);
|
||||
window.addEventListener('resize', updatePosition);
|
||||
window.addEventListener('scroll', scheduleUpdate, true);
|
||||
window.addEventListener('resize', scheduleSettledUpdates);
|
||||
window.visualViewport?.addEventListener('resize', scheduleSettledUpdates);
|
||||
window.visualViewport?.addEventListener('scroll', scheduleUpdate);
|
||||
document.addEventListener('focusin', handleFocusIn);
|
||||
|
||||
if ('ResizeObserver' in window) {
|
||||
dvhProbe = document.createElement('div');
|
||||
dvhProbe.style.position = 'fixed';
|
||||
dvhProbe.style.left = '-1px';
|
||||
dvhProbe.style.top = '0';
|
||||
dvhProbe.style.width = '1px';
|
||||
dvhProbe.style.height = '100dvh';
|
||||
dvhProbe.style.pointerEvents = 'none';
|
||||
dvhProbe.style.visibility = 'hidden';
|
||||
document.body.appendChild(dvhProbe);
|
||||
|
||||
dvhObserver = new ResizeObserver(handleViewportChange);
|
||||
dvhObserver.observe(dvhProbe);
|
||||
}
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('scroll', updatePosition, true);
|
||||
window.removeEventListener('resize', updatePosition);
|
||||
if (frame != null) cancelAnimationFrame(frame);
|
||||
if (anchorFrame != null) cancelAnimationFrame(anchorFrame);
|
||||
for (const timer of settleTimers) window.clearTimeout(timer);
|
||||
dvhObserver?.disconnect();
|
||||
dvhProbe?.remove();
|
||||
window.removeEventListener('scroll', scheduleUpdate, true);
|
||||
window.removeEventListener('resize', scheduleSettledUpdates);
|
||||
window.visualViewport?.removeEventListener('resize', scheduleSettledUpdates);
|
||||
window.visualViewport?.removeEventListener('scroll', scheduleUpdate);
|
||||
document.removeEventListener('focusin', handleFocusIn);
|
||||
};
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
maxHeight;
|
||||
if (menuEl) scheduleSettledUpdates();
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
class="fixed inset-0 z-[100]"
|
||||
use:portal={!inlineAbove}
|
||||
class="fixed inset-0 z-[1000]"
|
||||
onclick={onclose}
|
||||
oncontextmenu={(e) => {
|
||||
e.preventDefault();
|
||||
@@ -135,22 +323,29 @@
|
||||
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
use:portal={!inlineAbove}
|
||||
bind:this={menuEl}
|
||||
class="fixed z-[101] min-w-36 rounded-xl bg-white dark:bg-[#1a1a1a] border border-gray-150 dark:border-white/6 shadow-xl p-0.5 {className}"
|
||||
style="left: {pos.x}px; {pos.bottom != null
|
||||
? `bottom: ${pos.bottom}px`
|
||||
: `top: ${pos.top ?? -9999}px`}; {anchorWidth ? `width: ${anchorWidth}px;` : ''} opacity: {ready
|
||||
class="{inlineAbove
|
||||
? `absolute bottom-full mb-1 ${align === 'end' ? 'right-0' : 'left-0'}`
|
||||
: '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; top: ${pos.top}px; ${menuMaxHeight
|
||||
? `max-height: ${menuMaxHeight}px;`
|
||||
: ''}`} {anchorWidth ? `width: ${anchorWidth}px;` : ''} opacity: {ready
|
||||
? 1
|
||||
: 0}; pointer-events: {ready ? 'auto' : 'none'};"
|
||||
onclick={(e) => e.stopPropagation()}
|
||||
onmousedown={(e) => e.stopPropagation()}
|
||||
>
|
||||
{#if header}
|
||||
{@render header()}
|
||||
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
|
||||
<div class="flex-none">
|
||||
{@render header()}
|
||||
<div class="h-px bg-gray-100/50 dark:bg-white/3 mx-1 my-0.5"></div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div style={maxHeight ? `max-height: ${maxHeight}; overflow-y: auto;` : ''}>
|
||||
<div class="flex-1 min-h-0 overflow-y-auto" style={maxHeight ? `max-height: ${maxHeight};` : ''}>
|
||||
{#if items.length === 0 && empty}
|
||||
{@render empty()}
|
||||
{:else}
|
||||
|
||||
@@ -685,7 +685,7 @@
|
||||
|
||||
<!-- File list -->
|
||||
<div class="flex-1 overflow-y-auto">
|
||||
{#each gitStatus?.files ?? [] as file (file.path)}
|
||||
{#each gitStatus?.files ?? [] as file (`${file.path}:${file.staged}`)}
|
||||
{@const fp = fPath(file.path)}
|
||||
{@const sc = statusChar(file.status)}
|
||||
<button
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { tick } from 'svelte';
|
||||
import { onMount, tick } from 'svelte';
|
||||
import { chatModels } from '$lib/stores/chat';
|
||||
import DropdownMenu from '../DropdownMenu.svelte';
|
||||
import { t } from '$lib/i18n';
|
||||
@@ -15,6 +15,9 @@
|
||||
let searchInputEl: HTMLInputElement | undefined = $state();
|
||||
let open = $state(false);
|
||||
let search = $state('');
|
||||
let isSmallViewport = $state(false);
|
||||
|
||||
const selectorMaxHeight = $derived(isSmallViewport ? '7.5rem' : '15rem');
|
||||
|
||||
const filtered = $derived(
|
||||
search.trim()
|
||||
@@ -33,6 +36,20 @@
|
||||
}))
|
||||
);
|
||||
|
||||
function updateViewportSize() {
|
||||
isSmallViewport = (window.visualViewport?.width ?? window.innerWidth) < 640;
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
updateViewportSize();
|
||||
window.addEventListener('resize', updateViewportSize);
|
||||
window.visualViewport?.addEventListener('resize', updateViewportSize);
|
||||
return () => {
|
||||
window.removeEventListener('resize', updateViewportSize);
|
||||
window.visualViewport?.removeEventListener('resize', updateViewportSize);
|
||||
};
|
||||
});
|
||||
|
||||
async function toggle() {
|
||||
if ($chatModels.length === 0) return;
|
||||
if (open) {
|
||||
@@ -48,67 +65,70 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<button
|
||||
bind:this={btnEl}
|
||||
class="flex items-center gap-1 px-2 py-1 rounded-lg text-[11px] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 transition-colors duration-100"
|
||||
onclick={toggle}
|
||||
>
|
||||
<span class="truncate max-w-[160px]"
|
||||
>{$chatModels.length === 0
|
||||
? $t('modelSelector.noModels')
|
||||
: $chatModels.find((m) => m.id === selectedModel)?.name || $t('modelSelector.selectModel')}</span
|
||||
<span class="relative inline-flex {open ? 'z-[1001]' : ''}">
|
||||
<button
|
||||
bind:this={btnEl}
|
||||
class="flex items-center gap-1 px-2 py-1 rounded-lg text-[11px] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-400 hover:bg-gray-50 dark:hover:bg-white/5 transition-colors duration-100"
|
||||
onclick={toggle}
|
||||
>
|
||||
{#if $chatModels.length > 0}
|
||||
<svg
|
||||
class="w-3 h-3 opacity-50"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2.5"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
<span class="truncate max-w-[160px]"
|
||||
>{$chatModels.length === 0
|
||||
? $t('modelSelector.noModels')
|
||||
: $chatModels.find((m) => m.id === selectedModel)?.name || $t('modelSelector.selectModel')}</span
|
||||
>
|
||||
<polyline points="6 9 12 15 18 9" />
|
||||
</svg>
|
||||
{/if}
|
||||
</button>
|
||||
{#if $chatModels.length > 0}
|
||||
<svg
|
||||
class="w-3 h-3 opacity-50"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2.5"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<polyline points="6 9 12 15 18 9" />
|
||||
</svg>
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
{#if open && btnEl && $chatModels.length > 0}
|
||||
<DropdownMenu
|
||||
items={menuItems}
|
||||
anchor={btnEl}
|
||||
onclose={() => (open = false)}
|
||||
preferAbove={preferAbove}
|
||||
maxHeight="15rem"
|
||||
className="w-48"
|
||||
align={align}
|
||||
>
|
||||
{#snippet header()}
|
||||
<div class="flex items-center gap-1.5 h-6 px-2 mt-0.5">
|
||||
<svg
|
||||
class="w-3 h-3 shrink-0 text-gray-300 dark:text-gray-600"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="11" cy="11" r="8" /><line x1="21" y1="21" x2="16.65" y2="16.65" />
|
||||
</svg>
|
||||
<input
|
||||
bind:this={searchInputEl}
|
||||
bind:value={search}
|
||||
placeholder={$t('modelSelector.search')}
|
||||
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') open = false;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{/snippet}
|
||||
{#snippet empty()}
|
||||
<div class="px-3 py-1.5 text-[11px] text-gray-400 dark:text-gray-500 text-center">{$t('modelSelector.noMatches')}</div>
|
||||
{/snippet}
|
||||
</DropdownMenu>
|
||||
{/if}
|
||||
{#if open && btnEl && $chatModels.length > 0}
|
||||
<DropdownMenu
|
||||
items={menuItems}
|
||||
anchor={btnEl}
|
||||
onclose={() => (open = false)}
|
||||
preferAbove={preferAbove}
|
||||
forceAbove={preferAbove}
|
||||
maxHeight={selectorMaxHeight}
|
||||
className="w-48"
|
||||
align={align}
|
||||
>
|
||||
{#snippet header()}
|
||||
<div class="flex items-center gap-1.5 h-6 px-2 mt-0.5">
|
||||
<svg
|
||||
class="w-3 h-3 shrink-0 text-gray-300 dark:text-gray-600"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<circle cx="11" cy="11" r="8" /><line x1="21" y1="21" x2="16.65" y2="16.65" />
|
||||
</svg>
|
||||
<input
|
||||
bind:this={searchInputEl}
|
||||
bind:value={search}
|
||||
placeholder={$t('modelSelector.search')}
|
||||
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') open = false;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{/snippet}
|
||||
{#snippet empty()}
|
||||
<div class="px-3 py-1.5 text-[11px] text-gray-400 dark:text-gray-500 text-center">{$t('modelSelector.noMatches')}</div>
|
||||
{/snippet}
|
||||
</DropdownMenu>
|
||||
{/if}
|
||||
</span>
|
||||
@@ -75,29 +75,32 @@
|
||||
},
|
||||
30 * 60 * 1000
|
||||
);
|
||||
// iOS: Termius-style keyboard handling. visualViewport.height
|
||||
// gives us the area above the keyboard. Set max-height on the
|
||||
// main content column so the terminal shrinks to fit.
|
||||
// The layout container's overflow:hidden clips the gap.
|
||||
// iOS Safari keeps 100vh/100dvh at the layout viewport height when
|
||||
// the keyboard opens. visualViewport tells us how much of the bottom
|
||||
// of that layout viewport is covered, so reserve that space inside the
|
||||
// main column instead of moving or clipping the whole shell.
|
||||
const vv = window.visualViewport;
|
||||
if (vv) {
|
||||
const syncHeight = () => {
|
||||
const col = document.getElementById('main-col');
|
||||
if (!col) return;
|
||||
const kbHeight = window.innerHeight - vv.height;
|
||||
console.log('[viewport]', { innerHeight: window.innerHeight, vvHeight: vv.height, kbHeight });
|
||||
col.style.maxHeight = kbHeight > 100 ? `${vv.height}px` : '';
|
||||
};
|
||||
// iOS may fire 'scroll' instead of 'resize' when keyboard opens
|
||||
vv.addEventListener('resize', syncHeight);
|
||||
vv.addEventListener('scroll', syncHeight);
|
||||
return () => {
|
||||
clearInterval(healthCheck);
|
||||
vv.removeEventListener('resize', syncHeight);
|
||||
vv.removeEventListener('scroll', syncHeight);
|
||||
};
|
||||
}
|
||||
return () => clearInterval(healthCheck);
|
||||
const syncKeyboardInset = () => {
|
||||
const visualBottom = vv ? vv.offsetTop + vv.height : window.innerHeight;
|
||||
const keyboardInset = Math.max(0, window.innerHeight - visualBottom);
|
||||
document.documentElement.style.setProperty(
|
||||
'--keyboard-inset-bottom',
|
||||
keyboardInset > 100 ? `${keyboardInset}px` : '0px'
|
||||
);
|
||||
};
|
||||
|
||||
syncKeyboardInset();
|
||||
window.addEventListener('resize', syncKeyboardInset);
|
||||
// iOS may fire 'scroll' instead of 'resize' when keyboard opens.
|
||||
vv?.addEventListener('resize', syncKeyboardInset);
|
||||
vv?.addEventListener('scroll', syncKeyboardInset);
|
||||
return () => {
|
||||
clearInterval(healthCheck);
|
||||
document.documentElement.style.removeProperty('--keyboard-inset-bottom');
|
||||
window.removeEventListener('resize', syncKeyboardInset);
|
||||
vv?.removeEventListener('resize', syncKeyboardInset);
|
||||
vv?.removeEventListener('scroll', syncKeyboardInset);
|
||||
};
|
||||
});
|
||||
|
||||
let startupToken = $state('');
|
||||
@@ -325,7 +328,11 @@
|
||||
>
|
||||
<Sidebar />
|
||||
|
||||
<div id="main-col" class="flex flex-col flex-1 min-w-0 min-h-0 overflow-hidden">
|
||||
<div
|
||||
id="main-col"
|
||||
class="flex flex-col flex-1 min-w-0 min-h-0 overflow-hidden"
|
||||
style="padding-bottom: var(--keyboard-inset-bottom, 0px);"
|
||||
>
|
||||
{#if !$currentWorkspace && $page.url.pathname === '/'}
|
||||
<Bar />
|
||||
{/if}
|
||||
|
||||
+45
-9
@@ -232,12 +232,17 @@ async def unstage(root: str, files: list[str]) -> None:
|
||||
|
||||
|
||||
async def discard(root: str, files: list[str]) -> None:
|
||||
"""Discard changes in files. Tracked files are restored via git checkout;
|
||||
untracked files are deleted from disk."""
|
||||
"""Fully discard all changes for files — both staged and unstaged.
|
||||
|
||||
Tracked modified/deleted files are unstaged then restored via checkout.
|
||||
Newly added (staged) files are unstaged then deleted from disk.
|
||||
Untracked files are deleted from disk.
|
||||
"""
|
||||
if not files:
|
||||
return
|
||||
|
||||
# Determine which files are untracked
|
||||
requested = set(files)
|
||||
|
||||
_, st_out, _ = await _run(
|
||||
"status",
|
||||
"--porcelain=v2",
|
||||
@@ -245,17 +250,48 @@ async def discard(root: str, files: list[str]) -> None:
|
||||
cwd=root,
|
||||
check=False,
|
||||
)
|
||||
untracked = set()
|
||||
|
||||
to_unstage: list[str] = [] # staged changes that need unstaging first
|
||||
to_checkout: list[str] = [] # working-tree changes to restore from HEAD
|
||||
to_delete: list[str] = [] # untracked / newly-added files to remove
|
||||
|
||||
for line in st_out.splitlines():
|
||||
if line.startswith("? "):
|
||||
untracked.add(line[2:])
|
||||
path = line[2:]
|
||||
if path in requested:
|
||||
to_delete.append(path)
|
||||
elif line.startswith("1 ") or line.startswith("2 "):
|
||||
parts = line.split(" ", 8)
|
||||
xy = parts[1]
|
||||
path = parts[-1]
|
||||
if line.startswith("2 "):
|
||||
path = path.split("\t")[0]
|
||||
if path not in requested:
|
||||
continue
|
||||
staged_code = xy[0]
|
||||
unstaged_code = xy[1]
|
||||
if staged_code == "A":
|
||||
# Newly added file: unstage → becomes untracked → delete
|
||||
to_unstage.append(path)
|
||||
to_delete.append(path)
|
||||
elif staged_code != ".":
|
||||
# Staged modification/deletion: unstage then checkout
|
||||
to_unstage.append(path)
|
||||
to_checkout.append(path)
|
||||
if unstaged_code != "." and staged_code != "A":
|
||||
# Working-tree change: checkout (deduplicated)
|
||||
if path not in to_checkout:
|
||||
to_checkout.append(path)
|
||||
|
||||
tracked = [f for f in files if f not in untracked]
|
||||
to_delete = [f for f in files if f in untracked]
|
||||
# 1. Unstage any staged changes (reverts index to HEAD)
|
||||
if to_unstage:
|
||||
await _run("restore", "--staged", "--", *to_unstage, cwd=root)
|
||||
|
||||
if tracked:
|
||||
await _run("checkout", "--", *tracked, cwd=root)
|
||||
# 2. Restore working-tree files from HEAD
|
||||
if to_checkout:
|
||||
await _run("checkout", "--", *to_checkout, cwd=root)
|
||||
|
||||
# 3. Remove untracked / newly-added files
|
||||
for f in to_delete:
|
||||
full = os.path.join(root, f)
|
||||
if os.path.isfile(full):
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "cptr"
|
||||
version = "0.4.8"
|
||||
version = "0.4.9"
|
||||
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