Skip to content

Fix/trace and UI improvements#27

Open
muhammad-bassiouni wants to merge 2 commits intoownpilot:mainfrom
muhammad-bassiouni:fix/trace-and-ui-improvements
Open

Fix/trace and UI improvements#27
muhammad-bassiouni wants to merge 2 commits intoownpilot:mainfrom
muhammad-bassiouni:fix/trace-and-ui-improvements

Conversation

@muhammad-bassiouni
Copy link
Copy Markdown

Fix: Trace Rendering Crash & Sidebar UI Aesthetics

1. Trace Rendering Crash (TypeError: Cannot read properties of undefined)

The Issue

Opening historical chats or expanding the Trace module during active sessions caused the frontend to completely crash with a React Error Boundary: TypeError: Cannot read properties of undefined (reading 'reduce') at TraceDisplay.

How to Reproduce Exactly

  1. Create a chat session where the agent does not execute any autonomy checks or database operations (resulting in those arrays being undefined in the payload).
  2. Save the chat.
  3. Open the History page and click on the chat.
  4. Expand the "Debug/Trace Info" block.
  5. The UI will instantly crash because TraceDisplay.tsx attempts to call .reduce() or .map() on undefined trace arrays (e.g., trace.autonomyChecks.reduce()).

The Fix Applied

Instead of patching the UI with endless defensive checks (e.g., trace.autonomyChecks || []), we enforced a strict backend contract.

  1. Updated the persistence middleware to explicitly initialize all mandatory fields (autonomyChecks, dbOperations, memoryOps, triggersFired, errors) with safe defaults when streaming trace data back to the UI.
  2. Added a normalizeTrace() interceptor to the history API to sanitize legacy database records before they are sent to the client.
  3. Stripped out all the temporary defensive patches from the React component.

How it Solves the Issue

The frontend is now guaranteed to receive a perfectly formatted TraceInfo object directly from the API. By fixing the data structure at the source (the gateway/database extraction layer), TraceDisplay.tsx can safely iterate over arrays without risking null reference crashes.

Files Changed

  • packages/gateway/src/services/conversation-service.ts
  • packages/gateway/src/routes/chat-history.ts
  • packages/ui/src/components/TraceDisplay.tsx

2. Sidebar UI Aesthetics & Indentation

The Issue

The main sidebar UI felt slightly unpolished and bulky. Nested lists inside accordions (Workspaces, Workflows, Recent Chats) had incorrect indentation, making it hard to see the visual hierarchy. Active navigation items relied on heavy left borders. The "Recent" search input lacked an icon and was flush with the far edge, disconnecting it from its header.

How to Reproduce Exactly

  1. Open the sidebar.
  2. Expand the "Workspaces" or "Recent" accordion. Notice the child items are flush left, lacking indentation.
  3. Click an item to see the clunky border-l-[3px] active state and the jumping text effect (hover:translate-x-0.5).
  4. Look at the "Recent" section's search bar; it contains the raw unicode string \u2026 instead of an actual Search icon.
  5. Look at the "Customize" tab; it uses a generic Chevron instead of a settings-related icon.

The Fix Applied

  1. Indentation: Added precise left padding (pl-7 for standard lists, pl-9 for Recent search/tabs) so the text of child items perfectly aligns vertically with the text of their parent headers.
  2. Active States: Removed the heavy left borders and translate animations. Replaced them with a modern, fully rounded background highlight (bg-primary/10).
  3. Typography: Scaled font sizes to a crisper text-sm font-medium for nav links and text-[13px] for deeper nested items.
  4. Icons & Search: Embedded a native Search icon into the recent input, softened its background to bg-black/5, and replaced the generic Customize chevron with the Settings2 icon.

How it Solves the Issue

The sidebar now adheres to modern, professional UI standards. The spatial hierarchy is clear because child elements physically nest under their parent text. Active elements are obvious without being heavy, and the components look fully integrated rather than patched together.

Files Changed

  • packages/ui/src/components/Sidebar.tsx
  • packages/ui/src/components/sidebar/SidebarDataSection.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant