Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function MainApp() {
debugOpen,
setDebugOpen,
debugEntries,
hasDebugAlerts,
showDebugButton,
addDebugEntry,
handleCopyDebug,
clearDebugEntries
Expand Down Expand Up @@ -619,7 +619,7 @@ function MainApp() {
handleApprovalDecision,
onOpenSettings: handleOpenSettings,
onOpenDebug: handleDebugClick,
hasDebugAlerts,
showDebugButton,
onAddWorkspace: handleAddWorkspace,
onSelectHome: selectHome,
onSelectWorkspace: (workspaceId) => {
Expand Down
6 changes: 3 additions & 3 deletions src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type SidebarProps = {
accountRateLimits: RateLimitSnapshot | null;
onOpenSettings: () => void;
onOpenDebug: () => void;
hasDebugAlerts: boolean;
showDebugButton: boolean;
onAddWorkspace: () => void;
onSelectHome: () => void;
onSelectWorkspace: (id: string) => void;
Expand All @@ -44,7 +44,7 @@ export function Sidebar({
accountRateLimits,
onOpenSettings,
onOpenDebug,
hasDebugAlerts,
showDebugButton,
onAddWorkspace,
onSelectHome,
onSelectWorkspace,
Expand Down Expand Up @@ -733,7 +733,7 @@ export function Sidebar({
>
<Settings size={14} aria-hidden />
</button>
{hasDebugAlerts && (
{showDebugButton && (
<button
className="ghost sidebar-corner-button"
type="button"
Expand Down
19 changes: 18 additions & 1 deletion src/hooks/useDebugLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import type { DebugEntry } from "../types";
const MAX_DEBUG_ENTRIES = 200;

export function useDebugLog() {
const [debugOpen, setDebugOpen] = useState(false);
const [debugOpen, setDebugOpenState] = useState(false);
const [debugEntries, setDebugEntries] = useState<DebugEntry[]>([]);
const [hasDebugAlerts, setHasDebugAlerts] = useState(false);
const [debugPinned, setDebugPinned] = useState(false);

const shouldLogEntry = useCallback((entry: DebugEntry) => {
if (entry.source === "error" || entry.source === "stderr") {
Expand Down Expand Up @@ -59,11 +60,27 @@ export function useDebugLog() {
setHasDebugAlerts(false);
}, []);

const setDebugOpen = useCallback(
(next: boolean | ((prev: boolean) => boolean)) => {
setDebugOpenState((prev) => {
const resolved = typeof next === "function" ? next(prev) : next;
if (resolved) {
setDebugPinned(true);
}
return resolved;
});
},
[],
);

const showDebugButton = hasDebugAlerts || debugOpen || debugPinned;

return {
debugOpen,
setDebugOpen,
debugEntries,
hasDebugAlerts,
showDebugButton,
addDebugEntry,
handleCopyDebug,
clearDebugEntries,
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useLayoutNodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type LayoutNodesOptions = {
) => void;
onOpenSettings: () => void;
onOpenDebug: () => void;
hasDebugAlerts: boolean;
showDebugButton: boolean;
onAddWorkspace: () => void;
onSelectHome: () => void;
onSelectWorkspace: (workspaceId: string) => void;
Expand Down Expand Up @@ -213,7 +213,7 @@ export function useLayoutNodes(options: LayoutNodesOptions): LayoutNodesResult {
accountRateLimits={options.activeRateLimits}
onOpenSettings={options.onOpenSettings}
onOpenDebug={options.onOpenDebug}
hasDebugAlerts={options.hasDebugAlerts}
showDebugButton={options.showDebugButton}
onAddWorkspace={options.onAddWorkspace}
onSelectHome={options.onSelectHome}
onSelectWorkspace={options.onSelectWorkspace}
Expand Down