Skip to content

Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.

1.5 KB
Raw Blame
// The artifact drawer shares the conversation column on wide layouts and turns
// into an overlay that covers the chat below 800px (see
// useArtifactPanelLayout's compact mode), so auto-revealing it there would hide
// the answer the user is reading.
export const PANEL_ROOM_BREAKPOINT = 800;

// collectArtifacts labels files that came with a user message with this source;
// they are already visible in the composer and were not generated by the reply.
const USER_UPLOAD_SOURCE = "上传的文件";

export function panelFitsBesideConversation({
  viewportWidth = 0,
  sidebarOpen = false,
  sidebarWidth = 0,
} = {}) {
  const width = Number(viewportWidth);
  if (!Number.isFinite(width) || width <= 0) return false;
  const navigation = sidebarOpen ? Number(sidebarWidth) || 0 : 0;
  return width - navigation >= PANEL_ROOM_BREAKPOINT;
}

export function isGeneratedArtifact(artifact) {
  return Boolean(artifact) && artifact.source !== USER_UPLOAD_SOURCE;
}

/**
 * A newly generated artifact opens the drawer so the user does not have to
 * notice the unread badge. Restored artifacts (the first snapshot of an
 * existing conversation) and conversations without artifacts leave the drawer
 * exactly as the user left it.
 */
export function shouldRevealArtifactPanel({
  addedArtifacts = 0,
  panelOpen = false,
  viewportWidth = 0,
  sidebarOpen = false,
  sidebarWidth = 0,
} = {}) {
  if (panelOpen || !(addedArtifacts > 0)) return false;
  return panelFitsBesideConversation({ viewportWidth, sidebarOpen, sidebarWidth });
}