## Summary Complete sidebar redesign and comprehensive UI polish pass with performance optimizations, theme system refinements, and desktop integration improvements. ## Key Changes **Sidebar & Navigation Redesign** - Redesigned sessions sidebar layout with unified button primitives - Added activity sections with project grouping and improved session organization - Refined sidebar corners, spacing, and visual hierarchy - Removed NavRail component in favor of streamlined sidebar - Stabilized sessions bar toggle position in fullscreen mode **Performance Optimizations** - Reduced chat streaming CPU usage and storage churn - Optimized task tool polling and live timers with debouncing - Prevented chat state races and reduced background request load - Debounced draft writes and coalesced session reloads - Optimized message store updates and turn tracking **Theme & Visual System** - Added theme-aware window corners (desktop) and border radius tokens - Introduced glassmorphism effects on desktop sidebar - Added backdrop blur to UI elements **Chat Experience** - Added session-based permission auto-accept toggle in chat input - Polished permission shield UX with improved icon sizing and spacing - Fixed chat scroll-to-bottom behavior and timeline tracking - Enhanced tool output display with better path label detection - Removed duplicate draft context details in chat header - Added text selection menu to chat messages **Git Improvements** - Refreshed git history visual design with cleaner dividers - Added remote removal action in sync selector - Stabilized git polling to prevent excessive requests - Improved tool output rendering for git operations **Settings & Panels** - Fixed mobile scrolling on settings pages - Made outside-click settings close instantly - Reduced settings load churn and CPU spikes - Improved services dropdown layout and spacing - Softened panel resize handles **Desktop Integration** - Synced macOS window theme with app theme - Restored window dragging in sidebar header zones - Fixed system window corners on macOS - Improved header session metadata and action controls **Button & Component Standardization** - Unified button primitives across all components - Standardized destructive action patterns - Removed unused button variants (button-large, button-small) - Aligned context tab close hit areas --------- Co-authored-by: Iuliia Ivashko <yulia.ivashko@gmail.com>
88 lines
2.5 KiB
TypeScript
88 lines
2.5 KiB
TypeScript
import type { Session } from "@opencode-ai/sdk/v2/client";
|
|
|
|
export type PermissionAutoAcceptMap = Record<string, boolean>;
|
|
|
|
const DIRECTORY_WILDCARD = "*";
|
|
|
|
const encodeBase64 = (value: string): string => {
|
|
try {
|
|
const bytes = new TextEncoder().encode(value);
|
|
let binary = "";
|
|
for (const byte of bytes) {
|
|
binary += String.fromCharCode(byte);
|
|
}
|
|
return btoa(binary);
|
|
} catch {
|
|
return btoa(value);
|
|
}
|
|
};
|
|
|
|
export const normalizeDirectory = (value: string | null | undefined): string | null => {
|
|
if (typeof value !== "string") {
|
|
return null;
|
|
}
|
|
const trimmed = value.trim();
|
|
if (!trimmed) {
|
|
return null;
|
|
}
|
|
const normalized = trimmed.replace(/\\/g, "/");
|
|
if (normalized === "/") {
|
|
return "/";
|
|
}
|
|
return normalized.length > 1 ? normalized.replace(/\/+$/g, "") : normalized;
|
|
};
|
|
|
|
export const directoryAcceptKey = (directory: string): string => `${encodeBase64(directory)}/${DIRECTORY_WILDCARD}`;
|
|
|
|
export const sessionAcceptKey = (sessionID: string, directory: string): string => `${encodeBase64(directory)}/${sessionID}`;
|
|
|
|
const resolveLineage = (sessionID: string, sessions: Session[]): string[] => {
|
|
const map = new Map<string, Session>();
|
|
for (const session of sessions) {
|
|
map.set(session.id, session);
|
|
}
|
|
|
|
const result: string[] = [];
|
|
const seen = new Set<string>();
|
|
let current: string | undefined = sessionID;
|
|
while (current && !seen.has(current)) {
|
|
seen.add(current);
|
|
result.push(current);
|
|
current = map.get(current)?.parentID;
|
|
}
|
|
return result;
|
|
};
|
|
|
|
export const autoRespondsPermission = (input: {
|
|
autoAccept: PermissionAutoAcceptMap;
|
|
sessions: Session[];
|
|
sessionID: string;
|
|
directory: string;
|
|
}): boolean => {
|
|
const { autoAccept, sessions, sessionID, directory } = input;
|
|
|
|
for (const id of resolveLineage(sessionID, sessions)) {
|
|
const key = sessionAcceptKey(id, directory);
|
|
if (key in autoAccept) {
|
|
return autoAccept[key] === true;
|
|
}
|
|
|
|
// Legacy fallback for pre-directory keys.
|
|
if (id in autoAccept) {
|
|
return autoAccept[id] === true;
|
|
}
|
|
}
|
|
|
|
const directoryKey = directoryAcceptKey(directory);
|
|
if (directoryKey in autoAccept) {
|
|
return autoAccept[directoryKey] === true;
|
|
}
|
|
|
|
return false;
|
|
};
|
|
|
|
export const isDirectoryAutoAccepting = (autoAccept: PermissionAutoAcceptMap, directory: string): boolean => {
|
|
const key = directoryAcceptKey(directory);
|
|
return autoAccept[key] === true;
|
|
};
|