@temmo/cli 0.0.0-stage → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +14 -0
- package/.claude-plugin/plugin.json +16 -0
- package/.codex-plugin/plugin.json +30 -0
- package/.cursor-plugin/plugin.json +22 -0
- package/.mcp.json +18 -0
- package/LICENSE +202 -0
- package/README.md +82 -2
- package/THIRD_PARTY_NOTICES +32 -0
- package/commands/afk.md +17 -0
- package/deploy/build-ui.mjs +65 -0
- package/deploy/claude/README.md +16 -0
- package/deploy/claude/auto-mode.json +31 -0
- package/deploy/postgres/compose.yaml +26 -0
- package/deploy/temmo-runner.service +24 -0
- package/deploy/verify-ui.mjs +15 -0
- package/harness-core/README.md +27 -0
- package/harness-core/bin/harness.mjs +17 -0
- package/harness-core/package.json +10 -0
- package/harness-core/stage.mjs +108 -0
- package/harness-core/stages/commit.md +7 -0
- package/harness-core/stages/pr.md +7 -0
- package/harness-core/stages/push.md +7 -0
- package/hooks/codex-hooks.json +14 -0
- package/hooks/cursor-hooks.json +17 -0
- package/hooks/hooks.json +27 -0
- package/lib/acp/permission.js +72 -0
- package/lib/acp/sessionConfig.js +109 -0
- package/lib/activity.js +244 -0
- package/lib/agent-guard.js +72 -0
- package/lib/agents-route.js +55 -0
- package/lib/agents.js +213 -0
- package/lib/agui.js +255 -0
- package/lib/alerts.js +36 -0
- package/lib/analyze-otlp.js +46 -0
- package/lib/analyze-run-code.js +397 -0
- package/lib/analyze-sources.js +372 -0
- package/lib/approval-card.js +54 -0
- package/lib/approval-cli.js +53 -0
- package/lib/approval-request.js +81 -0
- package/lib/approval-signer.js +48 -0
- package/lib/approvals.js +295 -0
- package/lib/attachment-cache.js +236 -0
- package/lib/attachment.js +63 -0
- package/lib/blocked.js +20 -0
- package/lib/build-review.js +90 -0
- package/lib/builder/cli.js +90 -0
- package/lib/builder/policy.js +176 -0
- package/lib/builder/recover.js +189 -0
- package/lib/builder/run.js +240 -0
- package/lib/builder/settle.js +198 -0
- package/lib/builder/stage.js +240 -0
- package/lib/builder/state.js +73 -0
- package/lib/builder/supervisor.js +289 -0
- package/lib/builder-clean.js +223 -0
- package/lib/builder-code.cjs +67 -0
- package/lib/builder.js +9 -0
- package/lib/bus-postgres.js +281 -0
- package/lib/bus.js +349 -0
- package/lib/catalog/author.js +278 -0
- package/lib/catalog/dot.js +426 -0
- package/lib/catalog/pattern-model.js +193 -0
- package/lib/catalog/patterns.js +324 -0
- package/lib/catalog/projects.js +83 -0
- package/lib/catalog/records.js +2 -0
- package/lib/catalog/roster.js +70 -0
- package/lib/catalog/team-files.js +49 -0
- package/lib/catalog/teams.js +109 -0
- package/lib/claude-socket.js +333 -0
- package/lib/cli.js +741 -0
- package/lib/code-mode.js +45 -0
- package/lib/code-read-policy.yaml +9 -0
- package/lib/code-run.js +461 -0
- package/lib/codex-compact.js +141 -0
- package/lib/compaction.js +21 -0
- package/lib/config.js +424 -0
- package/lib/cursor-trace.js +248 -0
- package/lib/deep-link.js +20 -0
- package/lib/deliver-push.js +120 -0
- package/lib/delivery.js +28 -0
- package/lib/deploy-tree.js +227 -0
- package/lib/durable.js +404 -0
- package/lib/factory-tick.js +32 -0
- package/lib/family.js +63 -0
- package/lib/fetch-origin.js +53 -0
- package/lib/format.js +133 -0
- package/lib/harness-surface-cli.js +153 -0
- package/lib/harness-surface.js +486 -0
- package/lib/harness.js +271 -0
- package/lib/hook.mjs +291 -0
- package/lib/idle.js +40 -0
- package/lib/install-cursor.js +115 -0
- package/lib/install-opencode.js +105 -0
- package/lib/job.js +82 -0
- package/lib/land-cli.js +319 -0
- package/lib/land-member.js +64 -0
- package/lib/land.js +320 -0
- package/lib/lessons.js +223 -0
- package/lib/limit-alert.js +423 -0
- package/lib/limits.js +284 -0
- package/lib/machine-prompt.js +19 -0
- package/lib/merge-sweep.js +149 -0
- package/lib/messaging.js +1002 -0
- package/lib/mission-cli.js +103 -0
- package/lib/mission.js +241 -0
- package/lib/mode.js +215 -0
- package/lib/models.js +114 -0
- package/lib/names.js +86 -0
- package/lib/opencode-api.js +57 -0
- package/lib/opencode-plugin.mjs +313 -0
- package/lib/operator-token.js +78 -0
- package/lib/operator.js +187 -0
- package/lib/pad-activity.js +143 -0
- package/lib/pad-fresh.js +44 -0
- package/lib/pad.js +198 -0
- package/lib/pattern-cli.js +120 -0
- package/lib/pattern-compiler.js +68 -0
- package/lib/pattern-runs.js +795 -0
- package/lib/pattern-stall.js +58 -0
- package/lib/pattern-tick.js +45 -0
- package/lib/pattern-workflow.js +69 -0
- package/lib/pi-extension.mjs +98 -0
- package/lib/pi.js +57 -0
- package/lib/plugin-copy.js +76 -0
- package/lib/pm-review.js +32 -0
- package/lib/pm-workspace.js +87 -0
- package/lib/postgres.js +115 -0
- package/lib/pr-card.js +34 -0
- package/lib/probe.js +295 -0
- package/lib/process.js +67 -0
- package/lib/project-pause.js +23 -0
- package/lib/prune.js +793 -0
- package/lib/questions.js +250 -0
- package/lib/receipts.js +63 -0
- package/lib/reflect.js +962 -0
- package/lib/rename-migration.js +118 -0
- package/lib/run-terminal.js +437 -0
- package/lib/runner-request.js +33 -0
- package/lib/sandbox-app.js +120 -0
- package/lib/sandbox-claims.js +258 -0
- package/lib/sandbox-cli.js +188 -0
- package/lib/sandbox-hosts-cli.js +68 -0
- package/lib/sandbox-hosts.js +94 -0
- package/lib/sandbox-pr.js +102 -0
- package/lib/sandbox-proposal.js +367 -0
- package/lib/sandbox-tools.js +143 -0
- package/lib/sandbox.js +501 -0
- package/lib/schedule-session.js +68 -0
- package/lib/session-activity.js +67 -0
- package/lib/session-events.js +94 -0
- package/lib/sessions/control.js +244 -0
- package/lib/sessions/git-refs.js +265 -0
- package/lib/sessions/launch.js +359 -0
- package/lib/sessions/registry.js +450 -0
- package/lib/sessions/scope.js +111 -0
- package/lib/setup.js +377 -0
- package/lib/signed-approval.js +225 -0
- package/lib/slash.js +167 -0
- package/lib/spawn-cli.js +45 -0
- package/lib/spawn.js +107 -0
- package/lib/start-limit.js +58 -0
- package/lib/state.js +24 -0
- package/lib/stop.js +308 -0
- package/lib/store-read.js +62 -0
- package/lib/store.js +252 -0
- package/lib/subagent-guard.js +240 -0
- package/lib/surfaces/channel-post.js +43 -0
- package/lib/surfaces/instructions.js +15 -0
- package/lib/surfaces/mcp-reload.js +144 -0
- package/lib/surfaces/ops.js +629 -0
- package/lib/surfaces/render-mcp.js +33 -0
- package/lib/surfaces/run-terminal-ops.js +40 -0
- package/lib/surfaces/sandbox-ops.js +36 -0
- package/lib/surfaces/schema.js +7 -0
- package/lib/surfaces/task-view.js +90 -0
- package/lib/surfaces/types.js +4 -0
- package/lib/task-cli.js +274 -0
- package/lib/task-order.js +34 -0
- package/lib/task-order.mjs +2 -0
- package/lib/task-route.js +125 -0
- package/lib/tasks.js +631 -0
- package/lib/team-permission.js +34 -0
- package/lib/team-templates/blitz/team.dot +9 -0
- package/lib/team-templates/factory/team.dot +26 -0
- package/lib/team-templates/feature/team.dot +14 -0
- package/lib/team-templates/fix-and-review/team.dot +12 -0
- package/lib/team-templates/product/team.dot +16 -0
- package/lib/team-templates/release/team.dot +7 -0
- package/lib/team-templates/review/team.dot +6 -0
- package/lib/terminal-draft.js +42 -0
- package/lib/thread-branch.js +82 -0
- package/lib/thread-channel-store.js +181 -0
- package/lib/thread-channels.js +116 -0
- package/lib/thread-listening.js +20 -0
- package/lib/thread-routes.js +91 -0
- package/lib/threads.js +441 -0
- package/lib/tool-api.js +33 -0
- package/lib/transcript.js +98 -0
- package/lib/ui-build-output.js +19 -0
- package/lib/ui-capabilities.js +90 -0
- package/lib/usage.js +182 -0
- package/lib/vendor/mcp-sdk.d.mts +4 -0
- package/lib/vendor/mcp-sdk.mjs +17046 -0
- package/lib/waiter.js +127 -0
- package/lib/workflows.js +546 -0
- package/lib/worktree-setup.js +86 -0
- package/package.json +110 -4
- package/runner/adapters/claude.js +465 -0
- package/runner/adapters/cli-sandbox.js +277 -0
- package/runner/adapters/codex.js +675 -0
- package/runner/adapters/cursor.mjs +937 -0
- package/runner/adapters/fake.js +119 -0
- package/runner/adapters/opencode-sandbox.js +370 -0
- package/runner/adapters/opencode.js +486 -0
- package/runner/adapters/pi-sandbox.js +134 -0
- package/runner/adapters/pi.js +364 -0
- package/runner/client.js +40 -0
- package/runner/contract.js +129 -0
- package/runner/control.js +178 -0
- package/runner/delivery.js +184 -0
- package/runner/factory-tick.mjs +10 -0
- package/runner/lock.js +41 -0
- package/runner/main.mjs +118 -0
- package/runner/pattern-tick.mjs +16 -0
- package/runner/publish.js +113 -0
- package/runner/runner.js +2612 -0
- package/runner/sandbox-run.mjs +239 -0
- package/runner/schedules.js +294 -0
- package/runner/task-wake.js +59 -0
- package/scripts/ai-collab +3 -0
- package/scripts/ai-collab-bus.mjs +4 -0
- package/scripts/ai-collab-code-mcp.mjs +3 -0
- package/scripts/ai-collab-hook +3 -0
- package/scripts/ai-collab-hook.mjs +3 -0
- package/scripts/ai-collab-mcp-tools.mjs +2 -0
- package/scripts/ai-collab-mcp.mjs +3 -0
- package/scripts/ai-collab.mjs +3 -0
- package/scripts/install-cursor.mjs +11 -0
- package/scripts/install-opencode.mjs +10 -0
- package/scripts/temmo +3 -0
- package/scripts/temmo-bus.mjs +151 -0
- package/scripts/temmo-code-mcp.mjs +63 -0
- package/scripts/temmo-hook +3 -0
- package/scripts/temmo-hook.mjs +201 -0
- package/scripts/temmo-mcp-tools.mjs +22 -0
- package/scripts/temmo-mcp.mjs +27 -0
- package/scripts/temmo.mjs +4 -0
- package/skills/antislop/SKILL.md +701 -0
- package/skills/antislop/VERSION +1 -0
- package/skills/antislop-code/SKILL.md +128 -0
- package/skills/antislop-human/LICENSE-web-quality-skills +21 -0
- package/skills/antislop-human/SKILL.md +204 -0
- package/skills/antislop-human/contrast-check.py +168 -0
- package/skills/antislop-human/contrast-mcp.py +125 -0
- package/skills/antislop-human/references/A11Y-PATTERNS.md +249 -0
- package/skills/antislop-human/references/WCAG.md +127 -0
- package/skills/antislop-layoutmobile/SKILL.md +170 -0
- package/skills/antislop-ui/LICENSE-web-quality-skills +21 -0
- package/skills/antislop-ui/SKILL.md +351 -0
- package/skills/antislop-ui/references/CORE-WEB-VITALS.md +181 -0
- package/skills/antislop-ui/references/WEB-BASELINE.md +28 -0
- package/skills/harness-surface/SKILL.md +42 -0
- package/skills/land/SKILL.md +32 -0
- package/skills/memory-file/SKILL.md +39 -0
- package/skills/temmo/SKILL.md +101 -0
- package/skills/temmo/references/role-programs.md +47 -0
- package/skills/ui-sdk/SKILL.md +56 -0
- package/skills/ui-sdk/references/agent-ready.md +136 -0
- package/skills/ui-sdk/references/build-interface.md +187 -0
- package/skills/ui-sdk/references/create-component.md +88 -0
- package/skills/ui-sdk/references/patterns.md +246 -0
- package/skills/ui-sdk/references/styles.md +66 -0
- package/skills/ui-sdk/references/testing.md +172 -0
- package/skills/ui-sdk/references/web-components.md +78 -0
- package/tools/screen-state.mjs +119 -0
- package/tools/smoke-ui.mjs +540 -0
- package/web/app/activity.jsx +251 -0
- package/web/app/agent-mark.tsx +43 -0
- package/web/app/alert-level.jsx +16 -0
- package/web/app/api/[action]/route.js +8 -0
- package/web/app/api/auth/[step]/route.js +12 -0
- package/web/app/api/events/route.js +8 -0
- package/web/app/api/file/[name]/route.js +8 -0
- package/web/app/api/land/route.js +12 -0
- package/web/app/api/lessons/route.js +8 -0
- package/web/app/api/push/key/route.js +8 -0
- package/web/app/api/push/subscribe/route.js +12 -0
- package/web/app/api/push/test/route.js +8 -0
- package/web/app/api/refs/route.js +8 -0
- package/web/app/api/review-diff/route.js +8 -0
- package/web/app/api/schedules/route.js +8 -0
- package/web/app/api/thread-diff/route.js +8 -0
- package/web/app/api/version/route.js +6 -0
- package/web/app/cards.jsx +189 -0
- package/web/app/chat-api.js +82 -0
- package/web/app/chat-composer.jsx +313 -0
- package/web/app/chat-console.jsx +691 -0
- package/web/app/chat-image.tsx +61 -0
- package/web/app/chat-message.jsx +122 -0
- package/web/app/chat-shared.jsx +59 -0
- package/web/app/chat-sidebar.jsx +25 -0
- package/web/app/chat-stream.js +127 -0
- package/web/app/chat.jsx +31 -0
- package/web/app/compactions.jsx +57 -0
- package/web/app/composer-actions.tsx +87 -0
- package/web/app/decisions.jsx +53 -0
- package/web/app/fonts/OFL-hanken-grotesk.txt +93 -0
- package/web/app/fonts/OFL-ibm-plex-mono.txt +93 -0
- package/web/app/fonts/hanken-grotesk-latin-wght-normal.woff2 +0 -0
- package/web/app/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- package/web/app/fonts/ibm-plex-mono-latin-500-normal.woff2 +0 -0
- package/web/app/globals.css +199 -0
- package/web/app/home.jsx +246 -0
- package/web/app/icon.svg +1 -0
- package/web/app/land-panel.jsx +63 -0
- package/web/app/land-reviews.jsx +20 -0
- package/web/app/layout.jsx +17 -0
- package/web/app/lessons.tsx +76 -0
- package/web/app/logo.tsx +13 -0
- package/web/app/logos.jsx +16 -0
- package/web/app/manifest.js +8 -0
- package/web/app/mode-menu.tsx +46 -0
- package/web/app/new-session.jsx +275 -0
- package/web/app/notify.jsx +180 -0
- package/web/app/outcomes.tsx +94 -0
- package/web/app/page.jsx +9 -0
- package/web/app/pattern-graph.jsx +75 -0
- package/web/app/patterns-page.jsx +293 -0
- package/web/app/phone-nav.tsx +36 -0
- package/web/app/progress-feed.tsx +33 -0
- package/web/app/providers.tsx +27 -0
- package/web/app/quote.jsx +15 -0
- package/web/app/run-card.tsx +200 -0
- package/web/app/run-requests.tsx +148 -0
- package/web/app/scheduled.jsx +105 -0
- package/web/app/session-panel.tsx +174 -0
- package/web/app/session-toolbar.tsx +180 -0
- package/web/app/shadcn.css +638 -0
- package/web/app/shipped.jsx +49 -0
- package/web/app/subagent-runs.jsx +31 -0
- package/web/app/task-graph.jsx +67 -0
- package/web/app/tasks-strip.tsx +36 -0
- package/web/app/tasks.jsx +375 -0
- package/web/app/team-author.jsx +145 -0
- package/web/app/team-editor.jsx +88 -0
- package/web/app/thread-agents.tsx +32 -0
- package/web/app/thread-place.tsx +9 -0
- package/web/app/thread-sessions.tsx +149 -0
- package/web/app/thread-sidebar.tsx +418 -0
- package/web/app/thread-switcher.tsx +27 -0
- package/web/app/tool-diff.jsx +94 -0
- package/web/components/a2ui/controls.jsx +36 -0
- package/web/components/a2ui/option-picker.jsx +23 -0
- package/web/components/a2ui/script.tsx +121 -0
- package/web/components/a2ui/surface.jsx +81 -0
- package/web/components/chat/thread.jsx +50 -0
- package/web/components/script-text.tsx +42 -0
- package/web/components/ui/avatar.jsx +115 -0
- package/web/components/ui/badge.jsx +47 -0
- package/web/components/ui/button.jsx +63 -0
- package/web/components/ui/chat-container.jsx +52 -0
- package/web/components/ui/choice-list.tsx +72 -0
- package/web/components/ui/code-block.jsx +60 -0
- package/web/components/ui/copy-button.tsx +41 -0
- package/web/components/ui/dropdown-menu.jsx +257 -0
- package/web/components/ui/markdown.jsx +84 -0
- package/web/components/ui/message.jsx +28 -0
- package/web/components/ui/popover.jsx +33 -0
- package/web/components/ui/scroll-button.jsx +34 -0
- package/web/components/ui/select.jsx +189 -0
- package/web/components/ui/sheet.jsx +152 -0
- package/web/components/ui/sonner.jsx +10 -0
- package/web/components/ui/tabs.jsx +88 -0
- package/web/components/ui/textarea.jsx +20 -0
- package/web/components/ui/tooltip.jsx +56 -0
- package/web/components.json +24 -0
- package/web/instrumentation.js +8 -0
- package/web/lib/a2ui-catalog.js +34 -0
- package/web/lib/a2ui-pr.js +76 -0
- package/web/lib/a2ui-run-catalog.js +18 -0
- package/web/lib/a2ui-run.js +93 -0
- package/web/lib/a2ui.js +262 -0
- package/web/lib/activity-rows.js +275 -0
- package/web/lib/agent-detail.js +5 -0
- package/web/lib/alert-level.js +44 -0
- package/web/lib/approval-mode.js +22 -0
- package/web/lib/chat-turns.js +174 -0
- package/web/lib/child-subagents.js +16 -0
- package/web/lib/compaction-view.js +48 -0
- package/web/lib/composer-actions.js +40 -0
- package/web/lib/context-view.js +57 -0
- package/web/lib/fuzzy.js +26 -0
- package/web/lib/highlight.js +44 -0
- package/web/lib/lessons-view.js +23 -0
- package/web/lib/mentions.js +16 -0
- package/web/lib/message-routing.js +105 -0
- package/web/lib/new-session.js +85 -0
- package/web/lib/operator-messages.js +28 -0
- package/web/lib/pattern-graph.js +165 -0
- package/web/lib/pattern-view.js +33 -0
- package/web/lib/pending-summary.js +18 -0
- package/web/lib/permission-modes.js +30 -0
- package/web/lib/project-feed.js +107 -0
- package/web/lib/quote.js +7 -0
- package/web/lib/reply-quote.js +31 -0
- package/web/lib/scheduled.js +79 -0
- package/web/lib/selection.js +110 -0
- package/web/lib/send-confirmation.js +22 -0
- package/web/lib/session-dead.js +10 -0
- package/web/lib/session-state.js +132 -0
- package/web/lib/sidebar.js +15 -0
- package/web/lib/slash-commands.js +164 -0
- package/web/lib/start-default.js +35 -0
- package/web/lib/start-mode.js +35 -0
- package/web/lib/stream-views.js +49 -0
- package/web/lib/subagent-state.js +20 -0
- package/web/lib/task-board.js +54 -0
- package/web/lib/task-graph.js +183 -0
- package/web/lib/task-tags.js +41 -0
- package/web/lib/team-editor.js +10 -0
- package/web/lib/thread-groups.js +86 -0
- package/web/lib/threads.js +28 -0
- package/web/lib/tool-diff.js +273 -0
- package/web/lib/ui-events.js +58 -0
- package/web/lib/utils.js +5 -0
- package/web/lib/view-memory.js +25 -0
- package/web/next.config.mjs +37 -0
- package/web/postcss.config.mjs +1 -0
- package/web/proxy.js +25 -0
- package/web/public/sw.js +39 -0
- package/web/server/auth.js +178 -0
- package/web/server/dispatch.js +293 -0
- package/web/server/history.js +56 -0
- package/web/server/hosted.js +58 -0
- package/web/server/hub.js +126 -0
- package/web/server/instance.js +5 -0
- package/web/server/land-reviews.js +64 -0
- package/web/server/push.js +148 -0
- package/web/server/run-terminal.js +79 -0
- package/web/server/schedules.js +38 -0
- package/web/server/shipped.js +51 -0
- package/web/server/task-board.js +71 -0
- package/web/server/threads.js +209 -0
- package/web/server/ui.js +2937 -0
- package/web/tsconfig.base.json +16 -0
- package/web/tsconfig.json +9 -0
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// The left column: wordmark, project switcher, the project's threads grouped by what they need, and the app menu.
|
|
3
|
+
// Rendered beside the chat on a desktop and as the whole screen on a phone.
|
|
4
|
+
import { useState, type FormEvent, type ReactNode } from "react";
|
|
5
|
+
import { Check, ChevronDown, ChevronRight, Ellipsis, GitPullRequest, Inbox, MessagesSquare, Plus, Settings2 } from "lucide-react";
|
|
6
|
+
import { AlertDialog, AlertDialogClose, AlertDialogContent, AlertDialogDescription, AlertDialogTitle } from "@ui-sdk/react/alert-dialog";
|
|
7
|
+
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle } from "@ui-sdk/react/dialog";
|
|
8
|
+
import { Field, FieldLabel } from "@ui-sdk/react/field";
|
|
9
|
+
import { Input } from "@ui-sdk/react/input";
|
|
10
|
+
import { Menu, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuItemIndicator, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger } from "@ui-sdk/react/menu";
|
|
11
|
+
import { useTheme } from "next-themes";
|
|
12
|
+
import { cn } from "@/lib/utils";
|
|
13
|
+
import { isLive, sessionState } from "@/lib/session-state";
|
|
14
|
+
import { COLLAPSED, GROUPS, SETTLED_OPEN, elapsed, inactiveThreads, shortName, threadGroups, threadSession, unthreaded, workingTime, type Agent, type GroupId, type Thread, type ThreadRow } from "@/lib/thread-groups";
|
|
15
|
+
import { AgentName, HarnessMark } from "./agent-mark";
|
|
16
|
+
import { SessionTree, missingSession, workingCount, type ListenSession, type OpenSession } from "./thread-sessions";
|
|
17
|
+
import { Dot, ago } from "./chat-shared";
|
|
18
|
+
import { Logo } from "./logo";
|
|
19
|
+
import { ThreadPlace } from "./thread-place";
|
|
20
|
+
import { TasksStrip } from "./tasks-strip";
|
|
21
|
+
|
|
22
|
+
type Project = { id: string; waiting?: number; paused?: boolean };
|
|
23
|
+
type Selected = { level: string; project?: string; session?: string; tab?: string; thread?: string };
|
|
24
|
+
type Navigate = (next: Record<string, unknown>) => void;
|
|
25
|
+
type Data = {
|
|
26
|
+
project?: string; projects: Project[]; agents: Agent[]; threads?: Thread[]; closedProjects?: string[]; autoProjects?: string[];
|
|
27
|
+
decisions?: unknown[]; mode?: string; hosted?: boolean; tasks?: { tasks?: Parameters<typeof TasksStrip>[0]["tasks"] };
|
|
28
|
+
};
|
|
29
|
+
export type SidebarProps = {
|
|
30
|
+
data: Data; selected: Selected; now: number; navigate: Navigate; ready: boolean; disabled: boolean;
|
|
31
|
+
newThread: (project: string) => void; projectAction: (path: string, name: string) => void;
|
|
32
|
+
counts: { tasks: number; waiting: number; patterns: number }; decisions: number;
|
|
33
|
+
pause: () => void; openSchedules: () => void; openLessons?: () => void; signOut?: () => void; account?: string;
|
|
34
|
+
controls?: ReactNode; openTasks?: () => void; listen?: ListenSession;
|
|
35
|
+
threadAction?: ThreadAction; archiveThreads?: (ids: string[]) => void; stop?: (session: string) => void;
|
|
36
|
+
};
|
|
37
|
+
// One POST /api/thread op on one thread: rename {title}, pin {pinned}, status {status}.
|
|
38
|
+
export type ThreadAction = (op: "rename" | "pin" | "status", thread: string, fields: Record<string, unknown>, done: string) => void;
|
|
39
|
+
|
|
40
|
+
const MENU = "z-50 min-w-56 rounded-xl bg-popover p-1 text-sm text-popover-foreground shadow-raised outline-none";
|
|
41
|
+
const ITEM = "flex min-h-9 cursor-pointer items-center gap-2 rounded-md px-2 focus-visible:-outline-offset-2 data-highlighted:bg-accent data-disabled:cursor-default data-disabled:opacity-50 max-sm:min-h-11";
|
|
42
|
+
const LABEL = "px-2 pb-1 pt-2 text-xs text-muted-foreground";
|
|
43
|
+
const SEP = "my-1 h-px bg-border";
|
|
44
|
+
const THEMES = [["system", "System"], ["light", "Light"], ["dark", "Dark"]];
|
|
45
|
+
const DIALOG = "m-auto w-[min(28rem,calc(100vw-2rem))] rounded-xl bg-popover p-4 text-sm text-popover-foreground shadow-raised outline-none backdrop:bg-black/40";
|
|
46
|
+
const BUTTON = "inline-flex min-h-9 items-center rounded-md px-3 text-sm hover:bg-accent focus-visible:outline-2 max-md:min-h-11";
|
|
47
|
+
const SOLID = "bg-primary text-primary-foreground hover:bg-primary/90";
|
|
48
|
+
const PR_TONE = { merged: "text-foreground", open: "text-foreground", draft: "text-muted-foreground", closed: "text-muted-foreground line-through" } satisfies Record<string, string>;
|
|
49
|
+
|
|
50
|
+
/** The mark and wordmark; together they are the way home. */
|
|
51
|
+
function Wordmark({ current, navigate }: { current: boolean; navigate: Navigate }) {
|
|
52
|
+
return <button type="button" data-tap onClick={() => navigate({ level: "home" })} aria-current={current ? "page" : undefined} title="Home: every project"
|
|
53
|
+
className="flex items-center gap-2 rounded-md px-1 text-base font-semibold tracking-tight text-foreground">
|
|
54
|
+
<Logo/><span>ai<span className="text-muted-foreground">-</span>collab</span>
|
|
55
|
+
</button>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The project picker: the current project's full name, its waiting count, and every project in the menu. */
|
|
59
|
+
function ProjectSwitcher({ data, current, navigate }: { data: Data; current: string; navigate: Navigate }) {
|
|
60
|
+
const waiting = data.projects.reduce((sum, item) => sum + (item.waiting || 0), 0);
|
|
61
|
+
return <Menu presentation="auto">
|
|
62
|
+
<MenuTrigger className="flex min-h-9 w-full min-w-0 items-center gap-2 rounded-md px-2 text-left text-sm font-medium hover:bg-sidebar-accent data-open:bg-sidebar-accent max-md:min-h-11">
|
|
63
|
+
<span className="min-w-0 flex-1 truncate" title={current || "All projects"}>{current || "All projects"}</span>
|
|
64
|
+
{waiting > 0 && <span className="shrink-0 text-xs font-medium text-primary" aria-label={waiting + " waiting on you"}>{waiting}</span>}
|
|
65
|
+
<ChevronDown aria-hidden className="size-3.5 shrink-0 text-muted-foreground"/>
|
|
66
|
+
</MenuTrigger>
|
|
67
|
+
<MenuContent align="start" className={cn(MENU, "max-h-(--available-height) w-(--anchor-width) min-w-64 overflow-y-auto")}>
|
|
68
|
+
<MenuItem className={ITEM} onSelect={() => navigate({ level: "home" })}>
|
|
69
|
+
<span className="flex-1">All projects</span>{!current && <Check aria-hidden className="size-3.5"/>}
|
|
70
|
+
</MenuItem>
|
|
71
|
+
<MenuSeparator className={SEP}/>
|
|
72
|
+
{data.projects.map(project => <MenuItem key={project.id} className={ITEM} onSelect={() => navigate({ project: project.id, level: "project" })}>
|
|
73
|
+
<span className="min-w-0 flex-1 break-all">{project.id}</span>
|
|
74
|
+
{project.paused && <span className="shrink-0 text-xs text-muted-foreground">paused</span>}
|
|
75
|
+
{(project.waiting || 0) > 0 && <span className="shrink-0 text-xs font-medium text-primary">{project.waiting} waiting</span>}
|
|
76
|
+
{project.id === current && <Check aria-hidden className="size-3.5 shrink-0"/>}
|
|
77
|
+
</MenuItem>)}
|
|
78
|
+
</MenuContent>
|
|
79
|
+
</Menu>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function PrBadges({ prs }: { prs?: Thread["prs"] }) {
|
|
83
|
+
if (!prs?.length) return null;
|
|
84
|
+
return <span className="flex shrink-0 items-center gap-1.5">
|
|
85
|
+
{prs.map(pr => {
|
|
86
|
+
const cls = cn("inline-flex items-center gap-0.5 font-mono text-xs", PR_TONE[pr.state as keyof typeof PR_TONE] || "text-muted-foreground");
|
|
87
|
+
const title = "PR #" + pr.number + " · " + pr.state;
|
|
88
|
+
const body = <><GitPullRequest aria-hidden className="size-3"/>{pr.number}</>;
|
|
89
|
+
// A known url makes the badge a link; a PR recorded without one stays a plain badge.
|
|
90
|
+
return pr.url
|
|
91
|
+
? <a key={pr.id || pr.number} href={pr.url} target="_blank" rel="noreferrer noopener" title={title} data-pr={pr.state} className={cn(cls, "hover:underline")}>{body}</a>
|
|
92
|
+
: <span key={pr.id || pr.number} title={title} data-pr={pr.state} className={cls}>{body}</span>;
|
|
93
|
+
})}
|
|
94
|
+
</span>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** A thread's actions: rename, pin, and the stored status the operator sets. */
|
|
98
|
+
function ThreadMenu({ row, label, act, rename, disabled }: { row: ThreadRow; label: string; act: ThreadAction; rename: (row: ThreadRow) => void; disabled?: boolean }) {
|
|
99
|
+
const status = row.status || "active";
|
|
100
|
+
const set = (next: string, done: string) => act("status", row.id, { status: next }, done);
|
|
101
|
+
return <Menu presentation="auto">
|
|
102
|
+
<MenuTrigger aria-label={"Thread actions for " + label} data-thread-menu={row.id} disabled={disabled}
|
|
103
|
+
className="mt-1 grid size-7 shrink-0 place-items-center rounded-md text-muted-foreground hover:bg-sidebar-accent hover:text-foreground data-open:bg-sidebar-accent max-md:mt-0 max-md:size-11">
|
|
104
|
+
<Ellipsis aria-hidden className="size-3.5"/>
|
|
105
|
+
</MenuTrigger>
|
|
106
|
+
<MenuContent align="end" className={MENU}>
|
|
107
|
+
<MenuItem className={ITEM} onSelect={() => rename(row)}>Rename…</MenuItem>
|
|
108
|
+
<MenuItem className={ITEM} onSelect={() => act("pin", row.id, { pinned: !row.pinned }, row.pinned ? "Unpinned" : "Pinned")}>{row.pinned ? "Unpin" : "Pin"}</MenuItem>
|
|
109
|
+
<MenuSeparator className={SEP}/>
|
|
110
|
+
{(status === "snoozed" || status === "settled") && <MenuItem className={ITEM} onSelect={() => set("active", "Marked active")}>Mark active</MenuItem>}
|
|
111
|
+
{status !== "settled" && status !== "archived" && <MenuItem className={ITEM} onSelect={() => set("settled", "Settled")}>Settle</MenuItem>}
|
|
112
|
+
{status !== "snoozed" && status !== "archived" && <MenuItem className={ITEM} onSelect={() => set("snoozed", "Snoozed")}>Snooze</MenuItem>}
|
|
113
|
+
{status === "archived" ? <MenuItem className={ITEM} onSelect={() => set("active", "Unarchived")}>Unarchive</MenuItem>
|
|
114
|
+
: <MenuItem className={ITEM} onSelect={() => set("archived", "Archived")}>Archive</MenuItem>}
|
|
115
|
+
</MenuContent>
|
|
116
|
+
</Menu>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** The rename form for one thread; a rename stops the agent from renaming it. */
|
|
120
|
+
function RenameDialog({ thread, close, act }: { thread: ThreadRow | null; close: () => void; act?: ThreadAction }) {
|
|
121
|
+
const submit = (event: FormEvent<HTMLFormElement>) => {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
const title = String(new FormData(event.currentTarget).get("title") || "").trim();
|
|
124
|
+
if (thread && act && title) act("rename", thread.id, { title }, "Renamed");
|
|
125
|
+
close();
|
|
126
|
+
};
|
|
127
|
+
return <Dialog open={Boolean(thread)} onOpenChange={open => { if (!open) close(); }}>
|
|
128
|
+
<DialogContent className={DIALOG}>
|
|
129
|
+
<DialogTitle className="text-base font-semibold">Rename thread</DialogTitle>
|
|
130
|
+
<DialogDescription className="mt-1 text-muted-foreground">The agent stops renaming it after this.</DialogDescription>
|
|
131
|
+
<form className="mt-3 flex flex-col gap-3" onSubmit={submit}>
|
|
132
|
+
<Field className="flex flex-col gap-1">
|
|
133
|
+
<FieldLabel className="text-xs text-muted-foreground">Title</FieldLabel>
|
|
134
|
+
<Input name="title" required maxLength={200} defaultValue={thread?.title || ""} key={thread?.id}
|
|
135
|
+
className="min-h-9 rounded-md border bg-background px-2 text-sm max-md:min-h-11"/>
|
|
136
|
+
</Field>
|
|
137
|
+
<div className="flex justify-end gap-2">
|
|
138
|
+
<DialogClose className={BUTTON}>Cancel</DialogClose>
|
|
139
|
+
<button type="submit" className={cn(BUTTON, SOLID)}>Rename</button>
|
|
140
|
+
</div>
|
|
141
|
+
</form>
|
|
142
|
+
</DialogContent>
|
|
143
|
+
</Dialog>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Asks before Archive inactive archives every thread it found. */
|
|
147
|
+
function ArchiveInactiveDialog({ ids, close, archive }: { ids: string[]; close: () => void; archive?: (ids: string[]) => void }) {
|
|
148
|
+
const count = ids.length;
|
|
149
|
+
return <AlertDialog open={count > 0} onOpenChange={(open, details) => {
|
|
150
|
+
if (open) return;
|
|
151
|
+
if ((details as { returnValue?: string } | undefined)?.returnValue === "confirm" && archive) archive(ids);
|
|
152
|
+
close();
|
|
153
|
+
}}>
|
|
154
|
+
<AlertDialogContent className={DIALOG}>
|
|
155
|
+
<AlertDialogTitle className="text-base font-semibold">Archive {count} inactive {count === 1 ? "thread" : "threads"}?</AlertDialogTitle>
|
|
156
|
+
<AlertDialogDescription className="mt-1 text-muted-foreground">
|
|
157
|
+
Each has had no update for 24 hours and no session online. They move to the Archived group; Unarchive brings one back.
|
|
158
|
+
</AlertDialogDescription>
|
|
159
|
+
<div className="mt-4 flex justify-end gap-2">
|
|
160
|
+
<AlertDialogClose className={BUTTON}>Cancel</AlertDialogClose>
|
|
161
|
+
<AlertDialogClose value="confirm" className={cn(BUTTON, SOLID)}>Archive {count}</AlertDialogClose>
|
|
162
|
+
</div>
|
|
163
|
+
</AlertDialogContent>
|
|
164
|
+
</AlertDialog>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** One thread: waiting mark, title, its age or working time, where it runs, harness marks and PRs, then every session it holds. */
|
|
168
|
+
function ThreadItem({ row, all, selected, now, navigate, project, listen, disabled, act, rename, stop }: {
|
|
169
|
+
row: ThreadRow; all: Agent[]; selected: Selected; now: number; navigate: Navigate; project: string; listen?: ListenSession; disabled?: boolean; stop?: (session: string) => void;
|
|
170
|
+
act?: ThreadAction; rename: (row: ThreadRow) => void;
|
|
171
|
+
}) {
|
|
172
|
+
const open = (selected.level === "thread" && selected.thread === row.id)
|
|
173
|
+
|| (selected.level === "session" && Boolean(selected.session) && (row.sessions || []).includes(selected.session || ""));
|
|
174
|
+
const working = workingTime(row, now);
|
|
175
|
+
const waiting = row.shown === "waiting";
|
|
176
|
+
const go = (session: string) => navigate({ project, level: "session", harness: session.split("#")[0], session, ...(open && selected.level === "session" && selected.tab ? { tab: selected.tab } : {}) });
|
|
177
|
+
const byId = new Map(all.map(agent => [agent.id, agent]));
|
|
178
|
+
const sessions = (row.sessions || []).map(id => byId.get(id) || missingSession(id));
|
|
179
|
+
const busy = workingCount(sessions, all, now);
|
|
180
|
+
const [shut, setShut] = useState(false);
|
|
181
|
+
// A run row opens the run's transcript as the chat (hash subagent=<run id>).
|
|
182
|
+
const openRun: OpenSession = (session, run) => run
|
|
183
|
+
? navigate({ project, level: "session", harness: session.split("#")[0], session, subagent: run })
|
|
184
|
+
: go(session);
|
|
185
|
+
const label = row.title || row.branch || row.id;
|
|
186
|
+
return <li className="flex min-w-0 flex-col">
|
|
187
|
+
<div className="flex min-w-0 items-start">
|
|
188
|
+
<button type="button" data-thread={row.id} data-working={busy || undefined} aria-current={open ? "true" : undefined} onClick={() => navigate({ project, level: "thread", thread: row.id })}
|
|
189
|
+
className={cn("flex min-w-0 flex-1 flex-col gap-0.5 rounded-lg px-2 py-1.5 text-left hover:bg-sidebar-accent max-md:py-2.5", open && "bg-sidebar-accent/60")}>
|
|
190
|
+
<span className="flex min-w-0 items-center gap-2">
|
|
191
|
+
{waiting && <span role="img" aria-label="Waiting on you" className="size-1.5 shrink-0 rounded-full bg-primary"/>}
|
|
192
|
+
<span className={cn("min-w-0 flex-1 truncate", (open || waiting) && "font-medium")} title={row.title || row.branch || row.id}>{row.title || row.branch || row.id}</span>
|
|
193
|
+
<span className={cn("shrink-0 text-xs tabular-nums", working ? "text-foreground" : "text-muted-foreground")} title={working ? "Working for " + working : undefined}>
|
|
194
|
+
{working || (row.updatedAt ? elapsed(now - row.updatedAt) : "")}
|
|
195
|
+
</span>
|
|
196
|
+
</span>
|
|
197
|
+
{(row.harnesses.length > 0 || (row.prs?.length || 0) > 0 || row.branch || row.place) && <span className="flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground">
|
|
198
|
+
<span className="flex shrink-0 items-center">{row.harnesses.map(peer => <HarnessMark key={peer} peer={peer} className="size-3.5"/>)}</span>
|
|
199
|
+
<ThreadPlace place={row.place} branch={row.branch} className="flex-1"/>
|
|
200
|
+
{!row.branch && !row.place && <span className="flex-1"/>}
|
|
201
|
+
<PrBadges prs={row.prs}/>
|
|
202
|
+
</span>}
|
|
203
|
+
{busy > 0 && <span className="flex items-center gap-1.5 text-xs text-foreground"><Dot online/>{busy} working</span>}
|
|
204
|
+
</button>
|
|
205
|
+
{act && <ThreadMenu row={row} label={label} act={act} rename={rename} disabled={disabled}/>}
|
|
206
|
+
{sessions.length > 0 && <button type="button" aria-expanded={!shut} aria-label={(shut ? "Show" : "Hide") + " sessions in " + label} onClick={() => setShut(!shut)}
|
|
207
|
+
className="mt-1 grid size-7 shrink-0 place-items-center rounded-md text-muted-foreground hover:bg-sidebar-accent hover:text-foreground max-md:mt-0 max-md:size-11">
|
|
208
|
+
<ChevronDown aria-hidden className={cn("size-3.5 transition-transform motion-reduce:transition-none", shut && "-rotate-90")}/>
|
|
209
|
+
</button>}
|
|
210
|
+
</div>
|
|
211
|
+
{sessions.length > 0 && !shut && <SessionTree sessions={sessions} all={all} label={"Sessions in " + (row.title || row.id)} title={row.title} selected={selected} now={now} open={openRun}
|
|
212
|
+
listen={listen ? { thread: row, set: listen, disabled } : undefined} stop={stop}/>}
|
|
213
|
+
</li>;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** One session outside any thread: glyph, short name, and a waiting or working mark. */
|
|
217
|
+
function SessionItem({ agent, name, selected, now, onOpen }: { agent: Agent; name: string; selected: Selected; now: number; onOpen: () => void }) {
|
|
218
|
+
const state = sessionState(agent, now);
|
|
219
|
+
const current = selected.level === "session" && selected.session === agent.id;
|
|
220
|
+
return <li>
|
|
221
|
+
<button type="button" data-session={agent.id} aria-current={current ? "page" : undefined} onClick={onOpen}
|
|
222
|
+
className={cn("flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-sidebar-accent max-md:py-2", current && "font-medium text-foreground", !current && "text-muted-foreground")}>
|
|
223
|
+
<AgentName address={agent.id} name={name} className="flex-1"/>
|
|
224
|
+
{state === "waiting" || state === "afk" ? <span className="shrink-0 text-xs text-primary">waiting</span>
|
|
225
|
+
: state === "working" ? <span className="shrink-0 text-xs text-foreground">working</span>
|
|
226
|
+
: !isLive(agent, now) && agent.lastMessageAt ? <span className="shrink-0 text-xs">{ago(agent.lastMessageAt, now)}</span> : null}
|
|
227
|
+
</button>
|
|
228
|
+
</li>;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function Group({ id, label, rows, children }: { id: GroupId | "sessions" | "inactive"; label: string; rows: number; children: ReactNode }) {
|
|
232
|
+
// Null until the operator toggles, so a Settled group that grows long once the snapshot lands still starts collapsed.
|
|
233
|
+
const [toggled, setOpen] = useState<boolean | null>(null);
|
|
234
|
+
const open = toggled ?? (!COLLAPSED.includes(id as GroupId) && id !== "inactive" && !(id === "settled" && rows > SETTLED_OPEN));
|
|
235
|
+
if (!rows) return null;
|
|
236
|
+
return <section aria-label={label} data-group={id}>
|
|
237
|
+
<h2>
|
|
238
|
+
<button type="button" aria-expanded={open} onClick={() => setOpen(!open)}
|
|
239
|
+
className="flex w-full items-center gap-1 rounded-sm px-2 py-1 text-left text-xs text-muted-foreground hover:text-foreground max-md:py-2">
|
|
240
|
+
<ChevronRight aria-hidden className={cn("size-3 transition-transform motion-reduce:transition-none", open && "rotate-90")}/>
|
|
241
|
+
<span className={cn(id === "waiting" && "text-primary")}>{label}</span><span className="tabular-nums">{rows}</span>
|
|
242
|
+
</button>
|
|
243
|
+
</h2>
|
|
244
|
+
{open && <ul className="flex flex-col">{children}</ul>}
|
|
245
|
+
</section>;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** The project the sidebar shows: none on Home, in the inbox or in Recent progress. */
|
|
249
|
+
export function sidebarProject(data: Data, selected: Selected) {
|
|
250
|
+
return selected.level === "home" || selected.level === "inbox" || selected.level === "progress" ? "" : selected.project || data.project || "";
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** Opens the Decision inbox; marked current while the inbox is open. */
|
|
254
|
+
function DecisionsButton({ count, current, navigate }: { count: number; current: boolean; navigate: Navigate }) {
|
|
255
|
+
return <button type="button" onClick={() => navigate({ level: "inbox" })} aria-current={current ? "page" : undefined}
|
|
256
|
+
className={cn("flex min-h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-foreground hover:bg-sidebar-accent max-md:hidden", current && "bg-sidebar-accent/60 font-medium")}>
|
|
257
|
+
<Inbox aria-hidden className="size-4 text-muted-foreground"/>
|
|
258
|
+
<span className="flex-1">Decisions</span>
|
|
259
|
+
{count > 0 && <span className="text-xs font-medium tabular-nums text-primary"><span className="sr-only">, </span>{count}<span className="sr-only"> waiting</span></span>}
|
|
260
|
+
</button>;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export type MenuPlacement = { trigger: string; dot: string; side: "top"; align: "start" | "end"; children?: ReactNode };
|
|
264
|
+
|
|
265
|
+
/** The app menu with its Archive inactive confirmation; the sidebar foot and the phone bar each render one. */
|
|
266
|
+
export function SidebarMenu({ placement, ...props }: SidebarProps & { placement?: MenuPlacement }) {
|
|
267
|
+
const current = sidebarProject(props.data, props.selected);
|
|
268
|
+
const inactive = inactiveThreads(current ? props.data.threads || [] : [], props.data.agents || [], props.now);
|
|
269
|
+
const [archiving, setArchiving] = useState<string[]>([]);
|
|
270
|
+
return <>
|
|
271
|
+
<AppMenu {...props} placement={placement} current={current} inactive={inactive.length}
|
|
272
|
+
askArchive={props.archiveThreads && current ? () => setArchiving(inactive.map(thread => thread.id)) : undefined}/>
|
|
273
|
+
<ArchiveInactiveDialog ids={archiving} close={() => setArchiving([])} archive={props.archiveThreads}/>
|
|
274
|
+
</>;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** The app menu: project views, decisions, schedules, harness lessons, the project's pause switch, theme and account. */
|
|
278
|
+
function AppMenu({ data, current, navigate, counts, decisions, pause, openSchedules, openLessons, projectAction, signOut, account, disabled, ready, inactive, askArchive, placement }: SidebarProps & { current: string; inactive: number; askArchive?: () => void; placement?: MenuPlacement }) {
|
|
279
|
+
const { theme, setTheme } = useTheme();
|
|
280
|
+
const project = data.projects.find(item => item.id === current);
|
|
281
|
+
const managed = Boolean(current) && !data.autoProjects?.includes(current);
|
|
282
|
+
return <Menu presentation="auto">
|
|
283
|
+
<MenuTrigger aria-label="Menu" className={placement?.trigger || "flex min-h-9 items-center gap-1.5 rounded-md px-2 text-sm text-muted-foreground hover:bg-sidebar-accent hover:text-foreground data-open:bg-sidebar-accent max-md:min-h-11"}>
|
|
284
|
+
{placement?.children || <><Settings2 aria-hidden className="size-4"/>Menu</>}
|
|
285
|
+
{(decisions > 0 || counts.waiting > 0) && <span className={cn("size-1.5 rounded-full bg-primary", placement?.dot)} role="img" aria-label="Decisions wait on you"/>}
|
|
286
|
+
</MenuTrigger>
|
|
287
|
+
<MenuContent side={placement?.side || "top"} align={placement?.align || "start"} className={cn(MENU, "max-h-(--available-height) overflow-y-auto")}>
|
|
288
|
+
<MenuItem className={ITEM} onSelect={() => navigate({ level: "inbox" })}>
|
|
289
|
+
<span className="flex-1">Decision inbox</span>{decisions > 0 && <span className="text-xs font-medium text-primary">{decisions}</span>}
|
|
290
|
+
</MenuItem>
|
|
291
|
+
<MenuItem className={ITEM} onSelect={() => navigate({ level: "progress" })}><span className="flex-1">Recent progress</span></MenuItem>
|
|
292
|
+
{current && <MenuGroup>
|
|
293
|
+
<MenuGroupLabel className={LABEL}>{current}</MenuGroupLabel>
|
|
294
|
+
<MenuItem className={ITEM} onSelect={() => navigate({ project: current, level: "project" })}><span className="flex-1">Project chat</span></MenuItem>
|
|
295
|
+
<MenuItem className={ITEM} onSelect={() => navigate({ project: current, level: "tasks" })}>
|
|
296
|
+
<span className="flex-1">Tasks</span>
|
|
297
|
+
{counts.waiting > 0 ? <span className="text-xs font-medium text-primary">{counts.waiting} to decide</span> : counts.tasks > 0 && <span className="text-xs text-muted-foreground">{counts.tasks}</span>}
|
|
298
|
+
</MenuItem>
|
|
299
|
+
<MenuItem className={ITEM} onSelect={() => navigate({ project: current, level: "patterns" })}>
|
|
300
|
+
<span className="flex-1">Teams</span>{counts.patterns > 0 && <span className="text-xs text-muted-foreground">{counts.patterns}</span>}
|
|
301
|
+
</MenuItem>
|
|
302
|
+
<MenuItem className={ITEM} onSelect={() => navigate({ project: current, level: "session" })}><span className="flex-1">All sessions</span></MenuItem>
|
|
303
|
+
<MenuItem className={ITEM} onSelect={() => navigate({ project: current, level: "compactions" })}><span className="flex-1">History</span></MenuItem>
|
|
304
|
+
{askArchive && <MenuItem className={ITEM} disabled={disabled || inactive === 0} onSelect={askArchive}>
|
|
305
|
+
<span className="flex-1">Archive inactive…</span><span className="text-xs text-muted-foreground tabular-nums">{inactive}</span>
|
|
306
|
+
</MenuItem>}
|
|
307
|
+
{ready && !data.hosted && <MenuItem className={ITEM} disabled={disabled} onSelect={pause}>
|
|
308
|
+
<span className="flex-1">{project?.paused ? "Resume new work" : "Pause new work"}</span>
|
|
309
|
+
{project?.paused && <span className="text-xs text-muted-foreground">paused</span>}
|
|
310
|
+
</MenuItem>}
|
|
311
|
+
{managed && <MenuSub>
|
|
312
|
+
<MenuSubTrigger className={ITEM}><span className="flex-1">Project actions</span><ChevronRight aria-hidden className="size-3.5"/></MenuSubTrigger>
|
|
313
|
+
<MenuSubContent className={MENU}>
|
|
314
|
+
<MenuItem className={ITEM} onSelect={() => projectAction("request-outcome", current)}>Request an outcome</MenuItem>
|
|
315
|
+
<MenuItem className={ITEM} onSelect={() => projectAction("close", current)}>Close project</MenuItem>
|
|
316
|
+
<MenuItem className={cn(ITEM, "text-destructive")} onSelect={() => projectAction("delete", current)}>Delete project</MenuItem>
|
|
317
|
+
</MenuSubContent>
|
|
318
|
+
</MenuSub>}
|
|
319
|
+
</MenuGroup>}
|
|
320
|
+
<MenuSeparator className={SEP}/>
|
|
321
|
+
<MenuItem className={ITEM} onSelect={openSchedules}><span className="flex-1">Scheduled jobs</span></MenuItem>
|
|
322
|
+
{openLessons && <MenuItem className={ITEM} onSelect={openLessons}><span className="flex-1">Harness lessons</span></MenuItem>}
|
|
323
|
+
{(data.closedProjects?.length || 0) > 0 && <MenuSub>
|
|
324
|
+
<MenuSubTrigger className={ITEM}><span className="flex-1">Closed projects</span><span className="text-xs text-muted-foreground">{data.closedProjects?.length}</span><ChevronRight aria-hidden className="size-3.5"/></MenuSubTrigger>
|
|
325
|
+
<MenuSubContent className={MENU}>
|
|
326
|
+
<MenuGroup>
|
|
327
|
+
<MenuGroupLabel className={LABEL}>Reopen</MenuGroupLabel>
|
|
328
|
+
{data.closedProjects?.map(name => <MenuItem key={name} className={ITEM} onSelect={() => projectAction("reopen", name)}><span className="break-all">{name}</span></MenuItem>)}
|
|
329
|
+
</MenuGroup>
|
|
330
|
+
</MenuSubContent>
|
|
331
|
+
</MenuSub>}
|
|
332
|
+
<MenuSub>
|
|
333
|
+
<MenuSubTrigger className={ITEM}><span className="flex-1">Theme</span><span className="text-xs text-muted-foreground">{theme}</span><ChevronRight aria-hidden className="size-3.5"/></MenuSubTrigger>
|
|
334
|
+
<MenuSubContent className={MENU}>
|
|
335
|
+
<MenuRadioGroup value={theme} onValueChange={(next: unknown) => { if (typeof next === "string") setTheme(next); }}>
|
|
336
|
+
{THEMES.map(([id, label]) => <MenuRadioItem key={id} value={id} className={ITEM}>
|
|
337
|
+
<span className="flex-1">{label}</span><MenuItemIndicator><Check aria-hidden className="size-3.5"/></MenuItemIndicator>
|
|
338
|
+
</MenuRadioItem>)}
|
|
339
|
+
</MenuRadioGroup>
|
|
340
|
+
</MenuSubContent>
|
|
341
|
+
</MenuSub>
|
|
342
|
+
{account && signOut && <>
|
|
343
|
+
<MenuSeparator className={SEP}/>
|
|
344
|
+
<MenuGroup>
|
|
345
|
+
<MenuGroupLabel className={LABEL}>Signed in as {account}</MenuGroupLabel>
|
|
346
|
+
<MenuItem className={ITEM} onSelect={signOut}>Sign out</MenuItem>
|
|
347
|
+
</MenuGroup>
|
|
348
|
+
</>}
|
|
349
|
+
</MenuContent>
|
|
350
|
+
</Menu>;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export function ThreadSidebar(props: SidebarProps) {
|
|
354
|
+
const { data, selected, now, navigate, newThread, disabled, controls } = props;
|
|
355
|
+
const home = selected.level === "home" || selected.level === "inbox" || selected.level === "progress";
|
|
356
|
+
const current = sidebarProject(data, selected);
|
|
357
|
+
const all = home ? [] : data.agents || [];
|
|
358
|
+
const agents = all.filter(agent => !agent.gone);
|
|
359
|
+
const threads = home ? [] : data.threads || [];
|
|
360
|
+
const groups = threadGroups(threads, all, now);
|
|
361
|
+
const loose = unthreaded(agents, threads);
|
|
362
|
+
const live = loose.filter(agent => isLive(agent, now) || agent.online);
|
|
363
|
+
const idle = loose.filter(agent => !(isLive(agent, now) || agent.online));
|
|
364
|
+
const paused = data.projects.some(item => item.id === current && item.paused);
|
|
365
|
+
const [renaming, setRenaming] = useState<ThreadRow | null>(null);
|
|
366
|
+
const sessionRow = (agent: Agent) => <SessionItem key={agent.id} agent={agent} name={shortName(agent)} selected={selected} now={now}
|
|
367
|
+
onOpen={() => navigate({ project: current, level: "session", harness: agent.peer || agent.id.split("#")[0], session: agent.id })}/>;
|
|
368
|
+
return <div className="flex h-full min-h-0 flex-col">
|
|
369
|
+
<header className="flex flex-col gap-1 px-2 pb-2 pt-3">
|
|
370
|
+
<div className="flex min-h-9 items-center gap-2 px-1">
|
|
371
|
+
<Wordmark current={selected.level === "home"} navigate={navigate}/>
|
|
372
|
+
{/* The deploy banner ("deployed: <branch>") renders into this slot. */}
|
|
373
|
+
<div data-slot="deploy-banner" className="min-w-0 flex-1 truncate text-right text-xs text-muted-foreground empty:hidden"/>
|
|
374
|
+
</div>
|
|
375
|
+
<ProjectSwitcher data={data} current={current} navigate={navigate}/>
|
|
376
|
+
<DecisionsButton count={props.decisions} current={selected.level === "inbox"} navigate={navigate}/>
|
|
377
|
+
</header>
|
|
378
|
+
{!home && current && <TasksStrip tasks={data.tasks?.tasks || []} openTask={id => navigate({ project: current, level: "tasks", task: id })}
|
|
379
|
+
openBoard={props.openTasks || (() => navigate({ project: current, level: "tasks" }))}/>}
|
|
380
|
+
{current && <div className="px-2 pb-2">
|
|
381
|
+
<button type="button" aria-label={"New thread in " + current} onClick={() => newThread(current)} disabled={disabled || paused} title={paused ? "New work is paused" : undefined}
|
|
382
|
+
className="flex min-h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-foreground hover:bg-sidebar-accent disabled:opacity-50 max-md:min-h-11">
|
|
383
|
+
<Plus aria-hidden className="size-4 text-muted-foreground"/>New thread
|
|
384
|
+
</button>
|
|
385
|
+
<button type="button" onClick={() => navigate({ project: current, level: "project" })} aria-current={selected.level === "project" ? "page" : undefined}
|
|
386
|
+
className={cn("flex min-h-9 w-full items-center gap-2 rounded-md px-2 text-left text-sm text-foreground hover:bg-sidebar-accent max-md:min-h-11", selected.level === "project" && "bg-sidebar-accent/60")}>
|
|
387
|
+
<MessagesSquare aria-hidden className="size-4 text-muted-foreground"/>Project chat
|
|
388
|
+
</button>
|
|
389
|
+
</div>}
|
|
390
|
+
<nav aria-label="Threads" className="flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-2 pb-3">
|
|
391
|
+
{home ? <ul className="flex flex-col">
|
|
392
|
+
{data.projects.map(project => <li key={project.id}>
|
|
393
|
+
<button type="button" onClick={() => navigate({ project: project.id, level: "project" })}
|
|
394
|
+
className="flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-sidebar-accent max-md:py-2.5">
|
|
395
|
+
<span className="min-w-0 flex-1 break-all">{project.id}</span>
|
|
396
|
+
{(project.waiting || 0) > 0 && <span className="shrink-0 text-xs font-medium text-primary">{project.waiting} waiting</span>}
|
|
397
|
+
{project.paused && <span className="shrink-0 text-xs text-muted-foreground">paused</span>}
|
|
398
|
+
</button>
|
|
399
|
+
</li>)}
|
|
400
|
+
</ul> : <>
|
|
401
|
+
{GROUPS.map(([id, label]) => <Group key={id} id={id} label={label} rows={groups[id].length}>
|
|
402
|
+
{groups[id].map(row => <ThreadItem key={row.id} row={row} all={all} selected={selected} now={now} navigate={navigate} project={current} listen={props.listen} disabled={disabled}
|
|
403
|
+
act={props.threadAction} rename={setRenaming} stop={props.stop}/>)}
|
|
404
|
+
</Group>)}
|
|
405
|
+
<Group id="sessions" label={threads.length ? "Sessions outside threads" : "Sessions"} rows={live.length}>{live.map(sessionRow)}</Group>
|
|
406
|
+
<Group id="inactive" label="Inactive sessions" rows={idle.length}>{idle.map(sessionRow)}</Group>
|
|
407
|
+
{threads.length + loose.length === 0 && <p className="px-2 py-4 text-sm text-muted-foreground">No threads yet. Start one with New thread.</p>}
|
|
408
|
+
</>}
|
|
409
|
+
</nav>
|
|
410
|
+
<footer className="flex items-center gap-1 px-2 py-1.5 shadow-[0_-1px_0_var(--sidebar-border)]">
|
|
411
|
+
{/* Below md the bottom bar carries Menu. */}
|
|
412
|
+
<div className="max-md:hidden"><SidebarMenu {...props}/></div>
|
|
413
|
+
<span className="flex-1"/>
|
|
414
|
+
{controls}
|
|
415
|
+
</footer>
|
|
416
|
+
<RenameDialog thread={renaming} close={() => setRenaming(null)} act={props.threadAction}/>
|
|
417
|
+
</div>;
|
|
418
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// The phone header's agent switcher: jump to another agent of the open thread without going back to the list.
|
|
3
|
+
import { ChevronsUpDown } from "lucide-react";
|
|
4
|
+
import { Menu, MenuContent, MenuItem, MenuTrigger } from "@ui-sdk/react/menu";
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
import { shortName, type Agent, type Thread } from "@/lib/thread-groups";
|
|
7
|
+
|
|
8
|
+
const ITEM = "flex min-h-11 cursor-pointer items-center gap-2 rounded-md px-2 focus-visible:-outline-offset-2 data-highlighted:bg-accent";
|
|
9
|
+
|
|
10
|
+
export function ThreadSwitcher({ thread, agents, current, open }: { thread?: Thread; agents: Agent[]; current?: string; open: (session: string) => void }) {
|
|
11
|
+
const byId = new Map(agents.map(agent => [agent.id, agent]));
|
|
12
|
+
const shown = (thread?.sessions || []).map(id => byId.get(id)).filter((agent): agent is Agent => Boolean(agent && !agent.gone));
|
|
13
|
+
if (shown.length < 2) return null;
|
|
14
|
+
return <Menu presentation="auto">
|
|
15
|
+
<MenuTrigger aria-label="Switch agent" title="Switch agent in this thread"
|
|
16
|
+
className="grid size-11 shrink-0 place-items-center rounded-lg text-muted-foreground hover:bg-accent hover:text-foreground data-open:bg-accent md:hidden">
|
|
17
|
+
<ChevronsUpDown aria-hidden className="size-4"/>
|
|
18
|
+
</MenuTrigger>
|
|
19
|
+
<MenuContent align="end" className="z-50 max-h-(--available-height) w-72 max-w-[calc(100vw-1rem)] overflow-y-auto rounded-xl bg-popover p-1 text-sm text-popover-foreground shadow-raised outline-none">
|
|
20
|
+
{shown.map(agent => <MenuItem key={agent.id} className={cn(ITEM, agent.id === current && "font-medium text-primary")}
|
|
21
|
+
onSelect={() => open(agent.id)}>
|
|
22
|
+
<span className="min-w-0 flex-1 truncate">{shortName(agent, thread?.title) || agent.id}</span>
|
|
23
|
+
<span className="shrink-0 text-xs text-muted-foreground">{agent.peer || agent.id.split("#")[0]}</span>
|
|
24
|
+
</MenuItem>)}
|
|
25
|
+
</MenuContent>
|
|
26
|
+
</Menu>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Component, lazy, Suspense, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { ChevronRight } from "lucide-react";
|
|
4
|
+
import { useTheme } from "next-themes";
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
import { limitFiles, patchOf } from "@/lib/tool-diff";
|
|
7
|
+
|
|
8
|
+
// @pierre/diffs loads on first use: its highlighter and styles stay out of the first page load.
|
|
9
|
+
const PatchDiff = lazy(() => import("@pierre/diffs/react").then(mod => ({ default: mod.PatchDiff })));
|
|
10
|
+
const WIDE = "(min-width: 768px)";
|
|
11
|
+
const THEME = { dark: "github-dark", light: "github-light" };
|
|
12
|
+
const BASE = { overflow: "wrap", disableFileHeader: true, disableLineNumbers: true, theme: THEME };
|
|
13
|
+
|
|
14
|
+
const optionsOf = (diffStyle, themeType) => ({ ...BASE, diffStyle, themeType });
|
|
15
|
+
const noteOf = file => file.kind === "delete" ? "File deleted; its content is not in the tool input." : file.notes.join(" · ") || "No changes.";
|
|
16
|
+
|
|
17
|
+
// Shows the fallback when its child throws, such as a failed chunk load.
|
|
18
|
+
class DiffBoundary extends Component {
|
|
19
|
+
constructor(props) {
|
|
20
|
+
super(props);
|
|
21
|
+
this.state = { failed: false };
|
|
22
|
+
}
|
|
23
|
+
static getDerivedStateFromError() {
|
|
24
|
+
return { failed: true };
|
|
25
|
+
}
|
|
26
|
+
render() {
|
|
27
|
+
return this.state.failed ? this.props.fallback : this.props.children;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Split from 768px up, unified below; the view follows the window width.
|
|
32
|
+
function useWide() {
|
|
33
|
+
const [wide, setWide] = useState(false);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const query = window.matchMedia(WIDE);
|
|
36
|
+
const sync = () => setWide(query.matches);
|
|
37
|
+
sync();
|
|
38
|
+
query.addEventListener("change", sync);
|
|
39
|
+
return () => query.removeEventListener("change", sync);
|
|
40
|
+
}, []);
|
|
41
|
+
return wide;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function Counts({ added, removed, className }) {
|
|
45
|
+
return <span className={cn("shrink-0 font-mono", className)}>
|
|
46
|
+
<span className="text-emerald-700 dark:text-emerald-400">+{added}</span>{" "}
|
|
47
|
+
<span className="text-red-600 dark:text-red-400">−{removed}</span>
|
|
48
|
+
</span>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function FileDiff({ file, options }) {
|
|
52
|
+
const patch = patchOf(file);
|
|
53
|
+
const label = file.written ? "written" : file.kind === "add" ? "added" : file.kind === "delete" ? "deleted" : "";
|
|
54
|
+
const plain = <pre className="overflow-x-auto px-2.5 py-1.5 font-mono">{patch}</pre>;
|
|
55
|
+
return <details open className="group min-w-0 overflow-hidden rounded-lg border bg-card text-xs">
|
|
56
|
+
<summary className="flex cursor-pointer list-none items-center gap-2 border-b px-2.5 py-1.5 [&::-webkit-details-marker]:hidden">
|
|
57
|
+
<ChevronRight className="size-3.5 shrink-0 text-muted-foreground transition-transform group-open:rotate-90"/>
|
|
58
|
+
<span className="min-w-0 flex-1 truncate font-mono">{file.path}</span>
|
|
59
|
+
{label && <span className="shrink-0 text-muted-foreground">{label}</span>}
|
|
60
|
+
<Counts added={file.added} removed={file.removed}/>
|
|
61
|
+
</summary>
|
|
62
|
+
{file.hunks.length
|
|
63
|
+
? <>
|
|
64
|
+
{file.notes.length > 0 && <p className="border-b px-2.5 py-1 text-muted-foreground">{file.notes.join(" · ")}</p>}
|
|
65
|
+
<DiffBoundary fallback={plain}>
|
|
66
|
+
<Suspense fallback={plain}>
|
|
67
|
+
<div className="min-w-0 [&_pre]:text-xs">
|
|
68
|
+
<PatchDiff patch={patch} options={options} disableWorkerPool/>
|
|
69
|
+
</div>
|
|
70
|
+
</Suspense>
|
|
71
|
+
</DiffBoundary>
|
|
72
|
+
</>
|
|
73
|
+
: <p className="px-2.5 py-1.5 text-muted-foreground">{noteOf(file)}</p>}
|
|
74
|
+
</details>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** File diffs of one tool call: each file's path and +/- counts over its diff; more than DIFF_MAX_LINES lines wait behind "Show all". */
|
|
78
|
+
export function ToolDiff({ files, truncated = false }) {
|
|
79
|
+
const [all, setAll] = useState(false);
|
|
80
|
+
const wide = useWide();
|
|
81
|
+
const { resolvedTheme } = useTheme();
|
|
82
|
+
const options = useMemo(() => optionsOf(wide ? "split" : "unified", resolvedTheme === "light" ? "light" : "dark"), [wide, resolvedTheme]);
|
|
83
|
+
const { files: shown, hidden } = all ? { files, hidden: 0 } : limitFiles(files);
|
|
84
|
+
return <div className="flex min-w-0 flex-col gap-2">
|
|
85
|
+
{truncated && <p className="text-xs text-muted-foreground">Input truncated; the diff shows the part kept.</p>}
|
|
86
|
+
{shown.map((file, i) => <FileDiff key={file.path + i} file={file} options={options}/>)}
|
|
87
|
+
{hidden > 0 && <button type="button" onClick={() => setAll(true)}
|
|
88
|
+
className="self-start rounded-md border px-2.5 py-1 text-xs font-medium text-primary hover:bg-accent">
|
|
89
|
+
Show all · {hidden} more lines
|
|
90
|
+
</button>}
|
|
91
|
+
</div>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { Counts };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createComponentImplementation } from "@a2ui/react/v0_9";
|
|
3
|
+
import { basicCatalog } from "@a2ui/web_core/v0_9/basic_catalog";
|
|
4
|
+
import { Badge } from "@/components/ui/badge";
|
|
5
|
+
import { Button } from "@/components/ui/button";
|
|
6
|
+
import { ChipApi } from "@/lib/a2ui-catalog";
|
|
7
|
+
import { cn } from "@/lib/utils";
|
|
8
|
+
|
|
9
|
+
// Button, TextField and Chip render with the app's components; the schemas stay the basic catalog's, so answers and checks are unchanged.
|
|
10
|
+
const VARIANT = { primary: "default", default: "outline", borderless: "ghost" };
|
|
11
|
+
// The child Text paints with the surface color; inside a button it takes the button's foreground.
|
|
12
|
+
const ON_BUTTON = { "--a2ui-color-on-surface": "currentColor", "--a2ui-color-on-background": "currentColor" };
|
|
13
|
+
|
|
14
|
+
/** A button: primary, outlined or ghost; disabled while its checks fail. */
|
|
15
|
+
export const ButtonImpl = createComponentImplementation(basicCatalog.components.get("Button"), ({ props, buildChild }) => {
|
|
16
|
+
const disabled = props.isValid === false;
|
|
17
|
+
return <Button type="button" size="sm" variant={VARIANT[props.variant ?? "default"]} disabled={disabled} onClick={() => props.action?.()}
|
|
18
|
+
style={ON_BUTTON} className="h-11 rounded-md px-4 disabled:opacity-50 sm:h-8 sm:px-3.5 [&_*]:text-inherit">
|
|
19
|
+
{props.child && buildChild(props.child)}
|
|
20
|
+
</Button>;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/** A single-line text field; its label is the placeholder, as the Other row shows it. */
|
|
24
|
+
export const TextFieldImpl = createComponentImplementation(basicCatalog.components.get("TextField"), ({ props }) => {
|
|
25
|
+
return <input type="text" aria-label={props.label || "Answer"} placeholder={props.label} value={props.value ?? ""}
|
|
26
|
+
onChange={event => props.setValue?.(event.target.value)}
|
|
27
|
+
className={cn("h-11 w-full min-w-0 rounded-lg border border-input bg-background px-3 text-base text-foreground sm:h-9 sm:text-sm outline-none placeholder:text-muted-foreground",
|
|
28
|
+
"focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring")}/>;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/** A short tag: a question's header, or a status; accent marks something the agent waits on, danger a failure. */
|
|
32
|
+
export const ChipImpl = createComponentImplementation(ChipApi, ({ props }) => {
|
|
33
|
+
return <Badge variant={props.tone === "muted" ? "outline" : "secondary"}
|
|
34
|
+
className={cn("h-5 max-w-full px-2 text-xs font-medium", props.tone === "accent" ? "border-primary/40 bg-primary/10 text-primary"
|
|
35
|
+
: props.tone === "danger" ? "bg-destructive/10 text-destructive dark:bg-destructive/20" : "text-muted-foreground")}>{props.text}</Badge>;
|
|
36
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createComponentImplementation } from "@a2ui/react/v0_9";
|
|
3
|
+
import { ChoiceList, ChoiceSummary } from "@/components/ui/choice-list";
|
|
4
|
+
import { OptionPickerApi } from "@/lib/a2ui-catalog";
|
|
5
|
+
|
|
6
|
+
/** The question and its options as full-row radios, or checkboxes when multiSelect, then the Other field; a summary once closed. */
|
|
7
|
+
export const OptionPicker = createComponentImplementation(OptionPickerApi, ({ props, buildChild }) => {
|
|
8
|
+
const picked = props.value ?? [];
|
|
9
|
+
if (props.readOnly === true) {
|
|
10
|
+
return <ChoiceSummary question={props.label} chosen={props.options.filter(option => picked.includes(option.label)).map(option => option.label)}/>;
|
|
11
|
+
}
|
|
12
|
+
// Picking an option clears a typed Other answer in single-select, as the chat card does.
|
|
13
|
+
function choose(next) {
|
|
14
|
+
props.setValue?.(next);
|
|
15
|
+
if (props.multiSelect !== true) props.setOther?.("");
|
|
16
|
+
}
|
|
17
|
+
return <ChoiceList question={props.label} options={props.options} multiSelect={props.multiSelect === true} value={picked} onValueChange={choose}>
|
|
18
|
+
{props.otherChild && <label className="flex min-w-0 flex-col gap-1 pt-0.5">
|
|
19
|
+
<span className="text-xs text-muted-foreground">Or write your own answer</span>
|
|
20
|
+
{buildChild(props.otherChild)}
|
|
21
|
+
</label>}
|
|
22
|
+
</ChoiceList>;
|
|
23
|
+
});
|