import type { LayoutNode } from 'officerdev';

/** Does this tree contain a panel running `appType`? */
export function hasAppType(node: LayoutNode, appType: string): boolean {
  if (node.type === 'panel') return node.appType === appType;
  return node.children.some((child) => hasAppType(child.node, appType));
}

// The left column is itself a split: what is running now on top, the whole history below. They answer
// different questions from different sources — the agent's in-memory map versus transcripts on disk —
// and the live one is small and usually empty, hence the lopsided 25/75.
export const defaultLayout: LayoutNode = {
  type: 'group',
  id: 'chat-history-root',
  direction: 'horizontal',
  children: [
    {
      node: {
        type: 'group',
        id: 'chat-sidebar',
        direction: 'vertical',
        children: [
          { node: { type: 'panel', id: 'chat-live', appType: 'chat-live' }, size: 25 },
          { node: { type: 'panel', id: 'chat-list', appType: 'chat-session-list' }, size: 75 },
        ],
      },
      size: 35,
    },
    { node: { type: 'panel', id: 'chat-detail', appType: 'chat-detail' }, size: 65 },
  ],
};
