@temmo/cli 0.0.0 → 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 +112 -1
- 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,691 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// The console shell: hash routing, the header for each level, the streamed screen (via useStream),
|
|
3
|
+
// pull-to-refresh, scroll memory, and the wiring from every action to its /api call.
|
|
4
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { CircleStop, CornerLeftUp, ListTodo, PanelRight, Plus, RotateCw, UserPlus } from "lucide-react";
|
|
6
|
+
import { ThreadPrimitive, getExternalStoreMessages } from "@assistant-ui/react";
|
|
7
|
+
import { Badge } from "@/components/ui/badge";
|
|
8
|
+
import { Button } from "@/components/ui/button";
|
|
9
|
+
import { ChatContainerContent, ChatContainerRoot, ChatContainerScrollAnchor } from "@/components/ui/chat-container";
|
|
10
|
+
import { ScrollButton } from "@/components/ui/scroll-button";
|
|
11
|
+
import { Sheet, SheetContent, SheetDescription, SheetTitle } from "@/components/ui/sheet";
|
|
12
|
+
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
|
13
|
+
import { cn } from "@/lib/utils";
|
|
14
|
+
import { contextMeter, filesRead } from "@/lib/context-view";
|
|
15
|
+
import { agentDetail } from "@/lib/agent-detail";
|
|
16
|
+
import { chatThread, subagentThread } from "@/lib/chat-turns";
|
|
17
|
+
import { NewAgentComposer } from "./new-session";
|
|
18
|
+
import { PatternsPage } from "./patterns-page";
|
|
19
|
+
import { LandReviews } from "./land-reviews";
|
|
20
|
+
import { DeployedBanner, Land } from "./land-panel";
|
|
21
|
+
import { OutcomeRequest } from "./outcomes";
|
|
22
|
+
import { TaskBoard } from "./tasks";
|
|
23
|
+
import { liveRows, projectThread, sessionTurns, withoutAnswered } from "@/lib/project-feed";
|
|
24
|
+
import { projectViewCounts, selectionHash } from "@/lib/selection";
|
|
25
|
+
import { agentName } from "@/lib/sidebar";
|
|
26
|
+
import { canStop, sessionState } from "@/lib/session-state";
|
|
27
|
+
import { modeCommand } from "@/lib/approval-mode";
|
|
28
|
+
import { ActivityRow, Working } from "./activity";
|
|
29
|
+
import { RunRequests } from "./run-requests";
|
|
30
|
+
import { SurfaceContext } from "@/components/a2ui/surface";
|
|
31
|
+
import { NotifyToggle } from "./notify";
|
|
32
|
+
import { DecisionQueue } from "./decisions";
|
|
33
|
+
import { ProgressFeed } from "./progress-feed";
|
|
34
|
+
import { SessionList, SessionMenu, StateChip, SubagentList } from "./home";
|
|
35
|
+
import { RunningCount } from "./subagent-runs";
|
|
36
|
+
import { Shipped } from "./shipped";
|
|
37
|
+
import { CompactionMap } from "./compactions";
|
|
38
|
+
import { activityRows, groupSubagents, subagentLabel } from "@/lib/activity-rows";
|
|
39
|
+
import { conversationKey, views } from "@/lib/view-memory";
|
|
40
|
+
import { ChatRuntimeProvider } from "@/components/chat/thread";
|
|
41
|
+
import { ago, peerOf, seatOf, short } from "./chat-shared";
|
|
42
|
+
import { api, selection, signOut, streamOf } from "./chat-api";
|
|
43
|
+
import { useStream } from "./chat-stream";
|
|
44
|
+
import { AfkToggle } from "./chat-sidebar";
|
|
45
|
+
import { ThreadSidebar } from "./thread-sidebar";
|
|
46
|
+
import { PhoneNav } from "./phone-nav";
|
|
47
|
+
import { SessionPanel } from "./session-panel";
|
|
48
|
+
import { ThreadSwitcher } from "./thread-switcher";
|
|
49
|
+
import { ThreadAgents } from "./thread-agents";
|
|
50
|
+
import { ThreadPlace } from "./thread-place";
|
|
51
|
+
import { AgentName } from "./agent-mark";
|
|
52
|
+
import { ScheduledJobs } from "./scheduled";
|
|
53
|
+
import { HarnessLessons } from "./lessons";
|
|
54
|
+
import { shortName } from "@/lib/thread-groups";
|
|
55
|
+
import { ChatMessage, CompletionRow, LiveRow, QueueRow } from "./chat-message";
|
|
56
|
+
import { Composer, modelsOf, useModels } from "./chat-composer";
|
|
57
|
+
|
|
58
|
+
const PULL_THRESHOLD_PX = 70;
|
|
59
|
+
const PULL_MAX_PX = 110;
|
|
60
|
+
const TICK_MS = 1000;
|
|
61
|
+
// The composer's runtime only sends; the thread list has its own runtime.
|
|
62
|
+
const NO_ENTRIES = [];
|
|
63
|
+
// The panel tabs a session hash can name; "activity" alone means the chat with no panel.
|
|
64
|
+
const PANEL = ["diff", "pr", "subagents", "tasks", "raw"];
|
|
65
|
+
const WIDE = "(min-width: 768px)";
|
|
66
|
+
|
|
67
|
+
// The session's context: tokens used (with the window and a warning when the harness reported one) and its files.
|
|
68
|
+
// The runner stops a turn of any harness it holds; outside it only a live Codex or OpenCode session takes one.
|
|
69
|
+
function stoppable(agent) {
|
|
70
|
+
return agent.runnerStatus === "running" || (agent.online && ["codex", "opencode"].includes(agent.peer));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function ContextChip({ context, rows }) {
|
|
74
|
+
const meter = contextMeter(context);
|
|
75
|
+
const loaded = context.files || [];
|
|
76
|
+
const read = filesRead(rows);
|
|
77
|
+
const tone = meter.level === "full" ? "border-destructive text-destructive" : meter.level === "warn" ? "border-primary text-primary" : "text-muted-foreground";
|
|
78
|
+
const warning = meter.level === "full" ? " · full" : meter.level === "warn" ? " · near full" : "";
|
|
79
|
+
const [open, setOpen] = useState(false);
|
|
80
|
+
// A sheet fits any phone width; a popover anchored to the chip ran off the left edge at 390px.
|
|
81
|
+
return <>
|
|
82
|
+
<button type="button" aria-haspopup="dialog" aria-expanded={open} onClick={() => setOpen(true)}
|
|
83
|
+
className={cn("flex items-center gap-1 rounded-md border px-2.5 py-1 text-xs", tone)}>
|
|
84
|
+
Context{meter.text && " " + meter.text}{warning}</button>
|
|
85
|
+
<Sheet open={open} onOpenChange={setOpen}>
|
|
86
|
+
<SheetContent side="bottom" className="max-h-[80vh] overflow-y-auto break-words p-0">
|
|
87
|
+
<div className="flex flex-col gap-3 px-4 pb-6 pt-4 text-xs">
|
|
88
|
+
<SheetTitle className="text-base">Context</SheetTitle>
|
|
89
|
+
<SheetDescription className="text-xs">{meter.text ? "Tokens in context: " + meter.text : "No usage reported yet."}</SheetDescription>
|
|
90
|
+
<p className="font-medium">Files in context</p>
|
|
91
|
+
{loaded.length ? <ul className="flex flex-col gap-1.5">{loaded.map(entry => <li key={entry.path} className="min-w-0 break-all font-mono" title={entry.path}>{entry.path}
|
|
92
|
+
<span className="block text-muted-foreground">{entry.memory} · {entry.load.replace(/_/g, " ")}</span></li>)}</ul>
|
|
93
|
+
: <p className="text-muted-foreground">None recorded. Claude reports them through its InstructionsLoaded hook.</p>}
|
|
94
|
+
{/* Shown only once activity rows have loaded; before that, no reads are known, so the section stays out. */}
|
|
95
|
+
{rows.length > 0 && <>
|
|
96
|
+
<p className="font-medium">Files read</p>
|
|
97
|
+
{read.length ? <ul className="flex flex-col gap-1.5">{read.map(entry => <li key={entry.path} className="min-w-0 break-all font-mono" title={entry.path}>{entry.path}
|
|
98
|
+
<span className="text-muted-foreground"> · {entry.count}×</span></li>)}</ul>
|
|
99
|
+
: <p className="text-muted-foreground">No file reads in the loaded activity.</p>}
|
|
100
|
+
</>}
|
|
101
|
+
</div>
|
|
102
|
+
</SheetContent>
|
|
103
|
+
</Sheet>
|
|
104
|
+
</>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** True from md up, where the sidebar, chat and panel sit side by side. */
|
|
108
|
+
function useWide() {
|
|
109
|
+
const [wide, setWide] = useState(true);
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const query = window.matchMedia(WIDE);
|
|
112
|
+
const sync = () => setWide(query.matches);
|
|
113
|
+
sync();
|
|
114
|
+
query.addEventListener("change", sync);
|
|
115
|
+
return () => query.removeEventListener("change", sync);
|
|
116
|
+
}, []);
|
|
117
|
+
return wide;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function Console({ account }) {
|
|
121
|
+
const [selected, setSelected] = useState(selection);
|
|
122
|
+
const stick = useRef(null);
|
|
123
|
+
const [pull, setPull] = useState(0);
|
|
124
|
+
const pullFrom = useRef(null);
|
|
125
|
+
const pullRef = useRef(0);
|
|
126
|
+
const [pullSide, setPullSide] = useState("top");
|
|
127
|
+
const [outcomeProject, setOutcomeProject] = useState("");
|
|
128
|
+
const [outcomeError, setOutcomeError] = useState("");
|
|
129
|
+
// A deep link lands on its content; the header back button opens the thread list.
|
|
130
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
131
|
+
const [schedulesOpen, setSchedulesOpen] = useState(false);
|
|
132
|
+
const [lessonsOpen, setLessonsOpen] = useState(false);
|
|
133
|
+
const wide = useWide();
|
|
134
|
+
const [notice, setNotice] = useState("");
|
|
135
|
+
const [replyTo, setReplyTo] = useState(null);
|
|
136
|
+
const [creating, setCreating] = useState("");
|
|
137
|
+
// The selection the new-agent composer opened from; closing it goes back there.
|
|
138
|
+
const composeFrom = useRef(null);
|
|
139
|
+
// The thread a new agent joins; "" starts a new thread.
|
|
140
|
+
const [startThread, setStartThread] = useState("");
|
|
141
|
+
const [working, setWorking] = useState(false);
|
|
142
|
+
const latestAction = useRef(0);
|
|
143
|
+
const [now, setNow] = useState(Date.now);
|
|
144
|
+
const route = useRef("");
|
|
145
|
+
// The runtime's onNew bridge: the Composer registers its send handler here, so the primitive owns the
|
|
146
|
+
// input state while the console keeps the send path (urgent, command, image flags live in the Composer).
|
|
147
|
+
const sendBridgeRef = useRef(null);
|
|
148
|
+
const { home, watching, subagents, inline, raw, listing, tasks, compactions, requested } = streamOf(selected);
|
|
149
|
+
route.current = requested;
|
|
150
|
+
// The live stream owns the screen it streams: data, activity, surfaces, readiness, and the reconnect ladder.
|
|
151
|
+
const { data, activity, surfaces, ready, loadError, restore, retry } = useStream({ requested, route, account, onReady: () => setNow(Date.now()) });
|
|
152
|
+
// Home and a Sessions list remember their scroll and Dead group; other views open at the newest message.
|
|
153
|
+
const memoryKey = home ? (selected.level === "home" ? "home" : "") : listing ? "sessions " + (selected.project || data.project || "") : "";
|
|
154
|
+
const [, remembered] = useState(0);
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
if (!ready) return;
|
|
157
|
+
const list = stick.current?.scrollRef.current;
|
|
158
|
+
// Home and History open at their top: the overview, or the map above the chat.
|
|
159
|
+
if ((home || compactions) && list) {
|
|
160
|
+
stick.current.stopScroll();
|
|
161
|
+
list.scrollTop = 0;
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const saved = memoryKey && views.get(memoryKey, {}).scrollTop;
|
|
165
|
+
if (!list || !saved) { stick.current?.scrollToBottom("instant"); return; }
|
|
166
|
+
// Leaving the bottom lock first stops use-stick-to-bottom pulling the restored list down on its next resize.
|
|
167
|
+
stick.current.stopScroll();
|
|
168
|
+
list.scrollTop = saved;
|
|
169
|
+
}, [ready, requested, home, compactions, selected.subagent]);
|
|
170
|
+
useEffect(() => {
|
|
171
|
+
const list = stick.current?.scrollRef.current;
|
|
172
|
+
if (!ready || !memoryKey || !list) return;
|
|
173
|
+
const save = () => views.set(memoryKey, { ...views.get(memoryKey, {}), scrollTop: list.scrollTop });
|
|
174
|
+
list.addEventListener("scroll", save, { passive: true });
|
|
175
|
+
return () => list.removeEventListener("scroll", save);
|
|
176
|
+
}, [ready, requested, memoryKey]);
|
|
177
|
+
const [seenDecisions, setSeenDecisions] = useState(() => new Set());
|
|
178
|
+
const [projectPanel, setProjectPanel] = useState(false);
|
|
179
|
+
const markDecisionSeen = key => setSeenDecisions(seen => new Set(seen).add(key));
|
|
180
|
+
const [inactiveOpen, setInactiveOpen] = useState(false);
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
try { setInactiveOpen(localStorage.getItem("temmo:show-inactive") === "true"); } catch {}
|
|
183
|
+
}, []);
|
|
184
|
+
function rememberInactive(open) {
|
|
185
|
+
setInactiveOpen(open);
|
|
186
|
+
try { localStorage.setItem("temmo:show-inactive", String(open)); } catch {}
|
|
187
|
+
}
|
|
188
|
+
function rememberDead(open) {
|
|
189
|
+
if (Boolean(views.get(memoryKey, {}).dead) === open) return;
|
|
190
|
+
views.set(memoryKey, { ...views.get(memoryKey, {}), dead: open });
|
|
191
|
+
remembered(n => n + 1);
|
|
192
|
+
}
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
const change = () => {
|
|
195
|
+
const next = selection();
|
|
196
|
+
// A hash change that keeps the same stream (a tab or subagent run over rows already loaded) keeps its state.
|
|
197
|
+
const nextStream = streamOf(next).requested;
|
|
198
|
+
const same = nextStream === route.current;
|
|
199
|
+
// Set now so the old stream's events, until its effect closes it, are dropped.
|
|
200
|
+
route.current = nextStream;
|
|
201
|
+
setSelected(next);
|
|
202
|
+
// Any route change, a panel tab included, leaves the phone's thread list.
|
|
203
|
+
setNavOpen(false);
|
|
204
|
+
if (same) return;
|
|
205
|
+
// A screen still in the cache is shown at once; the reconnected stream revalidates it. An uncached one keeps the
|
|
206
|
+
// old snapshot's project list beside it until its own state frame arrives, so the sidebar never empties.
|
|
207
|
+
restore(nextStream);
|
|
208
|
+
latestAction.current++;
|
|
209
|
+
setNotice(""); setReplyTo(null);
|
|
210
|
+
};
|
|
211
|
+
window.addEventListener("hashchange", change);
|
|
212
|
+
return () => window.removeEventListener("hashchange", change);
|
|
213
|
+
}, []);
|
|
214
|
+
useEffect(() => {
|
|
215
|
+
// Relative times only; no network.
|
|
216
|
+
const timer = setInterval(() => setNow(Date.now()), TICK_MS);
|
|
217
|
+
return () => clearInterval(timer);
|
|
218
|
+
}, []);
|
|
219
|
+
// Pull to refresh: a touch drag down from the top or up from the bottom past PULL_THRESHOLD_PX reconnects like Retry.
|
|
220
|
+
// The scrolling element is StickToBottom.Content's outer div (overflow-y-auto via scrollClassName).
|
|
221
|
+
function pullStart(event) {
|
|
222
|
+
if (!event.currentTarget.firstElementChild) return;
|
|
223
|
+
const list = event.currentTarget.firstElementChild;
|
|
224
|
+
// The composer keeps focus after a send, so only a draft in it means the operator is typing.
|
|
225
|
+
const typing = document.activeElement?.id === "composer" && Boolean(document.activeElement.value?.trim());
|
|
226
|
+
const selecting = Boolean(window.getSelection?.()?.toString());
|
|
227
|
+
const top = atTop(list), bottom = atBottom(list);
|
|
228
|
+
pullFrom.current = (top || bottom) && !typing && !selecting && event.touches.length === 1 ? { y: event.touches[0].clientY, top, bottom } : null;
|
|
229
|
+
}
|
|
230
|
+
function pullMove(event) {
|
|
231
|
+
if (pullFrom.current === null) return;
|
|
232
|
+
const list = event.currentTarget.firstElementChild;
|
|
233
|
+
const dy = event.touches[0].clientY - pullFrom.current.y;
|
|
234
|
+
const side = dy > 0 && pullFrom.current.top && atTop(list) ? "top" : dy < 0 && pullFrom.current.bottom && atBottom(list) ? "bottom" : null;
|
|
235
|
+
if (!side) { pullFrom.current = null; pullTo(0); return; }
|
|
236
|
+
setPullSide(side);
|
|
237
|
+
pullTo(Math.abs(dy));
|
|
238
|
+
}
|
|
239
|
+
function pullEnd() {
|
|
240
|
+
const ready = pullFrom.current !== null && pullRef.current >= PULL_THRESHOLD_PX;
|
|
241
|
+
pullFrom.current = null;
|
|
242
|
+
pullTo(0);
|
|
243
|
+
if (ready) retry();
|
|
244
|
+
}
|
|
245
|
+
function atTop(list) { return list.scrollTop <= 0; }
|
|
246
|
+
function atBottom(list) { return list.scrollHeight - list.scrollTop - list.clientHeight <= 1; }
|
|
247
|
+
function pullTo(px) { pullRef.current = px; setPull(px); }
|
|
248
|
+
|
|
249
|
+
function navigate(next) {
|
|
250
|
+
setNavOpen(false);
|
|
251
|
+
location.hash = selectionHash(next);
|
|
252
|
+
}
|
|
253
|
+
const project = selected.project || data.project || "";
|
|
254
|
+
const models = useModels(project);
|
|
255
|
+
const level = selected.level;
|
|
256
|
+
const tasksView = level === "tasks";
|
|
257
|
+
const composeTask = selected.composeTask || "";
|
|
258
|
+
const taskLinks = useMemo(() => ({ project, ids: new Set(data.tasks?.tasks.map(task => task.id)) }), [project, data.tasks]);
|
|
259
|
+
// The new-agent composer replaces the chat while it is open.
|
|
260
|
+
const paused = data.projects.some(item => item.id === project && item.paused);
|
|
261
|
+
const composing = level === "project" && Boolean(creating) && creating === project && ready && !paused;
|
|
262
|
+
const viewCounts = projectViewCounts(ready ? data : undefined);
|
|
263
|
+
const agent = level === "session" ? data.agents.find(item => item.id === selected.session) : undefined;
|
|
264
|
+
const target = level === "session" ? selected.session : "all";
|
|
265
|
+
const missing = level === "session" && !target;
|
|
266
|
+
// A session the server lists as gone, or no longer lists at all: its row still opens what history remains.
|
|
267
|
+
const ended = level === "session" && Boolean(target) && ready && (!agent || Boolean(agent.gone));
|
|
268
|
+
const patterns = level === "patterns";
|
|
269
|
+
const inbox = level === "inbox";
|
|
270
|
+
const progressView = level === "progress";
|
|
271
|
+
// Home's own overview: the progress view and the inbox share its stream but not its cards.
|
|
272
|
+
const overview = home && !inbox && !progressView;
|
|
273
|
+
const identity = agentName(agent);
|
|
274
|
+
const sessionLabel = !agent?.generatedName ? agent?.name : "";
|
|
275
|
+
// A picked project's own views read alike: the header's kicker names the project and its h1 the view. A session keeps
|
|
276
|
+
// its own name; Home and the inbox are not inside a project.
|
|
277
|
+
const projectView = level === "project" ? "Chat" : level === "tasks" ? "Tasks" : level === "patterns" ? "Teams" : level === "compactions" ? "History" : "";
|
|
278
|
+
const title = inbox ? "Decision inbox" : progressView ? "Recent progress" : home ? "Home" : level === "session" ? identity || sessionLabel || short(selected.session) || "Sessions"
|
|
279
|
+
: level === "thread" ? "Thread" : projectView || project;
|
|
280
|
+
// A home or Sessions card opens its session, or one of its subagent runs.
|
|
281
|
+
const openCard = (node, run = "") => navigate({ project: node.project, level: "session", harness: node.harness || peerOf(node.id), session: node.id, ...(run ? { tab: "subagents", run } : {}) });
|
|
282
|
+
// The session's ⋯ menu opens its raw activity: every tool call, unfolded.
|
|
283
|
+
const openRaw = node => navigate({ project: node.project, level: "session", harness: node.harness || peerOf(node.id), session: node.id, tab: "raw" });
|
|
284
|
+
const placeholder = composeTask ? `Message about #${composeTask}…` : "Write a message…";
|
|
285
|
+
const currentThread = level === "thread" ? (data.threads || []).find(item => item.id === selected.thread)
|
|
286
|
+
: level === "session" && selected.session ? (data.threads || []).find(item => (item.sessions || []).includes(selected.session)) : undefined;
|
|
287
|
+
// Only the thread view posts to the thread's channel; a session's chat, even a thread member's, is a direct chat no other session reads.
|
|
288
|
+
const channelThread = level === "thread" ? currentThread : undefined;
|
|
289
|
+
const openThreads = (data.threads || []).filter(item => item.status !== "archived");
|
|
290
|
+
const startingIn = startThread ? openThreads.find(item => item.id === startThread) : undefined;
|
|
291
|
+
const routing = { project, target, session: level === "session" && Boolean(target), tasks: data.tasks?.tasks || [],
|
|
292
|
+
thread: channelThread ? { id: channelThread.id, title: channelThread.title } : null,
|
|
293
|
+
peers: data.projects.find(item => item.id === project)?.peers || [],
|
|
294
|
+
patterns: data.patterns || [], hosted: data.hosted };
|
|
295
|
+
// A session command: resolves true only when the session ran it or the compaction was requested (the composer clears).
|
|
296
|
+
async function runCommand(body) {
|
|
297
|
+
const at = requested;
|
|
298
|
+
latestAction.current++;
|
|
299
|
+
setWorking(true);
|
|
300
|
+
try {
|
|
301
|
+
const result = await api("command", { project, target: selected.session, command: body });
|
|
302
|
+
if (at === route.current) setNotice([result.status, result.detail].filter(Boolean).join(" · "));
|
|
303
|
+
return result.status === "succeeded" || result.status === "requested";
|
|
304
|
+
} catch (err) { if (at === route.current) setNotice(err.message); return false; }
|
|
305
|
+
finally { setWorking(false); }
|
|
306
|
+
}
|
|
307
|
+
// /mode from an approval card's menu: resolves true only when the runner changed the mode, so "Allow and switch" can follow.
|
|
308
|
+
async function changeMode({ project: at = project, target: address, mode }) {
|
|
309
|
+
const shown = requested;
|
|
310
|
+
latestAction.current++;
|
|
311
|
+
setWorking(true);
|
|
312
|
+
try {
|
|
313
|
+
const result = await api("command", { project: at, target: address, command: modeCommand(mode) });
|
|
314
|
+
if (shown === route.current) setNotice([result.status, result.detail].filter(Boolean).join(" · "));
|
|
315
|
+
return result.status === "succeeded";
|
|
316
|
+
} catch (err) { if (shown === route.current) setNotice(err.message); return false; }
|
|
317
|
+
finally { setWorking(false); }
|
|
318
|
+
}
|
|
319
|
+
async function action(path, payload, fallback, image) {
|
|
320
|
+
const at = requested;
|
|
321
|
+
const sequence = ++latestAction.current;
|
|
322
|
+
const current = () => at === route.current && sequence === latestAction.current;
|
|
323
|
+
const show = result => {
|
|
324
|
+
if (!result || !current()) return;
|
|
325
|
+
const outcome = (result.wake && !["online", "queued"].includes(result.wake.status) && result.wake) || result.compact || (result.wake ? { status: result.status, detail: result.detail } : result);
|
|
326
|
+
const note = result.quoted ? [outcome.status || "Sent", "as plain text quoting the original"].join(" · ")
|
|
327
|
+
: [outcome.status, outcome.detail || outcome.message || outcome.reason].filter(Boolean).join(" · ");
|
|
328
|
+
setNotice(note || fallback);
|
|
329
|
+
};
|
|
330
|
+
setWorking(true);
|
|
331
|
+
try {
|
|
332
|
+
const result = await api(path, { project, ...payload }, image);
|
|
333
|
+
if (result.draftHeld) return "draftHeld";
|
|
334
|
+
show(result);
|
|
335
|
+
void result.followup?.then(show);
|
|
336
|
+
return true;
|
|
337
|
+
} catch (err) { if (current()) setNotice(err.message); return false; }
|
|
338
|
+
finally { setWorking(false); }
|
|
339
|
+
}
|
|
340
|
+
// A tapped sender or @tag: a session address opens its thread, a bare harness name the session list.
|
|
341
|
+
function openAddress(address) {
|
|
342
|
+
const [peer, session] = String(address).split("#");
|
|
343
|
+
if (!peer || peer === "all" || peer === "operator" || peer === "ntfy" || peer === "system") return;
|
|
344
|
+
navigate(session ? { project, level: "session", harness: peer, session: address } : { project, level: "session" });
|
|
345
|
+
}
|
|
346
|
+
// The raw view keeps every tool call as its own row; the timeline and subagents fold them into turns and runs.
|
|
347
|
+
// A run link's window (selected.window) cuts the timeline to the rows of that schedule run.
|
|
348
|
+
const windowRows = useMemo(() => {
|
|
349
|
+
const from = selected.window?.from;
|
|
350
|
+
const to = selected.window?.to;
|
|
351
|
+
return Number.isSafeInteger(from) && Number.isSafeInteger(to) ? activity.filter(row => row.time * 1000 >= from && row.time * 1000 <= to) : activity;
|
|
352
|
+
}, [activity, selected.window]);
|
|
353
|
+
const rows = useMemo(() => watching || inline ? groupSubagents(activityRows(windowRows)) : [], [watching, inline, windowRows]);
|
|
354
|
+
// The raw panel keeps every tool call as its own row, newest first.
|
|
355
|
+
const rawRows = useMemo(() => raw ? activityRows(windowRows).slice().reverse() : [], [raw, windowRows]);
|
|
356
|
+
// A run's Go-to opens its transcript as the chat; an open panel on the same session stays open.
|
|
357
|
+
const goRun = row => navigate({ project, level: "session", harness: peerOf(row.agent), session: row.agent, subagent: row.run, ...(row.agent === selected.session ? { tab: selected.tab, run: selected.run } : {}) });
|
|
358
|
+
// The native subagent run whose transcript replaces the session's chat (hash subagent=<run id>).
|
|
359
|
+
const subagentRun = level === "session" && selected.subagent ? rows.find(row => row.type === "subagent" && row.agent === selected.session && row.run === selected.subagent) : undefined;
|
|
360
|
+
const leaveRun = () => navigate({ ...selected, project, subagent: "" });
|
|
361
|
+
// Answers whose card is listed show in the card, so their bubbles stay out of both threads.
|
|
362
|
+
const queue = level === "session" && ready ? data.messages.filter(item => item.queued && item.to === target) : [];
|
|
363
|
+
const visible = useMemo(() => withoutAnswered(level === "session" ? data.messages.filter(item => !item.queued) : data.messages), [data.messages, level]);
|
|
364
|
+
// A run window keeps the chat messages that arrived during the same run, so they sit beside its rows.
|
|
365
|
+
const scoped = useMemo(() => {
|
|
366
|
+
const from = selected.window?.from;
|
|
367
|
+
const to = selected.window?.to;
|
|
368
|
+
return Number.isSafeInteger(from) && Number.isSafeInteger(to) ? visible.filter(item => item.time * 1000 >= from && item.time * 1000 <= to) : visible;
|
|
369
|
+
}, [visible, selected.window]);
|
|
370
|
+
const turns = useMemo(() => sessionTurns(rows), [rows]);
|
|
371
|
+
// The project chat shows finished turns and busy sessions, not every tool call.
|
|
372
|
+
const live = useMemo(() => watching ? liveRows(turns, rows, now) : [], [turns, rows, watching, now]);
|
|
373
|
+
const thread = useMemo(() => inline && selected.subagent ? (subagentRun ? subagentThread(subagentRun) : [])
|
|
374
|
+
: inline ? chatThread(scoped, rows, selected.session)
|
|
375
|
+
: watching ? projectThread(visible, turns)
|
|
376
|
+
: visible.map(message => ({ message })), [visible, scoped, turns, rows, inline, watching, selected.session, selected.subagent, subagentRun]);
|
|
377
|
+
const newSession = (id, thread = "") => {
|
|
378
|
+
setStartThread(thread); setCreating(id);
|
|
379
|
+
const away = id !== project || level !== "project";
|
|
380
|
+
composeFrom.current = away && id === project ? selected : null;
|
|
381
|
+
if (away) navigate({ project: id, level: "project" }); else setNavOpen(false);
|
|
382
|
+
};
|
|
383
|
+
// Closing the composer returns to the chat it opened from; one opened in the project chat stays there.
|
|
384
|
+
const closeComposer = () => {
|
|
385
|
+
setCreating("");
|
|
386
|
+
const from = composeFrom.current;
|
|
387
|
+
composeFrom.current = null;
|
|
388
|
+
if (from && location.hash.slice(1) === selectionHash({ project, level: "project" })) navigate(from);
|
|
389
|
+
};
|
|
390
|
+
async function startSession(payload) {
|
|
391
|
+
try { return await api("start", { project, ...payload }); } catch (err) { return { status: "failed", detail: err.message }; }
|
|
392
|
+
}
|
|
393
|
+
// Pattern saves, copies, deletes and operator advances all post to the pattern action; a failure comes back as { error }.
|
|
394
|
+
async function patternCall(payload) {
|
|
395
|
+
try { return await api("pattern", payload); } catch (err) { return { error: err.message }; }
|
|
396
|
+
}
|
|
397
|
+
// Close, reopen and delete a project; Delete asks first and leaves the repo, worktrees and message history alone.
|
|
398
|
+
async function projectAction(path, name) {
|
|
399
|
+
if (path === "request-outcome") {
|
|
400
|
+
setNavOpen(false);
|
|
401
|
+
setOutcomeError("");
|
|
402
|
+
setOutcomeProject(name);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (path === "delete" && !window.confirm("Delete " + name + " from the project registry? Its repo, worktrees and message history stay. Live sessions in its repo will re-home under the folder name.")) return;
|
|
406
|
+
const done = await action(path, { project: name }, path === "close" ? "Closed" : path === "reopen" ? "Reopened" : "Deleted");
|
|
407
|
+
if (done && path !== "reopen" && name === (selected.project || data.project)) navigate({ level: "home" });
|
|
408
|
+
}
|
|
409
|
+
const anyWaiting = data.projects.some(project => project.waiting > 0);
|
|
410
|
+
const panel = level === "session" && selected.session && PANEL.includes(selected.tab) ? selected.tab : "";
|
|
411
|
+
const setPanel = tab => navigate({ ...selected, project, tab, run: "" });
|
|
412
|
+
// The board's props, shared by the Tasks level and the panel's Tasks tab.
|
|
413
|
+
const boardProps = {
|
|
414
|
+
project, board: ready ? data.tasks : null, now, landControl: ready && <LandReviews landing={data.landing} disabled={working} onLand={() => action("land-reviews", {}, "Landing reviews")}/>,
|
|
415
|
+
outcomeControls: { act: action, disabled: working, paused },
|
|
416
|
+
back: () => navigate({ project, level: "tasks" }), compose: id => navigate({ project, level: "project", composeTask: id }),
|
|
417
|
+
continuation: { harnesses: paused ? [] : data.startable || [], launch: (id, harness) => action("continue-builder", { id, harness }, "Replacement started") },
|
|
418
|
+
inspect: id => navigate({ project, level: "tasks", task: id }),
|
|
419
|
+
move: (id, status) => action("move-task", { id, status }, "Task moved"),
|
|
420
|
+
recover: (id, harness) => action("recover-builder", { id, harness }, "Builder started"),
|
|
421
|
+
decide: (id, answer) => action("decide", { id, answer }, "Decided"),
|
|
422
|
+
review: (id, decision, note, packet) => action("review", { id, decision, note, ...packet }, decision === "accept" ? "Build accepted" : "Build returned"),
|
|
423
|
+
skip: taskId => action("skip", { taskId }, "Skipped"),
|
|
424
|
+
open: address => navigate({ project, level: "session", harness: address.split("#")[0], session: address, tab: "activity" }),
|
|
425
|
+
};
|
|
426
|
+
// The project chat's panel holds only Tasks; it lives in state because project&tab=tasks is the old link to the board.
|
|
427
|
+
const shownPanel = panel || (level === "project" && projectPanel ? "tasks" : "");
|
|
428
|
+
const closePanel = () => level === "session" ? setPanel("activity") : setProjectPanel(false);
|
|
429
|
+
const openTasks = () => level === "session" && selected.session ? setPanel("tasks") : level === "project" ? setProjectPanel(true) : navigate({ project, level: "tasks" });
|
|
430
|
+
const threadProps = {
|
|
431
|
+
data, selected, now, navigate, ready, disabled: working, counts: viewCounts, decisions: data.decisions?.length || 0, openTasks,
|
|
432
|
+
newThread: newSession, projectAction,
|
|
433
|
+
listen: (thread, session, on) => action("thread", { op: "listen", thread, session, on }, on ? "Listening" : "Muted"),
|
|
434
|
+
threadAction: (op, thread, fields, done) => action("thread", { op, thread, ...fields }, done),
|
|
435
|
+
stop: session => action("interrupt", { target: session }, "Interrupt requested"),
|
|
436
|
+
archiveThreads: ids => action("thread", { op: "archive", threads: ids }, "Archived " + ids.length),
|
|
437
|
+
openSchedules: () => setSchedulesOpen(true), openLessons: () => setLessonsOpen(true), account: account.user?.login, signOut: account.user ? signOut : undefined,
|
|
438
|
+
pause: () => action("project-pause", { paused: !paused }, paused ? "New work resumed" : "New work paused"),
|
|
439
|
+
controls: <>
|
|
440
|
+
<AfkToggle mode={data.mode || "off"} disabled={!ready || working} set={mode => action("afk", { mode }, "AFK " + mode)}/>
|
|
441
|
+
{/* Before the first state frame the bell shows this browser's last choice. */}
|
|
442
|
+
<NotifyToggle level={data.alerts} levelDisabled={!ready || working} setLevel={level => action("alerts", { level }, "Alerts set")}
|
|
443
|
+
decisions={ready ? data.decisions || [] : []} now={now} openInbox={() => navigate({ level: "inbox" })}/>
|
|
444
|
+
</>,
|
|
445
|
+
};
|
|
446
|
+
// The session's display name: a set_identity name, else a few words of its title, else the thread's.
|
|
447
|
+
const sessionName = level === "session" ? identity || shortName(agent, currentThread?.title) || short(selected.session) : "";
|
|
448
|
+
// A phone shows one screen at a time: the thread list, or the chat with its panel as a sheet.
|
|
449
|
+
const listScreen = !wide && navOpen;
|
|
450
|
+
const asideRef = useRef(null);
|
|
451
|
+
const headerRef = useRef(null);
|
|
452
|
+
const barRef = useRef(null);
|
|
453
|
+
const shownList = useRef(listScreen);
|
|
454
|
+
// Swapping screens hides the focused control, so focus moves to the first control of the screen now shown.
|
|
455
|
+
useEffect(() => {
|
|
456
|
+
if (shownList.current === listScreen) return;
|
|
457
|
+
shownList.current = listScreen;
|
|
458
|
+
const hidden = listScreen ? headerRef.current?.closest("main") : asideRef.current;
|
|
459
|
+
const active = document.activeElement;
|
|
460
|
+
if (active && active !== document.body && !hidden?.contains(active) && !barRef.current?.contains(active)) return;
|
|
461
|
+
(listScreen ? asideRef : headerRef).current?.querySelector("button:not(:disabled)")?.focus();
|
|
462
|
+
}, [listScreen]);
|
|
463
|
+
return <SurfaceContext.Provider value={{ surfaces, submit: payload => action("a2ui", payload, "Sent"), disabled: !ready || working }}><div className="flex h-dvh w-full flex-col overflow-hidden"><div className="flex min-h-0 w-full flex-1">
|
|
464
|
+
<aside ref={asideRef} aria-label="Projects and threads" className={cn("shrink-0 bg-sidebar text-sidebar-foreground", listScreen ? "flex w-full" : "hidden w-72 md:flex")}>
|
|
465
|
+
<div className="min-w-0 flex-1"><ThreadSidebar {...threadProps}/></div>
|
|
466
|
+
</aside>
|
|
467
|
+
<Sheet open={schedulesOpen} onOpenChange={setSchedulesOpen}>
|
|
468
|
+
<SheetContent side={wide ? "right" : "bottom"} className="max-h-dvh overflow-y-auto p-0 max-md:max-h-[85dvh]">
|
|
469
|
+
<SheetTitle className="sr-only">Scheduled jobs</SheetTitle>
|
|
470
|
+
<SheetDescription className="sr-only">Scheduled jobs of the runner, read-only</SheetDescription>
|
|
471
|
+
<div className="pt-4"><ScheduledJobs project={home ? "" : project} openRun={hash => { setSchedulesOpen(false); setNavOpen(false); location.hash = hash.slice(1); }}/></div>
|
|
472
|
+
</SheetContent>
|
|
473
|
+
</Sheet>
|
|
474
|
+
<Sheet open={lessonsOpen} onOpenChange={setLessonsOpen}>
|
|
475
|
+
<SheetContent side={wide ? "right" : "bottom"} className="max-h-dvh overflow-y-auto p-0 max-md:max-h-[85dvh]">
|
|
476
|
+
<div className="px-4 pt-4"><SheetTitle>Harness lessons</SheetTitle>
|
|
477
|
+
<SheetDescription>Learned from ended sessions, read-only</SheetDescription></div>
|
|
478
|
+
<div className="pt-3"><HarnessLessons project={home ? "" : project}
|
|
479
|
+
openTask={(owner, task) => { setLessonsOpen(false); navigate({ level: "tasks", project: owner, task }); }}/></div>
|
|
480
|
+
</SheetContent>
|
|
481
|
+
</Sheet>
|
|
482
|
+
<OutcomeRequest project={outcomeProject} close={() => setOutcomeProject("")} disabled={working} error={outcomeError}
|
|
483
|
+
submit={async fields => {
|
|
484
|
+
setWorking(true);
|
|
485
|
+
setOutcomeError("");
|
|
486
|
+
try {
|
|
487
|
+
await api("request-outcome", { project: outcomeProject, ...fields });
|
|
488
|
+
setOutcomeProject("");
|
|
489
|
+
navigate({ project: outcomeProject, level: "tasks" });
|
|
490
|
+
} catch (err) { setOutcomeError(err.message); }
|
|
491
|
+
finally { setWorking(false); }
|
|
492
|
+
}}/>
|
|
493
|
+
<main className={cn("min-w-0 flex-1 flex-col", listScreen ? "hidden" : "flex")}>
|
|
494
|
+
<DeployedBanner deployed={data.deployed}/>
|
|
495
|
+
<header ref={headerRef} className="relative z-10 flex min-h-12 shrink-0 items-center gap-2 bg-background px-3 py-1.5 shadow-surface">
|
|
496
|
+
<div className="min-w-0 flex-1">
|
|
497
|
+
{level === "session" ? <>
|
|
498
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
499
|
+
{/* The agent names the header; the thread sits beside it as the way back to the thread chat (docs/threads.md "Thread view"). */}
|
|
500
|
+
<h1 className="min-w-0 truncate text-base font-semibold" title={selected.session}>
|
|
501
|
+
{selected.session ? <AgentName address={selected.session} name={sessionName}/> : title}
|
|
502
|
+
</h1>
|
|
503
|
+
{currentThread && <button type="button" data-tap onClick={() => navigate({ project, level: "thread", thread: currentThread.id })}
|
|
504
|
+
aria-label={"Open the thread chat: " + (currentThread.title || currentThread.id)} title={"Open the thread chat: " + (currentThread.title || currentThread.id)}
|
|
505
|
+
className="min-w-0 max-w-40 shrink truncate rounded-md text-sm text-muted-foreground underline-offset-2 hover:text-foreground hover:underline">{currentThread.title}</button>}
|
|
506
|
+
{agent && <span className="shrink-0 max-md:hidden"><StateChip state={sessionState(agent, now)}/></span>}
|
|
507
|
+
{agent && <span className="shrink-0 max-md:hidden"><RunningCount runs={agent.subagents} now={now}/></span>}
|
|
508
|
+
</div>
|
|
509
|
+
<p className="flex min-w-0 items-center gap-1.5 truncate text-xs text-muted-foreground">
|
|
510
|
+
<span className="truncate">{project}</span>
|
|
511
|
+
{currentThread && <ThreadPlace place={currentThread.place} branch={currentThread.branch} className="shrink"/>}
|
|
512
|
+
{level === "session" && (agent?.modelControl?.current || agent?.model) && <span className="shrink-0 truncate" title="Model">{agent.modelControl?.current || agent.model}</span>}
|
|
513
|
+
{level === "session" && agent?.parent && <button type="button" data-tap onClick={() => openAddress(agent.parent)} title={"Started by " + agent.parent}
|
|
514
|
+
aria-label={"Back to parent " + agent.parent} className="flex min-w-0 items-center gap-1 underline-offset-2 hover:underline">
|
|
515
|
+
<CornerLeftUp className="size-3.5 shrink-0"/><span className="truncate">parent {short(agent.parent)}</span></button>}
|
|
516
|
+
</p>
|
|
517
|
+
</> : level === "thread" ? <>
|
|
518
|
+
<h1 className="min-w-0 truncate text-base font-semibold">{currentThread?.title || "Thread"}</h1>
|
|
519
|
+
<p className="flex min-w-0 items-center gap-1.5 truncate text-xs text-muted-foreground">
|
|
520
|
+
<span className="truncate">{project}</span>
|
|
521
|
+
{currentThread && <ThreadPlace place={currentThread.place} branch={currentThread.branch} className="shrink"/>}
|
|
522
|
+
</p>
|
|
523
|
+
</> : <>
|
|
524
|
+
<p className="truncate text-xs text-muted-foreground">{home ? "All projects" : project ? "Project · " + project : "Project"}</p>
|
|
525
|
+
<h1 className="truncate text-base font-semibold leading-tight">{title}</h1>
|
|
526
|
+
</>}
|
|
527
|
+
</div>
|
|
528
|
+
{level === "project" && paused && <Badge variant="secondary">New work paused</Badge>}
|
|
529
|
+
{/* A phone hides the sidebar, so New thread repeats here as the header's first stop. */}
|
|
530
|
+
{project && !home && !inbox && <Button variant="ghost" size="icon" className="md:hidden" aria-label={"New thread in " + project}
|
|
531
|
+
title={paused ? "New work is paused" : "New thread"} disabled={working || paused} onClick={() => newSession(project)}><Plus/></Button>}
|
|
532
|
+
{(level === "session" || level === "thread") && currentThread && !paused && <Button variant="ghost" size="icon" aria-label={"Add agent to " + (currentThread.title || "this thread")}
|
|
533
|
+
title="Add agent to this thread" disabled={working} onClick={() => newSession(project, currentThread.id)}><UserPlus/></Button>}
|
|
534
|
+
{(level === "session" || level === "thread") && <ThreadSwitcher thread={currentThread} agents={data.agents || []} current={selected.session}
|
|
535
|
+
open={session => session && navigate({ project, level: "session", harness: session.split("#")[0], session })}/>}
|
|
536
|
+
{level === "session" && agent?.session && <div className="flex shrink-0 items-center gap-1">
|
|
537
|
+
{agent.modelControl && modelsOf(models, "claude").length > 0 && <select
|
|
538
|
+
aria-label="Claude model" className="h-8 w-28 truncate rounded-md border bg-background px-2 text-sm max-md:hidden"
|
|
539
|
+
value={agent.modelControl.current} disabled={!ready || working || agent.modelControl.busy}
|
|
540
|
+
onChange={event => action("model", { target: selected.session, model: event.target.value }, "Model switched")}>
|
|
541
|
+
<option value="" disabled>Default model</option>
|
|
542
|
+
{Array.from(new Set([agent.modelControl.current, ...modelsOf(models, "claude")])).filter(Boolean)
|
|
543
|
+
.map(model => <option key={model} value={model}>{model}</option>)}
|
|
544
|
+
</select>}
|
|
545
|
+
<span className="max-sm:hidden"><ContextChip context={agent.context || {}} rows={rows.filter(row => row.agent === agent.id)}/></span>
|
|
546
|
+
{canStop(agent, now) && <Button variant="ghost" size="icon" aria-label={"Stop " + selected.session} title="Stop this agent's turn" disabled={!ready}
|
|
547
|
+
onClick={() => action("interrupt", { target: selected.session }, "Interrupt requested")}><CircleStop/></Button>}
|
|
548
|
+
<SessionMenu node={{ ...agent, project }} disabled={working} map={() => navigate({ project, level: "compactions" })} dispose={node => action("dispose", { project: node.project, target: node.id }, "Disposed")}
|
|
549
|
+
raw={openRaw} label={"Session actions for " + selected.session} detailsAction={<>
|
|
550
|
+
<DropdownMenuItem disabled={!ready || working} onSelect={() => action("compact", { target: selected.session }, "Compaction requested")}>Compact</DropdownMenuItem>
|
|
551
|
+
{stoppable(agent) && <DropdownMenuItem disabled={!ready}
|
|
552
|
+
onSelect={() => action("interrupt", { target: selected.session }, "Interrupt requested")}>Interrupt</DropdownMenuItem>}
|
|
553
|
+
{agent.runnerStatus && <DropdownMenuItem variant="destructive" disabled={!ready}
|
|
554
|
+
onSelect={() => window.confirm("End " + selected.session + "? Its run stops and it takes no more messages.") && action("end", { target: selected.session }, "Agent ended")}>End agent</DropdownMenuItem>}
|
|
555
|
+
</>}/>
|
|
556
|
+
</div>}
|
|
557
|
+
{level === "session" && selected.session && <Button variant={panel ? "secondary" : "ghost"} size="icon" aria-label={panel ? "Close panel" : "Open panel"} aria-pressed={Boolean(panel)}
|
|
558
|
+
title="Diff, PR, activity, tasks and raw" onClick={() => setPanel(panel ? "activity" : wide ? "diff" : "subagents")}><PanelRight/></Button>}
|
|
559
|
+
{level === "project" && project && <Button variant={shownPanel ? "secondary" : "ghost"} size="icon" aria-label={shownPanel ? "Close tasks" : "Open tasks"} aria-pressed={Boolean(shownPanel)}
|
|
560
|
+
title="Tasks and the plan" onClick={() => setProjectPanel(!projectPanel)}><ListTodo/></Button>}
|
|
561
|
+
</header>
|
|
562
|
+
{level === "thread" && <ThreadAgents thread={currentThread} agents={data.agents || []} now={now}
|
|
563
|
+
open={session => navigate({ project, level: "session", harness: session.split("#")[0], session })}/>}
|
|
564
|
+
<div className={cn("flex flex-col gap-2 px-3 empty:hidden", composing && "min-h-0 flex-1 justify-end pb-3")}>
|
|
565
|
+
{composing && <div className="mx-auto w-full max-w-3xl px-1 pb-2">
|
|
566
|
+
<h2 className="text-xl font-semibold">{startingIn ? "New agent in " + (startingIn.title || "Untitled") : "New thread"}</h2>
|
|
567
|
+
<p className="text-sm text-muted-foreground">{startingIn ? "It joins the thread and works in its worktree." : "Describe the work; the first words become its title."}</p>
|
|
568
|
+
</div>}
|
|
569
|
+
{composing && <NewAgentComposer key={project + ":" + (data.startable || []).join(",")} project={project} startable={data.startable || []} places={data.startPlaces || ["folder"]} startPlace={data.startPlace || "folder"} sandboxHarnesses={data.openshellHarnesses || []}
|
|
570
|
+
startDefault={data.startDefault} codeModeDefault={data.codeModeDefault !== false} agents={data.agents} models={models} disabled={!ready} start={startSession} close={closeComposer}
|
|
571
|
+
threads={openThreads} thread={startThread} setThread={setStartThread} open={openAddress}/>}
|
|
572
|
+
{level === "session" && selected.subagent && <div data-subagent-chat={selected.subagent} className="mx-auto mt-2 flex w-full min-w-0 max-w-3xl items-center gap-2 rounded-xl border border-dashed bg-muted/50 px-3 py-2 text-sm">
|
|
573
|
+
<Button size="sm" variant="outline" className="shrink-0" aria-label={"Back to " + (sessionName || "session") + " chat"} onClick={leaveRun}><CornerLeftUp/>Back</Button>
|
|
574
|
+
<h2 className="min-w-0 flex-1 font-medium" title={subagentRun?.description || selected.subagent}>
|
|
575
|
+
<span className="block truncate">Subagent · {subagentRun ? subagentRun.kind || "agent" : selected.subagent}{subagentRun?.description && " · " + subagentRun.description}</span>
|
|
576
|
+
{subagentRun && <span className="block truncate text-xs font-normal text-muted-foreground">{subagentLabel(subagentRun, now)}</span>}
|
|
577
|
+
</h2>
|
|
578
|
+
</div>}
|
|
579
|
+
{agent?.wake?.status && <div className="mx-auto mt-2 flex w-full max-w-3xl flex-wrap items-center gap-2 rounded-xl border bg-muted/50 px-3 py-2 text-sm">
|
|
580
|
+
Wake · {agent.wake.status}{agent.wake.detail && " · " + agent.wake.detail}
|
|
581
|
+
{agent.wake.status === "failed" && !agent.online && <Button size="sm" variant="outline" disabled={working} onClick={() => action("wake", { target: selected.session }, "Wake requested")}>Retry wake</Button>}
|
|
582
|
+
</div>}
|
|
583
|
+
{selected.window && <div className="mx-auto mt-2 flex w-full max-w-3xl flex-wrap items-center gap-2 rounded-xl border bg-muted/50 px-3 py-2 text-sm">
|
|
584
|
+
<span className="min-w-0 flex-1">One schedule run · {new Date(selected.window.from).toLocaleString()} to {new Date(selected.window.to).toLocaleString()}</span>
|
|
585
|
+
<Button size="sm" variant="outline" onClick={() => navigate({ project, level: "session", harness: selected.harness, session: selected.session, tab: "activity" })}>Show all</Button>
|
|
586
|
+
</div>}
|
|
587
|
+
{loadError && <div role="alert" className="mx-auto mt-2 flex w-full max-w-3xl items-center gap-2 rounded-xl border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm">
|
|
588
|
+
<span className="flex-1">{loadError}</span>
|
|
589
|
+
<Button size="sm" variant="outline" onClick={retry}><RotateCw/>Retry</Button>
|
|
590
|
+
</div>}
|
|
591
|
+
{!composing && <RunRequests requests={data.runRequests} now={now}/>}
|
|
592
|
+
</div>
|
|
593
|
+
{patterns && <div className="min-h-0 flex-1 overflow-y-auto">
|
|
594
|
+
{ready ? <PatternsPage data={data} project={project} selected={selected} navigate={navigate} call={patternCall} disabled={working} models={models}/>
|
|
595
|
+
: <p className="py-16 text-center text-sm text-muted-foreground">Loading patterns…</p>}
|
|
596
|
+
</div>}
|
|
597
|
+
{!patterns && !composing && (tasksView ? <TaskBoard key={project} {...boardProps} taskId={selected.task}/> : <ChatContainerRoot key={inbox ? "inbox" : progressView ? "progress" : home ? "home" : "conversation"} initial={home || compactions ? false : "instant"} contextRef={stick} className="relative min-h-0 flex-1" onTouchStart={pullStart} onTouchMove={pullMove} onTouchEnd={pullEnd} onTouchCancel={() => pullTo(0)}>
|
|
598
|
+
<ChatRuntimeProvider key={requested + ":" + (selected.subagent || "")} entries={thread} operator={data.operator}>
|
|
599
|
+
<ChatContainerContent key={requested + ":" + (selected.subagent || "")} className="mx-auto w-full max-w-3xl gap-5 px-3 py-4">
|
|
600
|
+
{!ready && (home || listing || compactions) && !loadError && <p className="py-16 text-center text-sm text-muted-foreground">Loading sessions…</p>}
|
|
601
|
+
{ready && (home || listing) && <>
|
|
602
|
+
{home && data.unavailable?.length > 0 && <p role="alert" className="text-xs text-destructive">Unavailable: {data.unavailable.join(", ")}</p>}
|
|
603
|
+
{overview && data.projects.filter(item => item.paused).map(item =>
|
|
604
|
+
<button key={item.id} type="button" className="flex items-center justify-between gap-2 rounded-xl border px-3 py-2 text-left text-sm"
|
|
605
|
+
onClick={() => navigate({ project: item.id, level: "project" })}>
|
|
606
|
+
<span className="truncate">{item.id}</span><Badge variant="secondary">New work paused</Badge>
|
|
607
|
+
</button>)}
|
|
608
|
+
{overview && <LandReviews landing={data.landing} disabled={working} onLand={() => action("land-reviews", { project: undefined }, "Landing reviews")}/>}
|
|
609
|
+
{overview && <Land/>}
|
|
610
|
+
{home && !progressView && <DecisionQueue decisions={data.decisions} inbox={inbox} now={now} disabled={working} action={action} setMode={changeMode}
|
|
611
|
+
seen={seenDecisions} markSeen={markDecisionSeen} openInbox={() => navigate({ level: "inbox" })}/>}
|
|
612
|
+
{overview && data.shipped?.length > 0 && <Shipped items={data.shipped}
|
|
613
|
+
open={item => navigate({ project: item.project, level: "tasks", task: item.id })}/>}
|
|
614
|
+
{progressView && <ProgressFeed posts={data.progress || []} agents={data.sessions || []} now={now}/>}
|
|
615
|
+
{!inbox && !progressView && <SessionList sessions={data.sessions} now={now} open={openCard} raw={openRaw} disabled={working} showProject={home} compact={home}
|
|
616
|
+
inactiveOpen={inactiveOpen} onInactiveToggle={rememberInactive}
|
|
617
|
+
deadOpen={Boolean(views.get(memoryKey, {}).dead)} onDeadToggle={rememberDead}
|
|
618
|
+
openAddress={(address, at) => navigate({ project: at, level: "session", harness: peerOf(address), session: address })}
|
|
619
|
+
empty={home ? "No sessions in any project yet." : "No sessions in " + project + " yet."}
|
|
620
|
+
dispose={node => action("dispose", { project: node.project, target: node.id }, "Disposed")}
|
|
621
|
+
act={payload => action("approve", payload, "Sent")} answer={(at, id, body) => action("reply", { project: at, question: id, body }, "Reply sent")}
|
|
622
|
+
skip={payload => action("skip", payload, "Skipped")} setMode={changeMode}/>}
|
|
623
|
+
</>}
|
|
624
|
+
{ready && compactions && <CompactionMap agents={data.agents || []} now={now}/>}
|
|
625
|
+
{!home && !listing && !(ready && compactions) && (!ready || (thread.length + live.length === 0 && queue.length === 0)) && <p className="py-16 text-center text-sm text-muted-foreground">
|
|
626
|
+
{ready ? (level === "session" && selected.subagent ? "That subagent run is not in the recent activity." : ended ? "This session has ended, and the recent history holds none of its messages." : "No messages yet.") : loadError ? "" : watching ? "Loading project chat…" : "Loading conversation…"}</p>}
|
|
627
|
+
{ready && !home && !listing && <ThreadPrimitive.Messages>
|
|
628
|
+
{({ message }) => {
|
|
629
|
+
const [entry] = getExternalStoreMessages(message) || [];
|
|
630
|
+
if (!entry) return null;
|
|
631
|
+
if (entry.activity) return entry.activity.type === "completion"
|
|
632
|
+
? <CompletionRow row={{ ...entry.activity, seat: seatOf(data.agents, entry.activity.agent) }} when={at => ago(at, now)} open={openAddress}/>
|
|
633
|
+
: <ActivityRow row={entry.activity} when={at => ago(at, now)} now={now} goRun={goRun} openSession={openAddress}/>;
|
|
634
|
+
return <ChatMessage message={entry.message} operator={data.operator} me={account.user?.login} now={now} open={openAddress} disabled={!ready || working} taskLinks={taskLinks}
|
|
635
|
+
detail={agentDetail(data.agents.find(agent => agent.id === entry.message.from))} name={shortName(data.agents.find(agent => agent.id === entry.message.from))}
|
|
636
|
+
act={payload => action("approve", payload, "Sent")} answer={(id, body) => action("reply", { question: id, body }, "Reply sent")}
|
|
637
|
+
skip={payload => action("skip", payload, "Skipped")} setMode={changeMode}
|
|
638
|
+
replyFrom={target => setReplyTo(target)}/>;
|
|
639
|
+
}}
|
|
640
|
+
</ThreadPrimitive.Messages>}
|
|
641
|
+
{ready && watching && live.map(row => <LiveRow key={row.id} row={{ ...row, seat: seatOf(data.agents, row.agent) }} open={openAddress}/>)}
|
|
642
|
+
{ready && inline && !selected.subagent && <Working rows={rows} now={now} agents={data.agents}/>}
|
|
643
|
+
<ChatContainerScrollAnchor/>
|
|
644
|
+
</ChatContainerContent>
|
|
645
|
+
</ChatRuntimeProvider>
|
|
646
|
+
<div aria-hidden className={cn("pointer-events-none absolute inset-x-0 z-20 flex justify-center", pullSide === "top" ? "top-0" : "bottom-0")} style={{ transform: `translateY(${pullSide === "top" ? Math.min(pull, PULL_MAX_PX) - 44 : 44 - Math.min(pull, PULL_MAX_PX)}px)`, opacity: pull ? 1 : 0 }}>
|
|
647
|
+
<span data-pull={pull >= PULL_THRESHOLD_PX ? "ready" : "pulling"} className={cn("grid size-9 place-items-center rounded-full border bg-card shadow-md", pull >= PULL_THRESHOLD_PX && "border-primary text-primary")}>
|
|
648
|
+
<RotateCw className="size-4" style={{ transform: `rotate(${pull * 4}deg)` }}/></span>
|
|
649
|
+
</div>
|
|
650
|
+
<div className="pointer-events-none absolute inset-x-0 bottom-3 flex justify-center">
|
|
651
|
+
<ScrollButton className="pointer-events-auto shadow-md" aria-label="Scroll to newest"/>
|
|
652
|
+
</div>
|
|
653
|
+
</ChatContainerRoot>)}
|
|
654
|
+
<div role="status" hidden={!notice} className="mx-auto w-full max-w-3xl px-4 text-center text-xs text-muted-foreground">{notice}</div>
|
|
655
|
+
{!composing && queue.length > 0 && <section aria-label="Queued messages" className="mx-auto w-full max-w-3xl border-t bg-background">
|
|
656
|
+
<h2 className="px-3 py-1 text-xs font-medium text-muted-foreground">Queued messages ({queue.length})</h2>
|
|
657
|
+
<ul className="max-h-48 overflow-y-auto">
|
|
658
|
+
{queue.map(message => <QueueRow key={project + ":" + message.id} message={message} disabled={working || Boolean(message.by && message.by !== account.user?.login)}
|
|
659
|
+
change={(item, queueAction, body) => action("queue", { target: item.to, id: item.id, queueAction, body },
|
|
660
|
+
{ edit: "Queue updated", cancel: "Message canceled", steer: "Prioritized for delivery" }[queueAction])}/>)}
|
|
661
|
+
</ul>
|
|
662
|
+
</section>}
|
|
663
|
+
{!home && !listing && !patterns && !tasksView && !composing && <ChatRuntimeProvider key={requested + ":" + composeTask} entries={NO_ENTRIES} operator={data.operator} onSend={body => sendBridgeRef.current?.(body)}>
|
|
664
|
+
<Composer sendBridgeRef={sendBridgeRef} conversation={conversationKey(project, composeTask ? "#" + composeTask : level === "session" ? selected.session : level === "thread" ? "thread:" + selected.thread : "")} initialDraft={composeTask ? `#${composeTask} ` : ""} disabled={!ready || working || missing} agents={data.agents} harnesses={data.harnesses} teams={data.teams} startable={data.startable} models={models} now={now} harness={level === "session" && agent?.peer || ""}
|
|
665
|
+
placeholder={placeholder} routing={routing} urgentable replying={replyTo} cancelReply={() => setReplyTo(null)}
|
|
666
|
+
onSend={async (body, urgent, command, sendAnyway, image) => {
|
|
667
|
+
// Project chat never runs commands: a leading / there is ordinary chat.
|
|
668
|
+
if (command && level === "session" && selected.session) return runCommand(body);
|
|
669
|
+
const composeHash = composeTask && location.hash;
|
|
670
|
+
// In the open thread view the post goes to the thread channel (docs/threads.md "Thread channels").
|
|
671
|
+
const sent = await action("send", { target, body, ...(channelThread ? { thread: channelThread.id, channel: true } : {}), ...(sendAnyway ? { sendAnyway: true } : {}), ...(urgent ? { urgent: true } : {}), ...(replyTo ? { replyTo: replyTo.id, quote: { sender: replyTo.sender, body: replyTo.body } } : {}) }, "Sent", image);
|
|
672
|
+
if (sent === true && requested === route.current) {
|
|
673
|
+
setReplyTo(null); stick.current?.scrollToBottom();
|
|
674
|
+
if (composeHash && location.hash === composeHash) navigate({ project, level: "project" });
|
|
675
|
+
}
|
|
676
|
+
return sent;
|
|
677
|
+
}}/>
|
|
678
|
+
</ChatRuntimeProvider>}
|
|
679
|
+
</main>
|
|
680
|
+
{shownPanel && <SessionPanel wide={wide} tab={shownPanel} setTab={level === "session" ? setPanel : () => {}} close={closePanel} project={project} thread={currentThread}
|
|
681
|
+
tabs={level === "session" ? undefined : ["tasks"]} tasks={<TaskBoard key={"panel:" + project} {...boardProps} taskId=""/>}
|
|
682
|
+
activity={ready ? <SubagentList rows={rows} session={selected.session} run={selected.run} when={at => ago(at, now)} now={now}
|
|
683
|
+
childRuns={(agent?.subagents || []).filter(run => run.child)} openChild={child => navigate({ project, level: "session", harness: child.kind, session: child.id })}
|
|
684
|
+
back={() => navigate({ ...selected, project, tab: "subagents", run: "" })}
|
|
685
|
+
pick={run => navigate({ ...selected, project, tab: "subagents", run })}/> : <p className="py-8 text-center text-sm text-muted-foreground">Loading activity…</p>}
|
|
686
|
+
raw={rawRows.length ? <ul className="flex flex-col gap-3">{rawRows.map(row => <li key={row.id}><ActivityRow row={row} when={at => ago(at, now)} now={now} goRun={goRun}/></li>)}</ul>
|
|
687
|
+
: <p className="py-8 text-center text-sm text-muted-foreground">{ready ? "No activity yet." : "Loading activity…"}</p>}/>}
|
|
688
|
+
</div>
|
|
689
|
+
<div ref={barRef} className="contents"><PhoneNav sidebar={threadProps} threadsOpen={listScreen} openThreads={() => setNavOpen(true)} waiting={anyWaiting}/></div>
|
|
690
|
+
</div></SurfaceContext.Provider>;
|
|
691
|
+
}
|