From 6597ed17b26048281e2aebf6d2272a02e4e9edb9 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 9 Jul 2026 15:40:39 -0500 Subject: [PATCH 01/12] refac --- .../src/lib/components/FileEditor.svelte | 25 +- .../frontend/src/lib/components/GitBar.svelte | 76 +++--- .../src/lib/components/GitView.svelte | 62 ++--- .../src/lib/components/SyntaxDiffLine.svelte | 228 ++++++++++++++++++ cptr/frontend/src/lib/utils/diff.ts | 172 +++++++++++++ 5 files changed, 466 insertions(+), 97 deletions(-) create mode 100644 cptr/frontend/src/lib/components/SyntaxDiffLine.svelte create mode 100644 cptr/frontend/src/lib/utils/diff.ts diff --git a/cptr/frontend/src/lib/components/FileEditor.svelte b/cptr/frontend/src/lib/components/FileEditor.svelte index 505ff57..af82583 100644 --- a/cptr/frontend/src/lib/components/FileEditor.svelte +++ b/cptr/frontend/src/lib/components/FileEditor.svelte @@ -20,6 +20,8 @@ import SvgPreview from './preview/SvgPreview.svelte'; import OfficePreview from './preview/OfficePreview.svelte'; import Spinner from './common/Spinner.svelte'; + import { groupDiffLines, languageForPath, withInlineDiffSegments } from '$lib/utils/diff'; + import SyntaxDiffLine from './SyntaxDiffLine.svelte'; import { EditorState, StateEffect, @@ -158,7 +160,6 @@ type DiffHunk = { header: string; lines: DiffLine[] }; type DiffFileEntry = { path: string; hunks: DiffHunk[] }; type NumberedLine = DiffLine & { oldNumber: number | null; newNumber: number | null }; - type LineGroup = { type: DiffLine['type']; lines: NumberedLine[] }; type GitLineChange = { line: number; type: 'added' | 'modified' }; let diffMode = $state(false); let diffFiles = $state([]); @@ -265,16 +266,6 @@ }); } - function diffGroupLines(lines: NumberedLine[]): LineGroup[] { - const groups: LineGroup[] = []; - for (const line of lines) { - const last = groups[groups.length - 1]; - if (last && last.type === line.type) last.lines.push(line); - else groups.push({ type: line.type, lines: [line] }); - } - return groups; - } - function splitLines(text: string): string[] { return text.length === 0 ? [] : text.split('\n'); } @@ -1235,7 +1226,7 @@ {hunk.header} - {#each diffGroupLines(diffNumberedLines(hunk)) as group} + {#each groupDiffLines(withInlineDiffSegments(diffNumberedLines(hunk))) as group}
{#each group.lines as line}
{diffPrefix(line.type)} - {line.content || ' '} +
{/each}
diff --git a/cptr/frontend/src/lib/components/GitBar.svelte b/cptr/frontend/src/lib/components/GitBar.svelte index b3b3607..b9cd9e8 100644 --- a/cptr/frontend/src/lib/components/GitBar.svelte +++ b/cptr/frontend/src/lib/components/GitBar.svelte @@ -32,6 +32,15 @@ import { tooltip } from '$lib/tooltip'; import { t } from '$lib/i18n'; import Spinner from '$lib/components/common/Spinner.svelte'; + import { + groupDiffLines, + languageForPath, + numberDiffLines, + withInlineDiffSegments, + type DiffFile, + type DiffLine + } from '$lib/utils/diff'; + import SyntaxDiffLine from './SyntaxDiffLine.svelte'; type GitFile = { path: string; @@ -41,8 +50,6 @@ 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; @@ -710,22 +717,7 @@ } } - type LineGroup = { type: string; lines: { type: string; content: string }[] }; - - function groupLines(lines: { type: string; content: string }[]): LineGroup[] { - const groups: LineGroup[] = []; - for (const line of lines) { - const last = groups[groups.length - 1]; - if (last && last.type === line.type) { - last.lines.push(line); - } else { - groups.push({ type: line.type, lines: [line] }); - } - } - return groups; - } - - function blockClass(type: string): string { + function blockClass(type: DiffLine['type']): string { switch (type) { case 'added': return 'bg-green-100 border-l-[0.1875rem] border-l-green-500 dark:bg-green-500/15 dark:border-l-green-400'; @@ -736,6 +728,24 @@ } } + function textClass(type: DiffLine['type']): string { + if (type === 'added') return 'text-green-900 dark:text-green-300'; + if (type === 'removed') return 'text-red-900 dark:text-red-300'; + return 'text-gray-600 dark:text-gray-400'; + } + + function prefixClass(type: DiffLine['type']): string { + if (type === 'added') return 'text-green-600 dark:text-green-400'; + if (type === 'removed') return 'text-red-500 dark:text-red-400'; + return 'text-gray-400 dark:text-gray-600'; + } + + function linePrefix(type: DiffLine['type']): string { + if (type === 'added') return '+'; + if (type === 'removed') return '-'; + return ' '; + } + $effect(() => { if (!expanded) return; function onKeydown(e: KeyboardEvent) { @@ -1412,28 +1422,20 @@ > {hunk.header} - {#each groupLines(hunk.lines) as group} + {#each groupDiffLines(withInlineDiffSegments(numberDiffLines(hunk))) as group}
{#each group.lines as line} -
- {line.type === 'added' - ? '+' - : line.type === 'removed' - ? '-' - : ' '}{line.content} + {linePrefix(line.type)} +
{/each}
diff --git a/cptr/frontend/src/lib/components/GitView.svelte b/cptr/frontend/src/lib/components/GitView.svelte index 78246c3..41ce9bc 100644 --- a/cptr/frontend/src/lib/components/GitView.svelte +++ b/cptr/frontend/src/lib/components/GitView.svelte @@ -5,12 +5,18 @@ import { tooltip } from '$lib/tooltip'; import { t } from '$lib/i18n'; + import { + groupDiffLines, + languageForPath, + numberDiffLines, + withInlineDiffSegments, + type DiffFile, + type DiffLine + } from '$lib/utils/diff'; import Icon from './Icon.svelte'; import Spinner from '$lib/components/common/Spinner.svelte'; + import SyntaxDiffLine from './SyntaxDiffLine.svelte'; - type DiffLine = { type: 'added' | 'removed' | 'context'; content: string }; - type DiffHunk = { header: string; lines: DiffLine[] }; - type DiffFile = { path: string; hunks: DiffHunk[] }; type ReviewFile = { key: string; path: string; @@ -21,7 +27,6 @@ deletions: number; expanded: boolean; }; - type NumberedLine = DiffLine & { oldNumber: number | null; newNumber: number | null }; let gitStatus = $derived(gitStatusStore.status); let reviewFiles = $state([]); @@ -178,28 +183,6 @@ } } - function hunkStart(header: string): { oldStart: number; newStart: number } { - const match = header.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/); - return { - oldStart: match ? Number(match[1]) : 0, - newStart: match ? Number(match[2]) : 0 - }; - } - - function numberedLines(hunk: DiffHunk): NumberedLine[] { - let { oldStart, newStart } = hunkStart(hunk.header); - - return hunk.lines.map((line) => { - if (line.type === 'added') { - return { ...line, oldNumber: null, newNumber: newStart++ }; - } - if (line.type === 'removed') { - return { ...line, oldNumber: oldStart++, newNumber: null }; - } - return { ...line, oldNumber: oldStart++, newNumber: newStart++ }; - }); - } - function blockClass(type: DiffLine['type']): string { switch (type) { case 'added': @@ -238,21 +221,6 @@ if (type === 'removed') return '-'; return ' '; } - - type LineGroup = { type: DiffLine['type']; lines: NumberedLine[] }; - - function groupLines(lines: NumberedLine[]): LineGroup[] { - const groups: LineGroup[] = []; - for (const line of lines) { - const last = groups[groups.length - 1]; - if (last && last.type === line.type) { - last.lines.push(line); - } else { - groups.push({ type: line.type, lines: [line] }); - } - } - return groups; - }
{hunk.header}
- {#each groupLines(numberedLines(hunk)) as group} + {#each groupDiffLines(withInlineDiffSegments(numberDiffLines(hunk))) as group}
{#each group.lines as line}
@@ -453,9 +421,13 @@ class="select-none px-1 text-center {prefixClass(line.type)}" >{linePrefix(line.type)} - {line.content || ' '} +
{/each}
diff --git a/cptr/frontend/src/lib/components/SyntaxDiffLine.svelte b/cptr/frontend/src/lib/components/SyntaxDiffLine.svelte new file mode 100644 index 0000000..139fe16 --- /dev/null +++ b/cptr/frontend/src/lib/components/SyntaxDiffLine.svelte @@ -0,0 +1,228 @@ + + + + +{@html html} + + diff --git a/cptr/frontend/src/lib/utils/diff.ts b/cptr/frontend/src/lib/utils/diff.ts new file mode 100644 index 0000000..66c653c --- /dev/null +++ b/cptr/frontend/src/lib/utils/diff.ts @@ -0,0 +1,172 @@ +export type DiffLineType = 'added' | 'removed' | 'context'; +export type DiffLine = { type: DiffLineType; content: string }; +export type DiffHunk = { header: string; lines: DiffLine[] }; +export type DiffFile = { path: string; hunks: DiffHunk[] }; +export type NumberedDiffLine = DiffLine & { oldNumber: number | null; newNumber: number | null }; +export type InlineDiffSegment = { text: string; changed: boolean }; +export type InlineDiffLine = NumberedDiffLine & { segments: InlineDiffSegment[] }; +export type DiffLineGroup = { type: T['type']; lines: T[] }; + +export function languageForPath(path: string): string { + const ext = path.slice(path.lastIndexOf('.')).toLowerCase(); + const byExt: Record = { + '.py': 'python', + '.js': 'javascript', + '.ts': 'typescript', + '.jsx': 'jsx', + '.tsx': 'tsx', + '.svelte': 'svelte', + '.css': 'css', + '.scss': 'scss', + '.html': 'html', + '.json': 'json', + '.xml': 'xml', + '.yaml': 'yaml', + '.yml': 'yaml', + '.toml': 'toml', + '.md': 'markdown', + '.sh': 'bash', + '.bash': 'bash', + '.zsh': 'bash', + '.rs': 'rust', + '.go': 'go', + '.java': 'java', + '.c': 'c', + '.h': 'c', + '.cpp': 'cpp', + '.hpp': 'cpp', + '.rb': 'ruby', + '.php': 'php', + '.swift': 'swift', + '.kt': 'kotlin', + '.sql': 'sql', + '.lua': 'lua', + '.dockerfile': 'dockerfile', + '.makefile': 'makefile' + }; + return byExt[ext] ?? 'text'; +} + +export function numberDiffLines(hunk: DiffHunk): NumberedDiffLine[] { + const match = hunk.header.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/); + let oldNumber = match ? Number(match[1]) : 0; + let newNumber = match ? Number(match[2]) : 0; + + return hunk.lines.map((line) => { + if (line.type === 'added') return { ...line, oldNumber: null, newNumber: newNumber++ }; + if (line.type === 'removed') return { ...line, oldNumber: oldNumber++, newNumber: null }; + return { ...line, oldNumber: oldNumber++, newNumber: newNumber++ }; + }); +} + +export function groupDiffLines(lines: T[]): DiffLineGroup[] { + const groups: DiffLineGroup[] = []; + for (const line of lines) { + const last = groups[groups.length - 1]; + if (last && last.type === line.type) last.lines.push(line); + else groups.push({ type: line.type, lines: [line] }); + } + return groups; +} + +export function withInlineDiffSegments(lines: NumberedDiffLine[]): InlineDiffLine[] { + const result: InlineDiffLine[] = []; + let i = 0; + + while (i < lines.length) { + const line = lines[i]; + if (line.type === 'context') { + result.push({ ...line, segments: [{ text: line.content || ' ', changed: false }] }); + i += 1; + continue; + } + + const block: NumberedDiffLine[] = []; + while (i < lines.length && lines[i].type !== 'context') { + block.push(lines[i]); + i += 1; + } + + const removed = block.filter((item) => item.type === 'removed'); + const added = block.filter((item) => item.type === 'added'); + const removedSegments = removed.map((item, index) => + segmentsForPair(item.content, added[index]?.content, 'removed') + ); + const addedSegments = added.map((item, index) => + segmentsForPair(removed[index]?.content, item.content, 'added') + ); + + for (const item of block) { + const index = + item.type === 'removed' + ? removed.indexOf(item) + : item.type === 'added' + ? added.indexOf(item) + : -1; + const segments = + item.type === 'removed' + ? removedSegments[index] + : item.type === 'added' + ? addedSegments[index] + : [{ text: item.content || ' ', changed: false }]; + result.push({ ...item, segments }); + } + } + + return result; +} + +function segmentsForPair( + oldText: string | undefined, + newText: string | undefined, + side: 'removed' | 'added' +): InlineDiffSegment[] { + const text = side === 'removed' ? oldText : newText; + if (text === undefined) return []; + if (oldText === undefined || newText === undefined) + return [{ text: text || ' ', changed: false }]; + if (oldText === newText) return [{ text: text || ' ', changed: false }]; + + let prefix = 0; + const maxPrefix = Math.min(oldText.length, newText.length); + while (prefix < maxPrefix && oldText[prefix] === newText[prefix]) prefix += 1; + + let oldSuffix = oldText.length; + let newSuffix = newText.length; + while ( + oldSuffix > prefix && + newSuffix > prefix && + oldText[oldSuffix - 1] === newText[newSuffix - 1] + ) { + oldSuffix -= 1; + newSuffix -= 1; + } + + const oldChangedLength = oldSuffix - prefix; + const newChangedLength = newSuffix - prefix; + const sharedLength = Math.max( + oldText.length - oldChangedLength, + newText.length - newChangedLength + ); + const similarity = sharedLength / Math.max(oldText.length, newText.length, 1); + const changedLength = side === 'removed' ? oldChangedLength : newChangedLength; + if (similarity < 0.55 || changedLength / Math.max(text.length, 1) > 0.45) { + return [{ text: text || ' ', changed: false }]; + } + + const end = side === 'removed' ? oldSuffix : newSuffix; + const changed = text.slice(prefix, end); + const tokenStart = changed.search(/[A-Za-z0-9_$]/); + if (tokenStart < 0) return [{ text: text || ' ', changed: false }]; + + const tokenEnd = changed.search(/[A-Za-z0-9_$][^A-Za-z0-9_$]*$/); + const highlightStart = tokenStart >= 0 ? prefix + tokenStart : prefix; + const highlightEnd = tokenEnd >= 0 ? prefix + tokenEnd + 1 : end; + const segments = [ + { text: text.slice(0, highlightStart), changed: false }, + { text: text.slice(highlightStart, highlightEnd), changed: true }, + { text: text.slice(highlightEnd), changed: false } + ].filter((segment) => segment.text.length > 0); + + return segments.length ? segments : [{ text: ' ', changed: false }]; +} From e711553f139eb28e3f781731f34f33c8550d1ee3 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 9 Jul 2026 15:53:47 -0500 Subject: [PATCH 02/12] refac --- .../src/lib/components/FileBrowser.svelte | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/cptr/frontend/src/lib/components/FileBrowser.svelte b/cptr/frontend/src/lib/components/FileBrowser.svelte index 8b6a69a..2b2aaf5 100644 --- a/cptr/frontend/src/lib/components/FileBrowser.svelte +++ b/cptr/frontend/src/lib/components/FileBrowser.svelte @@ -74,6 +74,7 @@ let contextMenu = $state<{ x: number; y: number; entry: TreeEntry; anchor?: HTMLElement } | null>( null ); + let directoryMenu = $state<{ x: number; y: number } | null>(null); let renamingEntry = $state(null); let renameValue = $state(''); @@ -864,18 +865,37 @@ // ── Context menu ─────────────────────────────────────────── function onContextMenu(e: MouseEvent, entry: TreeEntry) { e.preventDefault(); + e.stopPropagation(); + directoryMenu = null; contextMenu = { x: e.clientX, y: e.clientY, entry }; } function openEntryMenu(e: MouseEvent | KeyboardEvent, entry: TreeEntry) { e.stopPropagation(); + directoryMenu = null; contextMenu = { x: 0, y: 0, entry, anchor: e.currentTarget as HTMLElement }; } + function onDirectoryContextMenu(e: MouseEvent) { + if ((e.target as HTMLElement | null)?.closest('input, textarea, [contenteditable="true"]')) { + return; + } + + e.preventDefault(); + contextMenu = null; + addMenuOpen = false; + sortMenuOpen = false; + directoryMenu = { x: e.clientX, y: e.clientY }; + } + function closeMenu() { contextMenu = null; } + function closeDirectoryMenu() { + directoryMenu = null; + } + function startRename(entry: TreeEntry) { renamingEntry = entry.path; renameValue = entry.name; @@ -1044,7 +1064,7 @@ -
+
{#if showNewInput}
@@ -1325,6 +1345,30 @@ /> {/if} +{#if directoryMenu} + fetchDirectory(cwd) + }, + { label: '', divider: true, onclick: () => {} }, + { label: $t('files.newFile'), icon: 'plus', onclick: () => startNew('file') }, + { label: $t('files.newFolder'), icon: 'folder', onclick: () => startNew('folder') }, + { label: $t('files.uploadFile'), icon: 'upload', onclick: () => handleUploadFromMenu() }, + { label: '', divider: true, onclick: () => {} }, + { + label: showHidden ? $t('files.hideHidden') : $t('files.showHidden'), + icon: 'eye', + onclick: () => toggleHidden() + } + ]} + onclose={closeDirectoryMenu} + /> +{/if} + {#if contextMenu} Date: Thu, 9 Jul 2026 16:00:06 -0500 Subject: [PATCH 03/12] refac --- cptr/utils/context.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cptr/utils/context.py b/cptr/utils/context.py index 4f8fcf0..1a4e12c 100644 --- a/cptr/utils/context.py +++ b/cptr/utils/context.py @@ -93,14 +93,13 @@ def resolve_compact_token_threshold( model: str | None = None, *, chat_models_config: dict | None = None, - global_cap: int | None = None, + global_threshold: int | None = None, ) -> int: """Return the effective compaction threshold for a model. - The existing global threshold is the cap. Model-level values can lower it - for smaller context windows, but never raise it. + Model-level values override the global default. """ - cap = global_cap or _get_threshold() + default_threshold = global_threshold or _get_threshold() model_threshold = None if chat_models_config: @@ -117,7 +116,7 @@ def resolve_compact_token_threshold( if model_threshold: break - return min(model_threshold, cap) if model_threshold else cap + return model_threshold or default_threshold async def load_compact_token_threshold(model: str | None = None) -> int: From 0a4166baa0cfdb8a0d3fcc3b3801781c5bb087c6 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 9 Jul 2026 16:04:19 -0500 Subject: [PATCH 04/12] refac --- cptr/utils/chat_task.py | 4 +++- cptr/utils/tools.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cptr/utils/chat_task.py b/cptr/utils/chat_task.py index 671b393..9672e9e 100644 --- a/cptr/utils/chat_task.py +++ b/cptr/utils/chat_task.py @@ -2166,7 +2166,9 @@ async def run_chat_task( for idx in other_indices: tc, item = call_items[idx] if tc["name"] == "create_artifact": - result = await create_artifact(**tc["arguments"], workspace=workspace) + args = dict(tc["arguments"]) + args.pop("workspace", None) + result = await create_artifact(**args, workspace=workspace) else: result = await execute_tool( tc["name"], diff --git a/cptr/utils/tools.py b/cptr/utils/tools.py index eba3411..9d4fb6f 100644 --- a/cptr/utils/tools.py +++ b/cptr/utils/tools.py @@ -2923,6 +2923,8 @@ async def execute_tool(name: str, args: dict, __context__: dict) -> str: if not is_builtin_tool_enabled(name, __context__.get("builtin_tools")): return f"Error: tool disabled: {name}" fn = info["fn"] + args = dict(args) + args.pop("workspace", None) try: sig = inspect.signature(fn) if "__context__" in sig.parameters: From 7304e0574ac0bd911b25527f53645bf40c09bc63 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 9 Jul 2026 16:08:41 -0500 Subject: [PATCH 05/12] refac --- cptr/utils/browser/cdp.py | 57 +++++++++++++++++++++++++++-------- cptr/utils/browser/session.py | 2 +- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/cptr/utils/browser/cdp.py b/cptr/utils/browser/cdp.py index 2c49056..ce2f16e 100644 --- a/cptr/utils/browser/cdp.py +++ b/cptr/utils/browser/cdp.py @@ -14,6 +14,7 @@ import logging from typing import Any import websockets +from websockets.exceptions import ConnectionClosed logger = logging.getLogger(__name__) @@ -65,7 +66,11 @@ class CDPClient: ws_url = page_target["webSocketDebuggerUrl"] target_id = page_target["id"] - ws = await websockets.connect(ws_url, max_size=50 * 1024 * 1024) + ws = await websockets.connect( + ws_url, + max_size=50 * 1024 * 1024, + ping_interval=None, + ) client = cls(ws, target_id) @@ -87,17 +92,46 @@ class CDPClient: if params: payload["params"] = params - await self._ws.send(json.dumps(payload)) + try: + await self._ws.send(json.dumps(payload)) - # Wait for matching response (skip events) - while True: + # Wait for matching response (skip events) + while True: + data = await self._recv_json() + if data.get("id") == msg_id: + if "error" in data: + raise RuntimeError( + f"CDP error: {data['error'].get('message', data['error'])}" + ) + return data.get("result", {}) + # Ignore events (no "id" field) + except ConnectionClosed: + self._closed = True + raise + + async def _recv_json(self) -> dict: + try: raw = await asyncio.wait_for(self._ws.recv(), timeout=30) - data = json.loads(raw) - if data.get("id") == msg_id: - if "error" in data: - raise RuntimeError(f"CDP error: {data['error'].get('message', data['error'])}") - return data.get("result", {}) - # Ignore events (no "id" field) + except ConnectionClosed: + self._closed = True + raise + return json.loads(raw) + + def is_closed(self) -> bool: + """Return whether this client or its underlying socket is closed.""" + if self._closed: + return True + + if getattr(self._ws, "closed", False): + self._closed = True + return True + + state_name = getattr(getattr(self._ws, "state", None), "name", None) + if state_name in {"CLOSING", "CLOSED"}: + self._closed = True + return True + + return False # ── Navigation ───────────────────────────────────────── @@ -107,8 +141,7 @@ class CDPClient: # Wait for load event while True: - raw = await asyncio.wait_for(self._ws.recv(), timeout=30) - data = json.loads(raw) + data = await self._recv_json() if data.get("method") == "Page.loadEventFired": break diff --git a/cptr/utils/browser/session.py b/cptr/utils/browser/session.py index b30a4bc..1ef41b6 100644 --- a/cptr/utils/browser/session.py +++ b/cptr/utils/browser/session.py @@ -34,7 +34,7 @@ class BrowserSessionManager: """Get an existing session for this chat, or create a new one.""" if chat_id in self._sessions: client = self._sessions[chat_id] - if not client._closed: + if not client.is_closed(): self._last_used[chat_id] = time.monotonic() return client # Session was closed externally, remove it From 27d404ba598eebc565291a257627a7f34768fa4d Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 9 Jul 2026 16:31:38 -0500 Subject: [PATCH 06/12] refac --- .../src/lib/components/Sidebar.svelte | 593 +----------------- .../src/lib/components/SidebarFooter.svelte | 87 +++ .../src/lib/components/SidebarHeader.svelte | 32 + .../src/lib/components/SidebarNav.svelte | 48 ++ .../components/SidebarWorkspaceList.svelte | 426 +++++++++++++ 5 files changed, 604 insertions(+), 582 deletions(-) create mode 100644 cptr/frontend/src/lib/components/SidebarFooter.svelte create mode 100644 cptr/frontend/src/lib/components/SidebarHeader.svelte create mode 100644 cptr/frontend/src/lib/components/SidebarNav.svelte create mode 100644 cptr/frontend/src/lib/components/SidebarWorkspaceList.svelte diff --git a/cptr/frontend/src/lib/components/Sidebar.svelte b/cptr/frontend/src/lib/components/Sidebar.svelte index 8a39498..31b1a58 100644 --- a/cptr/frontend/src/lib/components/Sidebar.svelte +++ b/cptr/frontend/src/lib/components/Sidebar.svelte @@ -1,148 +1,18 @@ {#if $sidebarOpen} @@ -278,269 +77,17 @@ onpointerdown={startResize} ondblclick={() => sidebarWidth.set(220)} >
- -
- { - e.preventDefault(); - goto('/'); - if (typeof window !== 'undefined' && window.innerWidth < 768) sidebarOpen.set(false); - }}>Computer logoComputer - -
- - -
- -
- - - {#if $chatEnabled} - - {/if} - - -
- {$t('sidebar.workspaces')} - -
- - -
- {#each $workspaceList as ws (ws.path)} - {@const isExpanded = expandedWorkspaces.has(ws.path)} - {@const chats = wsChatsCache.get(ws.path)} - {@const isLoading = wsChatsLoading.has(ws.path)} -
-
- handleWorkspaceClick(e, ws.path)} - > - - {#if $chatEnabled} - { - e.stopPropagation(); - e.preventDefault(); - toggleWorkspaceExpand(ws.path); - }} - aria-label={isExpanded ? $t('sidebar.collapse') : $t('sidebar.addWorkspace')} - > - - - - - - {:else} - - {/if} - {ws.name} - - openWsMenu(e, ws.path)} - aria-label={$t('sidebar.workspaceOptions')} - > - - - {#if $chatEnabled} - handleNewChat(ws.path)} - aria-label={$t('bar.newChat')} - use:tooltip={$t('bar.newChat')} - > - - - {/if} -
- - - {#if $chatEnabled && isExpanded} -
- {#if isLoading && !chats} -
- - - -
- {:else if chats && chats.length > 0} - {#each chats as chat (chat.id)} - handleSidebarChatClick(chat.id, ws.path, chat.title)} - /> - {/each} - - {:else if chats} - - {/if} -
- {/if} -
- {/each} - - {#if $workspaceList.length === 0} -
-

{$t('sidebar.noWorkspaces')}

-
- {/if} -
- - -
- - {/if} - -
+ + + (showPicker = true)} /> + {/if} -{#if showMenu && menuButtonEl} - { - settingsTab = 'account'; - showMenu = false; - showSettings = true; - } - } - ] - : []), - ...($session ? [{ divider: true, label: '', onclick: () => {} }] : []), - { - label: $t('sidebar.settings'), - icon: 'settings', - shortcut: formatChord($keybindings.openSettings), - onclick: openSettings - }, - { - label: $t('system.infoTitle'), - icon: 'info', - onclick: openSystemInfo - }, - { divider: true, label: '', onclick: () => {} }, - { label: $t('sidebar.logOut'), icon: 'log-out', onclick: logout } - ]} - onclose={() => (showMenu = false)} - /> -{/if} - {#if showPicker} (showPicker = false)} /> {/if} -{#if wsMenuPath && wsMenuAnchor} - handleRemoveWorkspace(wsMenuPath!) - } - ]} - onclose={closeWsMenu} - /> -{/if} - {#if showSettings} diff --git a/cptr/frontend/src/lib/components/SidebarFooter.svelte b/cptr/frontend/src/lib/components/SidebarFooter.svelte new file mode 100644 index 0000000..cd06a6e --- /dev/null +++ b/cptr/frontend/src/lib/components/SidebarFooter.svelte @@ -0,0 +1,87 @@ + + +
+ + {/if} + +
+ +{#if showMenu && menuButtonEl} + openSettings('account') + } + ] + : []), + ...($session ? [{ divider: true, label: '', onclick: () => {} }] : []), + { + label: $t('sidebar.settings'), + icon: 'settings', + shortcut: formatChord($keybindings.openSettings), + onclick: () => openSettings() + }, + { + label: $t('system.infoTitle'), + icon: 'info', + onclick: openSystemInfo + }, + { divider: true, label: '', onclick: () => {} }, + { label: $t('sidebar.logOut'), icon: 'log-out', onclick: clearSession } + ]} + onclose={() => (showMenu = false)} + /> +{/if} diff --git a/cptr/frontend/src/lib/components/SidebarHeader.svelte b/cptr/frontend/src/lib/components/SidebarHeader.svelte new file mode 100644 index 0000000..465ac53 --- /dev/null +++ b/cptr/frontend/src/lib/components/SidebarHeader.svelte @@ -0,0 +1,32 @@ + + +
+ Computer logoComputer + +
diff --git a/cptr/frontend/src/lib/components/SidebarNav.svelte b/cptr/frontend/src/lib/components/SidebarNav.svelte new file mode 100644 index 0000000..e8d1145 --- /dev/null +++ b/cptr/frontend/src/lib/components/SidebarNav.svelte @@ -0,0 +1,48 @@ + + +
+ +
+ +{#if $chatEnabled} + +{/if} diff --git a/cptr/frontend/src/lib/components/SidebarWorkspaceList.svelte b/cptr/frontend/src/lib/components/SidebarWorkspaceList.svelte new file mode 100644 index 0000000..98d3a23 --- /dev/null +++ b/cptr/frontend/src/lib/components/SidebarWorkspaceList.svelte @@ -0,0 +1,426 @@ + + +
+ {$t('sidebar.workspaces')} + +
+ +
+ {#each $workspaceList as ws (ws.path)} + {@const isExpanded = expandedWorkspaces.has(ws.path)} + {@const chats = wsChatsCache.get(ws.path)} + {@const isLoading = wsChatsLoading.has(ws.path)} +
+
+ openWorkspace(e, ws.path)} + > + {#if $chatEnabled} + { + e.stopPropagation(); + e.preventDefault(); + toggleWorkspaceExpand(ws.path); + }} + aria-label={isExpanded ? $t('sidebar.collapse') : $t('sidebar.addWorkspace')} + > + + + + + + {:else} + + {/if} + {ws.name} + + openWsMenu(e, ws.path)} + aria-label={$t('sidebar.workspaceOptions')} + > + + + {#if $chatEnabled} + newChat(ws.path)} + aria-label={$t('bar.newChat')} + use:tooltip={$t('bar.newChat')} + > + + + {/if} +
+ + {#if $chatEnabled && isExpanded} +
+ {#if isLoading && !chats} +
+ + + +
+ {:else if chats && chats.length > 0} + {#each chats as chat (chat.id)} + openChat(chat.id, ws.path)} + onmenu={(e) => openChatMenu(e, chat.id, ws.path)} + /> + {/each} + + {/if} +
+ {/if} +
+ {/each} + + {#if $workspaceList.length === 0} +
+

{$t('sidebar.noWorkspaces')}

+
+ {/if} +
+ +{#if wsMenuPath && wsMenuAnchor} + handleRemoveWorkspace(wsMenuPath!) + } + ]} + onclose={closeWsMenu} + /> +{/if} + +{#if chatMenu} + +{/if} + + From c5d4bf76a5488ab290de49d4fa3c7bc9039b5d9b Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 9 Jul 2026 16:37:40 -0500 Subject: [PATCH 07/12] refac --- cptr/frontend/src/lib/apis/git.ts | 6 +- .../src/lib/components/DiffHunkRows.svelte | 186 ++++++++++++++++++ .../lib/components/DiffSettingsMenu.svelte | 94 +++++++++ .../src/lib/components/FileEditor.svelte | 146 +------------- .../frontend/src/lib/components/GitBar.svelte | 119 +++++------ .../src/lib/components/GitView.svelte | 118 +++-------- cptr/frontend/src/lib/components/Icon.svelte | 5 + .../src/lib/components/SyntaxDiffLine.svelte | 9 +- .../src/lib/stores/gitDiffSettings.ts | 29 +++ cptr/frontend/src/lib/utils/diff.ts | 30 +++ cptr/routers/git.py | 12 +- cptr/utils/git.py | 31 ++- 12 files changed, 461 insertions(+), 324 deletions(-) create mode 100644 cptr/frontend/src/lib/components/DiffHunkRows.svelte create mode 100644 cptr/frontend/src/lib/components/DiffSettingsMenu.svelte create mode 100644 cptr/frontend/src/lib/stores/gitDiffSettings.ts diff --git a/cptr/frontend/src/lib/apis/git.ts b/cptr/frontend/src/lib/apis/git.ts index 888ea7a..61d8329 100644 --- a/cptr/frontend/src/lib/apis/git.ts +++ b/cptr/frontend/src/lib/apis/git.ts @@ -39,8 +39,10 @@ export const getGitLog = (root: string, limit = 30) => export const getGitDiff = (params: string) => fetchJSON(`/api/git/diff?${params}`); -export const getGitShow = (root: string, ref: string) => - fetchJSON(`/api/git/show?root=${encodeURIComponent(root)}&ref=${encodeURIComponent(ref)}`); +export const getGitShow = (root: string, ref: string, ignoreWhitespace = false) => + fetchJSON( + `/api/git/show?root=${encodeURIComponent(root)}&ref=${encodeURIComponent(ref)}&ignore_whitespace=${ignoreWhitespace}` + ); export const getGitBranches = (root: string) => fetchJSON(`/api/git/branches?root=${encodeURIComponent(root)}`); diff --git a/cptr/frontend/src/lib/components/DiffHunkRows.svelte b/cptr/frontend/src/lib/components/DiffHunkRows.svelte new file mode 100644 index 0000000..57fa104 --- /dev/null +++ b/cptr/frontend/src/lib/components/DiffHunkRows.svelte @@ -0,0 +1,186 @@ + + +{#if $diffDisplayMode === 'split'} + {#each splitDiffRows(lines) as row} +
+ {#if showNumbers} + {row.oldLine?.oldNumber ?? ''} + {/if} +
+ {#if row.oldLine} + + {:else} + + {/if} +
+ {#if showNumbers} + {row.newLine?.newNumber ?? ''} + {/if} +
+ {#if row.newLine} + + {:else} + + {/if} +
+
+ {/each} +{:else} + {#each groupDiffLines(lines) as group} +
+ {#each group.lines as line} + {#if showNumbers} +
+ {line.oldNumber ?? ''} + {line.newNumber ?? ''} + {linePrefix(line.type)} + +
+ {:else} +
+ {linePrefix(line.type)} + +
+ {/if} + {/each} +
+ {/each} +{/if} + + diff --git a/cptr/frontend/src/lib/components/DiffSettingsMenu.svelte b/cptr/frontend/src/lib/components/DiffSettingsMenu.svelte new file mode 100644 index 0000000..c782686 --- /dev/null +++ b/cptr/frontend/src/lib/components/DiffSettingsMenu.svelte @@ -0,0 +1,94 @@ + + + +
+
+ Whitespace +
+ + + +
+ Diff Display +
+ + + +
+
diff --git a/cptr/frontend/src/lib/components/FileEditor.svelte b/cptr/frontend/src/lib/components/FileEditor.svelte index af82583..5dbb7b6 100644 --- a/cptr/frontend/src/lib/components/FileEditor.svelte +++ b/cptr/frontend/src/lib/components/FileEditor.svelte @@ -6,6 +6,7 @@ import { tooltip } from '$lib/tooltip'; import { readFile, writeFile } from '$lib/apis/files'; import { getGitDiff } from '$lib/apis/git'; + import { hideWhitespaceChanges } from '$lib/stores/gitDiffSettings'; import { gitStatusStore, type GitFile } from '$lib/stores/gitStatus.svelte'; import Icon from './Icon.svelte'; import SaveDialog from './SaveDialog.svelte'; @@ -20,8 +21,7 @@ import SvgPreview from './preview/SvgPreview.svelte'; import OfficePreview from './preview/OfficePreview.svelte'; import Spinner from './common/Spinner.svelte'; - import { groupDiffLines, languageForPath, withInlineDiffSegments } from '$lib/utils/diff'; - import SyntaxDiffLine from './SyntaxDiffLine.svelte'; + import DiffHunkRows from './DiffHunkRows.svelte'; import { EditorState, StateEffect, @@ -526,31 +526,6 @@ applyGitLineChanges(); } - function diffBlockClass(type: DiffLine['type']): string { - if (type === 'added') - return 'bg-green-100 border-l-[0.1875rem] border-l-green-500 dark:bg-green-500/15 dark:border-l-green-400'; - if (type === 'removed') return 'bg-red-100 diff-gutter-removed dark:bg-red-500/15'; - return ''; - } - - function diffTextClass(type: DiffLine['type']): string { - if (type === 'added') return 'text-green-900 dark:text-green-300'; - if (type === 'removed') return 'text-red-900 dark:text-red-300'; - return 'text-gray-600 dark:text-gray-400'; - } - - function diffPrefixClass(type: DiffLine['type']): string { - if (type === 'added') return 'text-green-600 dark:text-green-400'; - if (type === 'removed') return 'text-red-500 dark:text-red-400'; - return 'text-gray-400 dark:text-gray-600'; - } - - function diffPrefix(type: DiffLine['type']): string { - if (type === 'added') return '+'; - if (type === 'removed') return '-'; - return ' '; - } - // Editing state: true when the code editor should be active let isEditing = $derived( fileData && @@ -811,7 +786,8 @@ root: ws.path, file: relPath, staged: 'false', - untracked: String(fileStatus?.status === 'untracked') + untracked: String(fileStatus?.status === 'untracked'), + ignore_whitespace: String($hideWhitespaceChanges) }); const d = (await getGitDiff(params.toString())) as { files?: DiffFileEntry[] }; diffFiles = d.files ?? []; @@ -1226,34 +1202,7 @@ {hunk.header}
- {#each groupDiffLines(withInlineDiffSegments(diffNumberedLines(hunk))) as group} -
- {#each group.lines as line} -
- {line.oldNumber ?? ''} - {line.newNumber ?? ''} - {diffPrefix(line.type)} - -
- {/each} -
- {/each} + {/each} {/each}
@@ -1475,89 +1424,4 @@ font-size: 0.75rem; line-height: 1.125rem; } - - .diff-hunk-header { - padding: 0.125rem 0.5rem; - color: var(--color-gray-400); - background: var(--color-gray-50); - } - - :global(.dark) .diff-hunk-header { - background: rgba(255, 255, 255, 0.03); - color: var(--color-gray-600); - } - - .diff-line { - padding: 0 0.5rem; - white-space: pre-wrap; - word-break: break-all; - } - - .diff-prefix { - display: inline-block; - width: 1rem; - user-select: none; - } - - .diff-added { - background: #dcfce7; - color: #14532d; - } - - :global(.dark) .diff-added { - background: rgba(34, 197, 94, 0.12); - color: #86efac; - } - - .diff-added .diff-prefix { - color: #16a34a; - } - :global(.dark) .diff-added .diff-prefix { - color: #4ade80; - } - - .diff-removed { - background: #fee2e2; - color: #7f1d1d; - } - - :global(.dark) .diff-removed { - background: rgba(239, 68, 68, 0.12); - color: #fca5a5; - } - - .diff-removed .diff-prefix { - color: #ef4444; - } - :global(.dark) .diff-removed .diff-prefix { - color: #f87171; - } - - .diff-ctx { - color: var(--color-gray-600); - } - - :global(.dark) .diff-ctx { - color: var(--color-gray-400); - } - - .diff-ctx .diff-prefix { - color: var(--color-gray-400); - } - - :global(.dark) .diff-ctx .diff-prefix { - color: var(--color-gray-600); - } - - .diff-gutter-removed { - border-left: 0.1875rem solid transparent; - border-image: repeating-linear-gradient( - -45deg, - #ef4444 0, - #ef4444 1px, - transparent 1px, - transparent 0.1875rem - ) - 3; - } diff --git a/cptr/frontend/src/lib/components/GitBar.svelte b/cptr/frontend/src/lib/components/GitBar.svelte index b9cd9e8..af5227e 100644 --- a/cptr/frontend/src/lib/components/GitBar.svelte +++ b/cptr/frontend/src/lib/components/GitBar.svelte @@ -26,21 +26,16 @@ renameGitBranch } from '$lib/apis/git'; import { gitStatusStore } from '$lib/stores/gitStatus.svelte'; + import { diffDisplayMode, hideWhitespaceChanges } from '$lib/stores/gitDiffSettings'; 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'; - import { - groupDiffLines, - languageForPath, - numberDiffLines, - withInlineDiffSegments, - type DiffFile, - type DiffLine - } from '$lib/utils/diff'; - import SyntaxDiffLine from './SyntaxDiffLine.svelte'; + import DiffSettingsMenu from './DiffSettingsMenu.svelte'; + import type { DiffFile } from '$lib/utils/diff'; + import DiffHunkRows from './DiffHunkRows.svelte'; type GitFile = { path: string; @@ -84,8 +79,10 @@ let showDiff = $state(false); let showBranches = $state(false); let showWorktrees = $state(false); + let showDiffSettings = $state(false); let branchBtnEl = $state(); let worktreeBtnEl = $state(); + let diffSettingsBtnEl = $state(); let branchSearchInputEl = $state(); let worktreeSearchInputEl = $state(); let newBranchInputEl = $state(); @@ -187,6 +184,15 @@ } }); + let _prevHideWhitespace = false; + $effect(() => { + const hideWhitespace = $hideWhitespaceChanges; + if (hideWhitespace === _prevHideWhitespace) return; + _prevHideWhitespace = hideWhitespace; + if (!expanded || !showDiff) return; + reloadSelectedDiff(); + }); + // Auto-select first file $effect(() => { if ( @@ -213,7 +219,8 @@ const params = new URLSearchParams({ root: workspacePath, file: path, - staged: String(staged) + staged: String(staged), + ignore_whitespace: String($hideWhitespaceChanges) }); if (untracked) params.set('untracked', 'true'); const d = await getGitDiff(params.toString()); @@ -228,7 +235,7 @@ selectedFile = null; showDiff = true; try { - const d = await getGitShow(workspacePath, c.hash); + const d = await getGitShow(workspacePath, c.hash, $hideWhitespaceChanges); fileDiff = d.diff?.files ?? []; } catch { fileDiff = []; @@ -239,6 +246,16 @@ showDiff = false; } + function reloadSelectedDiff() { + if (selectedCommit) { + selectCommit(selectedCommit); + return; + } + if (!selectedFile) return; + const file = (gitStatus?.files ?? []).find((item) => item.path === selectedFile); + if (file) selectFile(file.path, file.staged, file.status === 'untracked'); + } + async function loadHistory() { try { commits = await getGitLog(workspacePath, 50); @@ -717,35 +734,6 @@ } } - function blockClass(type: DiffLine['type']): string { - switch (type) { - case 'added': - return 'bg-green-100 border-l-[0.1875rem] border-l-green-500 dark:bg-green-500/15 dark:border-l-green-400'; - case 'removed': - return 'bg-red-100 diff-gutter-removed dark:bg-red-500/15'; - default: - return ''; - } - } - - function textClass(type: DiffLine['type']): string { - if (type === 'added') return 'text-green-900 dark:text-green-300'; - if (type === 'removed') return 'text-red-900 dark:text-red-300'; - return 'text-gray-600 dark:text-gray-400'; - } - - function prefixClass(type: DiffLine['type']): string { - if (type === 'added') return 'text-green-600 dark:text-green-400'; - if (type === 'removed') return 'text-red-500 dark:text-red-400'; - return 'text-gray-400 dark:text-gray-600'; - } - - function linePrefix(type: DiffLine['type']): string { - if (type === 'added') return '+'; - if (type === 'removed') return '-'; - return ' '; - } - $effect(() => { if (!expanded) return; function onKeydown(e: KeyboardEvent) { @@ -1184,6 +1172,16 @@ {/if} + + + + {#if showDiffSettings && diffSettingsButtonEl} + (showDiffSettings = false)} /> + {/if} + {#if totalChanges > 0}
-
+
{#if file.diffFiles.some((diffFile) => diffFile.hunks.length > 0)} {#each file.diffFiles as diffFile} {#if file.diffFiles.length > 1} @@ -405,33 +381,7 @@ {hunk.header}
- {#each groupDiffLines(withInlineDiffSegments(numberDiffLines(hunk))) as group} -
- {#each group.lines as line} -
- {line.oldNumber ?? ''} - {line.newNumber ?? ''} - {linePrefix(line.type)} - -
- {/each} -
- {/each} + {/each} {/each} {:else} @@ -458,15 +408,7 @@ min-width: 100%; } - .diff-gutter-removed { - border-left: 0.1875rem solid transparent; - border-image: repeating-linear-gradient( - -45deg, - #ef4444 0, - #ef4444 1px, - transparent 1px, - transparent 0.1875rem - ) - 3; + .diff-content-split { + width: 100%; } diff --git a/cptr/frontend/src/lib/components/Icon.svelte b/cptr/frontend/src/lib/components/Icon.svelte index 72f45a3..3d6a4d2 100644 --- a/cptr/frontend/src/lib/components/Icon.svelte +++ b/cptr/frontend/src/lib/components/Icon.svelte @@ -143,6 +143,11 @@ + {:else if name === 'split-view'} + + {:else if name === 'chevron-right'} {:else if name === 'arrow-left'} diff --git a/cptr/frontend/src/lib/components/SyntaxDiffLine.svelte b/cptr/frontend/src/lib/components/SyntaxDiffLine.svelte index 139fe16..1ba4c90 100644 --- a/cptr/frontend/src/lib/components/SyntaxDiffLine.svelte +++ b/cptr/frontend/src/lib/components/SyntaxDiffLine.svelte @@ -68,6 +68,7 @@ content: string; segments: InlineDiffSegment[]; language: string; + wrap?: boolean; class?: string; } @@ -76,7 +77,7 @@ dark?: string; }; - let { type, content, segments, language, class: className = '' }: Props = $props(); + let { type, content, segments, language, wrap = false, class: className = '' }: Props = $props(); let renderedSegments = $state(null); $effect(() => { @@ -187,7 +188,11 @@ const html = $derived(htmlForSegments(type, fallbackSegments)); -{@html html} +{@html html} diff --git a/cptr/frontend/src/lib/components/GitBar.svelte b/cptr/frontend/src/lib/components/GitBar.svelte index 5411df3..94cf2a0 100644 --- a/cptr/frontend/src/lib/components/GitBar.svelte +++ b/cptr/frontend/src/lib/components/GitBar.svelte @@ -35,7 +35,7 @@ import Spinner from '$lib/components/common/Spinner.svelte'; import DiffSettingsMenu from './DiffSettingsMenu.svelte'; import { countDiffStats, type DiffFile } from '$lib/utils/diff'; - import DiffHunkRows from './DiffHunkRows.svelte'; + import DiffHunkList from './DiffHunkList.svelte'; type GitFile = { path: string; @@ -799,10 +799,9 @@ {#if totalChanges > 0}{$t('git.changedCount', { count: totalChanges })}+{totalAdditions}-{totalDeletions}+{totalAdditions} + -{totalDeletions}{/if} {#if actionMsg} {/if} - {#if fp.dir} + + {#if fp.dir} + {fp.dir} + {/if} + {fp.dir} { + e.stopPropagation(); + openFileTab(workspacePath.replace(/\/$/, '') + '/' + file.path); + }}>{fp.name} - {/if} - + { - e.stopPropagation(); - openFileTab(workspacePath.replace(/\/$/, '') + '/' + file.path); - }}>{fp.name} - +{file.additions ?? 0} -{file.deletions ?? 0} @@ -1428,14 +1429,7 @@ {df.path}
{/if} - {#each df.hunks as hunk} -
- {hunk.header} -
- - {/each} + {/each}
diff --git a/cptr/frontend/src/lib/components/GitView.svelte b/cptr/frontend/src/lib/components/GitView.svelte index 15ee85b..e3ff334 100644 --- a/cptr/frontend/src/lib/components/GitView.svelte +++ b/cptr/frontend/src/lib/components/GitView.svelte @@ -10,7 +10,7 @@ import Icon from './Icon.svelte'; import Spinner from '$lib/components/common/Spinner.svelte'; import DiffSettingsMenu from './DiffSettingsMenu.svelte'; - import DiffHunkRows from './DiffHunkRows.svelte'; + import DiffHunkList from './DiffHunkList.svelte'; type ReviewFile = { key: string; @@ -342,17 +342,7 @@ {diffFile.path} {/if} - {#each diffFile.hunks as hunk} -
- - - - {hunk.header} -
- - {/each} + {/each} {:else}
Date: Thu, 9 Jul 2026 17:19:46 -0500 Subject: [PATCH 12/12] refac --- CHANGELOG.md | 19 +++++++++++++++++++ pyproject.toml | 2 +- uv.lock | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a58d8c..bc9fd9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,25 @@ 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.6] - 2026-07-09 + +### Added + +- ✨ **Sharper diff reviews.** Review changes in split or unified view, hide whitespace-only edits, and spot changed words inside a line. +- 📊 **Git change counts.** Git panels and file lists now show added and removed lines at a glance. + +### Changed + +- 🗂️ **Cleaner file browsing.** Files use more recognizable icons, and folder background menus make common actions easier to reach. +- 🧭 **Sidebar chat cleanup.** Recent chats can now be deleted from the sidebar. +- 📅 **Clearer scheduled-task naming.** Automations are now labeled Scheduled in the app and README. + +### Fixed + +- 🌐 **More reliable browser control.** Browser sessions recover more gracefully when a page connection closes. +- 🧰 **More dependable tool use.** Tool calls and artifact creation are less likely to fail when workspace details are included. +- 🧠 **Per-model chat cleanup.** Long chats now use the cleanup setting for the selected model. + ## [0.8.5] - 2026-07-07 ### Added diff --git a/pyproject.toml b/pyproject.toml index b61d28c..e882fcc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "cptr" -version = "0.8.5" +version = "0.8.6" description = "Your computer, from anywhere. Code, manage, and control your machine from the web." license = {file = "LICENSE"} readme = "README.md" diff --git a/uv.lock b/uv.lock index ba606fc..6c2ced7 100644 --- a/uv.lock +++ b/uv.lock @@ -284,7 +284,7 @@ wheels = [ [[package]] name = "cptr" -version = "0.8.5" +version = "0.8.6" source = { editable = "." } dependencies = [ { name = "aiosqlite" },