@kabmo-labs/kabmo 0.25.0 → 0.27.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/dist/client/index.html +1 -1
- package/dist/client/index.js +448 -444
- package/dist/client/static/js/index-32rpkj6b.css +1 -0
- package/dist/client/static/js/{index-ga8cbpt4.js → index-e3qh2yps.js} +950 -950
- package/package.json +1 -1
- package/src/client/components/common/Toast.test.tsx +28 -2
- package/src/client/components/common/Toast.tsx +21 -9
- package/src/client/components/common/session-actions-menu/index.tsx +38 -12
- package/src/client/components/common/session-branch/BranchGuides.tsx +93 -0
- package/src/client/components/common/session-branch/SubagentRow.tsx +77 -0
- package/src/client/components/common/session-branch/index.tsx +169 -0
- package/src/client/components/common/session-branch/session-branch.test.tsx +240 -0
- package/src/client/components/common/session-branch/style.ts +29 -0
- package/src/client/components/common/session-row/StatusSlot.tsx +15 -3
- package/src/client/components/common/session-row/index.tsx +24 -25
- package/src/client/components/common/session-row/session-row.test.tsx +11 -0
- package/src/client/components/common/session-state-provider/index.tsx +1 -1
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +2 -1
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +66 -69
- package/src/client/components/layout/session-sidebar/SessionItem.batch.test.ts +3 -3
- package/src/client/components/layout/session-sidebar/SessionItem.test.ts +25 -2
- package/src/client/components/layout/session-sidebar/SessionItem.tsx +33 -30
- package/src/client/components/layout/session-sidebar/SessionList.tsx +2 -1
- package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +261 -0
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +35 -225
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +36 -16
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +11 -3
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +13 -4
- package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +3 -2
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +30 -14
- package/src/client/components/layout/session-sidebar/modern/RevealRow.tsx +56 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +69 -85
- package/src/client/components/layout/session-sidebar/modern/reveal-row.test.tsx +104 -0
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -1
- package/src/client/components/layout/session-sidebar/variant-props.ts +2 -1
- package/src/client/components/mobile/SessionSidebar.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +59 -62
- package/src/client/components/mobile/mobile-session-sidebar/List.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +5 -0
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +33 -30
- package/src/client/components/settings/Modal.tsx +1 -1
- package/src/client/components/settings/Sidebar.tsx +1 -1
- package/src/client/components/settings/categories/NotificationSettings.test.tsx +92 -0
- package/src/client/components/settings/categories/NotificationSettings.tsx +112 -2
- package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +1 -1
- package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
- package/src/client/components/settings/categories/usage-settings/LimitsSection.tsx +39 -19
- package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +1 -0
- package/src/client/components/settings/categories/usage-settings/limit-groups.test.ts +94 -0
- package/src/client/components/settings/categories/usage-settings/limit-groups.ts +118 -0
- package/src/client/components/settings/categories/usage-settings/limits-section.test.tsx +118 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +94 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +31 -5
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +86 -93
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +7 -5
- package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +21 -1
- package/src/client/components/workspace/chat-timeline/PendingTranscript.tsx +130 -0
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +12 -3
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +15 -1
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +85 -0
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +84 -0
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +5 -0
- package/src/client/components/workspace/chat-timeline/fork-preview.test.tsx +141 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +16 -22
- package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +116 -0
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +173 -0
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +5 -4
- package/src/client/components/workspace/chat-timeline/target-picker/parent-session-options.test.ts +49 -0
- package/src/client/components/workspace/git-panel/index.tsx +2 -2
- package/src/client/components/workspace/terminal-panel/RealtimeTerminalView.tsx +8 -5
- package/src/client/components/workspace/terminal-panel/index.tsx +3 -0
- package/src/client/hooks/chat/composer/items.test.ts +19 -0
- package/src/client/hooks/chat/omp/folder-auto-expand.ts +1 -1
- package/src/client/hooks/chat/omp/pending-adoption.ts +51 -0
- package/src/client/hooks/chat/omp/pending-child.test.ts +73 -0
- package/src/client/hooks/chat/omp/pending-entry.ts +59 -0
- package/src/client/hooks/chat/omp/pending-rows.ts +6 -2
- package/src/client/hooks/chat/omp/pending-sessions.test.ts +1 -2
- package/src/client/hooks/chat/omp/pending-sessions.ts +45 -69
- package/src/client/hooks/chat/omp/pending-waiting.ts +1 -1
- package/src/client/hooks/chat/omp/run-switch.ts +1 -1
- package/src/client/hooks/chat/omp/session-list.tsx +9 -0
- package/src/client/hooks/chat/omp/sidebar-reload.test.ts +85 -0
- package/src/client/hooks/chat/omp/sidebar-reload.ts +30 -0
- package/src/client/hooks/chat/subagents/roster.ts +122 -0
- package/src/client/hooks/chat/timeline/child-spawn.test.ts +55 -0
- package/src/client/hooks/chat/timeline/child-spawn.ts +45 -0
- package/src/client/hooks/chat/timeline/fork-preview.test.ts +148 -0
- package/src/client/hooks/chat/timeline/fork-preview.ts +104 -0
- package/src/client/hooks/chat/timeline/fork-request.test.ts +54 -0
- package/src/client/hooks/chat/timeline/fork-request.ts +43 -0
- package/src/client/hooks/chat/timeline/fork-send.test.ts +139 -0
- package/src/client/hooks/chat/timeline/mode-availability.test.ts +1 -1
- package/src/client/hooks/chat/timeline/mode-availability.ts +33 -0
- package/src/client/hooks/chat/timeline/mode-markers.ts +7 -1
- package/src/client/hooks/chat/timeline/mode-post.ts +15 -3
- package/src/client/hooks/chat/timeline/modes-contract.ts +9 -4
- package/src/client/hooks/chat/timeline/modes.test.ts +56 -18
- package/src/client/hooks/chat/timeline/modes.ts +42 -29
- package/src/client/hooks/chat/timeline/pending-branch.ts +214 -0
- package/src/client/hooks/chat/timeline/pending-dispatch.ts +302 -0
- package/src/client/hooks/chat/timeline/send.ts +17 -103
- package/src/client/hooks/chat/timeline/session-harness.ts +6 -0
- package/src/client/hooks/chat/timeline/stop-with-queue.ts +42 -0
- package/src/client/hooks/chat/timeline/use-fork-session.ts +40 -31
- package/src/client/hooks/chat/waiting/cancel.ts +2 -1
- package/src/client/hooks/chat/waiting/dispatch.ts +5 -4
- package/src/client/hooks/chat/waiting/held.ts +2 -1
- package/src/client/hooks/models/use-harness-update.test.ts +137 -44
- package/src/client/hooks/models/use-harness-update.ts +133 -85
- package/src/client/hooks/settings/providers/actions.ts +3 -2
- package/src/client/hooks/settings/providers/messages.ts +9 -7
- package/src/client/hooks/settings/providers/model-actions.ts +2 -1
- package/src/client/hooks/ui/editor-error-toast.ts +2 -1
- package/src/client/hooks/ui/input-required-alert.ts +12 -5
- package/src/client/hooks/ui/notifications.ts +45 -0
- package/src/client/hooks/ui/run-outcome-alert.ts +48 -0
- package/src/client/hooks/workspace/batch-archive.test.ts +2 -2
- package/src/client/hooks/workspace/batch-archive.ts +4 -2
- package/src/client/hooks/workspace/expanded-sessions.ts +36 -7
- package/src/client/hooks/workspace/git-action-outcome.ts +4 -3
- package/src/client/hooks/workspace/navbar-session-actions.ts +2 -1
- package/src/client/hooks/workspace/session-actions.test.ts +2 -1
- package/src/client/hooks/workspace/session-actions.ts +2 -1
- package/src/client/hooks/workspace/terminal/connection.test.ts +63 -0
- package/src/client/hooks/workspace/terminal/connection.ts +47 -0
- package/src/client/hooks/workspace/terminal/index.ts +35 -4
- package/src/client/hooks/workspace/workspace-folder-actions.ts +2 -1
- package/src/client/lib/native/open-session.ts +33 -0
- package/src/client/lib/notifications/os.test.ts +125 -0
- package/src/client/lib/notifications/os.ts +130 -0
- package/src/client/lib/plugins/sidebar-bridge.ts +2 -20
- package/src/client/lib/router/open-session.test.ts +75 -0
- package/src/client/lib/router/open-session.ts +34 -0
- package/src/client/lib/signals.ts +5 -1
- package/src/client/main.tsx +6 -0
- package/src/server/lib/db/schema.ts +1 -0
- package/src/server/lib/harness/acp/calls.ts +15 -1
- package/src/server/lib/harness/acp/client-capabilities.test.ts +55 -0
- package/src/server/lib/harness/acp/client-capabilities.ts +61 -0
- package/src/server/lib/harness/acp/client-fs.test.ts +135 -0
- package/src/server/lib/harness/acp/client-fs.ts +131 -0
- package/src/server/lib/harness/acp/client-initialize.test.ts +70 -0
- package/src/server/lib/harness/acp/client-initialize.ts +84 -0
- package/src/server/lib/harness/acp/client.ts +31 -21
- package/src/server/lib/harness/acp/commands.test.ts +5 -5
- package/src/server/lib/harness/acp/commands.ts +14 -2
- package/src/server/lib/harness/acp/frames-timing.test.ts +68 -0
- package/src/server/lib/harness/acp/frames-v2.test.ts +85 -0
- package/src/server/lib/harness/acp/frames.ts +71 -158
- package/src/server/lib/harness/acp/mapper.test.ts +40 -0
- package/src/server/lib/harness/acp/mapper.ts +12 -0
- package/src/server/lib/harness/acp/permissions.ts +6 -0
- package/src/server/lib/harness/acp/protocol.ts +41 -2
- package/src/server/lib/harness/acp/session-facts.ts +1 -1
- package/src/server/lib/harness/acp/session-handshake.test.ts +90 -1
- package/src/server/lib/harness/acp/session-handshake.ts +83 -6
- package/src/server/lib/harness/acp/session-idle.ts +7 -6
- package/src/server/lib/harness/acp/session-notifications.ts +41 -2
- package/src/server/lib/harness/acp/session-observers.test.ts +63 -0
- package/src/server/lib/harness/acp/session-permissions.test.ts +29 -0
- package/src/server/lib/harness/acp/session-permissions.ts +36 -0
- package/src/server/lib/harness/acp/session-requests.test.ts +92 -0
- package/src/server/lib/harness/acp/session-requests.ts +48 -6
- package/src/server/lib/harness/acp/session-turns.ts +8 -3
- package/src/server/lib/harness/acp/session-usage.ts +4 -0
- package/src/server/lib/harness/acp/session-web-state.ts +30 -2
- package/src/server/lib/harness/acp/session.test-util.ts +19 -1
- package/src/server/lib/harness/acp/session.ts +60 -60
- package/src/server/lib/harness/acp/tool-calls.ts +223 -0
- package/src/server/lib/harness/acp/turn.test.ts +102 -0
- package/src/server/lib/harness/acp/turn.ts +81 -6
- package/src/server/lib/harness/acp/v2.test.ts +144 -0
- package/src/server/lib/harness/acp/v2.ts +220 -0
- package/src/server/lib/harness/acp/verbs.ts +46 -6
- package/src/server/lib/harness/launch.test.ts +25 -0
- package/src/server/lib/harness/launch.ts +21 -9
- package/src/server/lib/harness/session.ts +3 -0
- package/src/server/lib/harness/update-job-store.test.ts +37 -12
- package/src/server/lib/harness/update-job-store.ts +22 -16
- package/src/server/lib/harness/update-job.server.ts +66 -175
- package/src/server/lib/harness/update-queue.server.ts +292 -0
- package/src/server/lib/harness/update-queue.test.ts +265 -0
- package/src/server/lib/harness/update-spawn.server.ts +96 -0
- package/src/server/lib/harness/update-worker.ts +8 -3
- package/src/server/lib/lifecycle/after-listen.ts +9 -0
- package/src/server/lib/lifecycle/paths.ts +14 -9
- package/src/server/lib/omp/rpc/run-settle.server.ts +10 -1
- package/src/server/lib/omp/rpc/subagent-liveness.ts +5 -5
- package/src/server/lib/omp/rpc/terminal-settle.ts +5 -1
- package/src/server/lib/omp/session/delete-flow.server.ts +1 -0
- package/src/server/lib/omp/session/sidebar-data.server.ts +10 -12
- package/src/server/lib/sessions/fork.server.test.ts +68 -0
- package/src/server/lib/sessions/fork.server.ts +31 -6
- package/src/server/lib/sessions/spawn.server.test.ts +41 -0
- package/src/server/lib/sessions/spawn.server.ts +27 -2
- package/src/server/lib/usage/report.server.ts +57 -0
- package/src/server/routes/agent/harness-command.ts +6 -5
- package/src/server/routes/chat/stream.ts +7 -2
- package/src/server/routes/harness/update-status.ts +18 -12
- package/src/server/routes/harness/update.test.ts +53 -16
- package/src/server/routes/harness/update.ts +13 -8
- package/src/server/routes/sessions/body-readers.ts +43 -0
- package/src/server/routes/sessions/fork.ts +19 -4
- package/src/server/routes/sessions/routes.test.ts +1 -2
- package/src/server/routes/sessions/session.ts +19 -0
- package/src/server/routes/sessions/spawn.ts +16 -13
- package/src/shared/lib/chat/omp/agent-events.ts +11 -0
- package/src/shared/lib/chat/omp/session-modes-signal.test.ts +41 -0
- package/src/shared/lib/chat/timeline/fork-preview.test.ts +62 -0
- package/src/shared/lib/chat/timeline/fork-preview.ts +36 -0
- package/src/shared/lib/harness/mode-signal.ts +20 -0
- package/src/shared/lib/harness/session-modes.ts +24 -0
- package/src/shared/lib/harness/update-job.ts +53 -6
- package/src/shared/lib/icons/tint-hues.generated.ts +34 -34
- package/src/shared/lib/notifications/outcomes.test.ts +96 -0
- package/src/shared/lib/notifications/outcomes.ts +64 -0
- package/src/shared/lib/notifications/settings.test.ts +49 -0
- package/src/shared/lib/notifications/settings.ts +34 -0
- package/src/shared/lib/omp/session/default-title.ts +5 -4
- package/src/shared/lib/omp/session/prewarm-misc.test.ts +3 -2
- package/src/shared/lib/omp/session/schema-migrations.ts +4 -0
- package/src/shared/lib/omp/session/stream-state.server.test.ts +19 -0
- package/src/shared/lib/omp/session/stream-state.server.ts +24 -4
- package/src/shared/lib/settings/defaults.ts +3 -0
- package/src/shared/lib/ui/toast-duration.test.ts +25 -1
- package/src/shared/lib/ui/toast-duration.ts +22 -4
- package/src/shared/lib/workspace/session-state/store.ts +4 -0
- package/src/shared/types/harness-update.ts +24 -0
- package/src/shared/types/realtime.ts +2 -0
- package/src/shared/types/settings/state.ts +10 -0
- package/src/shared/types/workspace.ts +4 -0
- package/src/test-support/harness-table.test-util.ts +25 -9
- package/dist/client/static/js/index-bc9aa4mx.css +0 -1
- package/src/client/components/common/session-actions-menu/NewChildSessionDialog.tsx +0 -113
- package/src/client/components/common/subagent-list/index.tsx +0 -165
- package/src/client/components/layout/session-sidebar/ChildSessionList.tsx +0 -66
- package/src/client/hooks/workspace/child-expansion.ts +0 -33
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `modern` sidebar's reveal / collapse row, below a workspace's sessions.
|
|
8
|
+
*
|
|
9
|
+
* Split out of `WorkspaceSection.tsx` so that file stays under the repo's
|
|
10
|
+
* per-file ceiling, the same way `mobile-session-sidebar/RevealRow.tsx` was
|
|
11
|
+
* split out of `Item.tsx`. The window itself is the folder hook's
|
|
12
|
+
* (`useShowMore`), so this file owns only the markup.
|
|
13
|
+
*
|
|
14
|
+
* Reveal and collapse are two controls, not one toggle: the list is truncated
|
|
15
|
+
* for height, so after a partial reveal the user needs to keep going AND to
|
|
16
|
+
* start over, which is what two controls say and one alternating control
|
|
17
|
+
* cannot.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { ChevronDown, ChevronUp } from 'lucide-preact';
|
|
21
|
+
|
|
22
|
+
interface Props {
|
|
23
|
+
hiddenCount: number;
|
|
24
|
+
canShowLess: boolean;
|
|
25
|
+
onShowMore: () => void;
|
|
26
|
+
onShowLess: () => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function WorkspaceRevealRow({ hiddenCount, canShowLess, onShowMore, onShowLess }: Props) {
|
|
30
|
+
if (hiddenCount <= 0 && !canShowLess) return null;
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div className="flex items-center gap-1 pl-6">
|
|
34
|
+
{hiddenCount > 0 && (
|
|
35
|
+
<button
|
|
36
|
+
type="button"
|
|
37
|
+
onClick={onShowMore}
|
|
38
|
+
className="min-w-0 truncate rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80"
|
|
39
|
+
>
|
|
40
|
+
<ChevronDown size={11} className="mr-1 inline align-[-2px]" />
|
|
41
|
+
{hiddenCount} more
|
|
42
|
+
</button>
|
|
43
|
+
)}
|
|
44
|
+
{canShowLess && (
|
|
45
|
+
<button
|
|
46
|
+
type="button"
|
|
47
|
+
onClick={onShowLess}
|
|
48
|
+
className="ml-auto shrink-0 rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80"
|
|
49
|
+
>
|
|
50
|
+
<ChevronUp size={11} className="mr-1 inline align-[-2px]" />
|
|
51
|
+
Less
|
|
52
|
+
</button>
|
|
53
|
+
)}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -25,28 +25,29 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import { useEffect, useState } from 'preact/hooks';
|
|
28
|
-
import { ChevronDown, ChevronUp } from 'lucide-preact';
|
|
29
28
|
import { useSearchParams } from '@/client/lib/router/search-params';
|
|
30
29
|
import { useFetcher } from '@/client/lib/router/fetcher';
|
|
31
30
|
import { useShowMore } from '@/client/hooks/ui/show-more';
|
|
32
31
|
import { useWorkspaceFolderActions } from '@/client/hooks/workspace/workspace-folder-actions';
|
|
33
32
|
import { useSessionDelete } from '@/client/hooks/workspace/session-delete';
|
|
34
33
|
import { useExpandedSessions } from '@/client/hooks/workspace/expanded-sessions';
|
|
35
|
-
import {
|
|
34
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
36
35
|
import { useSidebarData } from '@/client/hooks/chat/omp/session-list';
|
|
37
|
-
import { SessionRow, type SessionRowDensity } from '@/client/components/common/session-row';
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
36
|
+
import { SessionRow, sessionRowBranchStyle, type SessionRowDensity } from '@/client/components/common/session-row';
|
|
37
|
+
import { SessionBranch, branchControlFor } from '@/client/components/common/session-branch';
|
|
38
|
+
import type { BranchControl } from '@/client/components/common/session-branch';
|
|
40
39
|
import { buildSessionTree } from '@/client/lib/session-tree';
|
|
41
40
|
import { SessionDeleteModal } from '@/client/components/common/session-delete-modal';
|
|
42
41
|
import { WorkspaceOptionsMenu } from '@/client/components/common/workspace-options-menu';
|
|
43
42
|
import { NewWorktreeModal } from '@/client/components/workspace/worktree-modal/index';
|
|
44
43
|
import { WorkspaceHeader } from '@/client/components/layout/session-sidebar/modern/WorkspaceHeader';
|
|
44
|
+
import { WorkspaceRevealRow } from '@/client/components/layout/session-sidebar/modern/RevealRow';
|
|
45
45
|
import { folderBatchState } from '@/client/components/common/batch-selection/folder-state';
|
|
46
46
|
import { relativeTimeAgo } from '@/shared/lib/workspace/relative-time';
|
|
47
|
+
import { isPendingSessionId } from '@/shared/lib/omp/session/default-title';
|
|
47
48
|
import type { BatchBinding } from '@/client/components/common/batch-selection/types';
|
|
48
49
|
import type { SessionStatusMap } from '@/client/components/layout/session-sidebar/variant-props';
|
|
49
|
-
import type { WorkspaceFolderData } from '@/shared/types';
|
|
50
|
+
import type { SessionItemData, WorkspaceFolderData } from '@/shared/types';
|
|
50
51
|
|
|
51
52
|
export interface WorkspaceSectionProps {
|
|
52
53
|
folder: WorkspaceFolderData;
|
|
@@ -61,7 +62,7 @@ export interface WorkspaceSectionProps {
|
|
|
61
62
|
onSelectSession: (id: number | string) => void;
|
|
62
63
|
onNewSessionForFolder: (folderId: number) => void;
|
|
63
64
|
onNewWorktreeSession?: (folderId: number, worktreePath: string) => void;
|
|
64
|
-
onToast: (message: string, type?:
|
|
65
|
+
onToast: (message: string, type?: ToastTone) => void;
|
|
65
66
|
onStartSessionSelection?: (folderId: number) => void;
|
|
66
67
|
onCancelWait?: (waitId: string) => void;
|
|
67
68
|
}
|
|
@@ -89,7 +90,6 @@ export function WorkspaceSection({
|
|
|
89
90
|
const urlSubagentId = searchParams.get('subagent');
|
|
90
91
|
const urlSessionId = searchParams.get('sessionId');
|
|
91
92
|
const { expandedSessionIds, toggleSession } = useExpandedSessions();
|
|
92
|
-
const { expandedChildIds, toggleChild } = useChildExpansion();
|
|
93
93
|
const { refresh } = useSidebarData();
|
|
94
94
|
const toggleFetcher = useFetcher<{ success?: boolean }>();
|
|
95
95
|
const {
|
|
@@ -155,6 +155,48 @@ export function WorkspaceSection({
|
|
|
155
155
|
// A session selection opens every workspace: a checkbox on a collapsed folder
|
|
156
156
|
// would let the user select rows they cannot see or unselect.
|
|
157
157
|
const listOpen = forceExpanded || isOpen || sessionCheckboxes;
|
|
158
|
+
|
|
159
|
+
// Roots and descendants share this renderer: a child session is the same row as a root.
|
|
160
|
+
const renderSessionRow = (session: SessionItemData, control: BranchControl) => {
|
|
161
|
+
const key = String(session.id);
|
|
162
|
+
const isActive = activeSessionId === null ? session.is_active === 1 : String(activeSessionId) === key;
|
|
163
|
+
// While one of its subagents is viewed, the row dims so the leaf reads as the active one.
|
|
164
|
+
const viewingSubagent = isActive && urlSessionId === key && Boolean(urlSubagentId);
|
|
165
|
+
const pending = isPendingSessionId(key);
|
|
166
|
+
return (
|
|
167
|
+
<SessionRow
|
|
168
|
+
sessionId={session.id}
|
|
169
|
+
title={session.title}
|
|
170
|
+
harness={session.harness}
|
|
171
|
+
folderId={session.folder_id}
|
|
172
|
+
density={density}
|
|
173
|
+
isActive={isActive && !viewingSubagent}
|
|
174
|
+
isArchived={session.is_archived === 1}
|
|
175
|
+
status={sessionStatus[key]}
|
|
176
|
+
awaitingInput={Boolean(session.awaitingInput)}
|
|
177
|
+
timeAgo={relativeTimeAgo(session.updated_at ?? session.created_at)}
|
|
178
|
+
worktree={session.worktree}
|
|
179
|
+
waitingFor={session.waitingFor ? { title: session.waitingFor.title } : undefined}
|
|
180
|
+
expandable={control.expandable} isChild={control.isChild}
|
|
181
|
+
isExpanded={control.isExpanded}
|
|
182
|
+
onToggleExpand={control.onToggleExpand}
|
|
183
|
+
onClick={() => onSelectSession(session.id)}
|
|
184
|
+
onArchive={() => handleArchive(session)}
|
|
185
|
+
// A pending `new-…` chat has no transcript anywhere yet, so there is
|
|
186
|
+
// nothing to delete and nothing to rename from.
|
|
187
|
+
onDelete={pending ? undefined : () => sessionDelete.requestDelete(session)}
|
|
188
|
+
onRename={pending ? undefined : (name) => void handleRename(session, name)}
|
|
189
|
+
onRenameWithAi={pending ? undefined : () => void handleRenameWithAi(session)}
|
|
190
|
+
onCancelWait={session.waitingFor ? () => onCancelWait?.(session.waitingFor!.waitId) : undefined}
|
|
191
|
+
selectable={sessionCheckboxes}
|
|
192
|
+
selected={Boolean(batch?.selected.includes(key))}
|
|
193
|
+
onToggleSelect={batch ? () => batch.toggle(key) : undefined}
|
|
194
|
+
/>
|
|
195
|
+
);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const controlFor = (session: SessionItemData): BranchControl =>
|
|
199
|
+
branchControlFor(session, tree.childrenOf, expandedSessionIds, toggleSession);
|
|
158
200
|
const canCreateWorktree = Boolean(onNewWorktreeSession && folder.project_path);
|
|
159
201
|
|
|
160
202
|
return (
|
|
@@ -227,91 +269,33 @@ export function WorkspaceSection({
|
|
|
227
269
|
<div className="space-y-0.5">
|
|
228
270
|
{tree.roots.map((session) => {
|
|
229
271
|
const key = String(session.id);
|
|
230
|
-
const
|
|
231
|
-
? String(activeSessionId) === key
|
|
232
|
-
: session.is_active === 1;
|
|
233
|
-
// While one of its subagents is being viewed, the parent row dims so
|
|
234
|
-
// the highlighted roster entry reads as the active one.
|
|
235
|
-
const viewingSubagent = isActive && urlSessionId === key && Boolean(urlSubagentId);
|
|
236
|
-
const hasChildren = (tree.childrenOf.get(key)?.length ?? 0) > 0;
|
|
237
|
-
const hasSubagents = Boolean(session.hasSubagents);
|
|
238
|
-
const childrenExpanded = hasChildren && expandedChildIds.has(key);
|
|
239
|
-
const rosterExpanded = hasSubagents && expandedSessionIds.has(key);
|
|
240
|
-
const pending = key.startsWith('new-');
|
|
241
|
-
|
|
272
|
+
const control = controlFor(session);
|
|
242
273
|
return (
|
|
243
274
|
<div key={session.id} className="space-y-0.5">
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
waitingFor={session.waitingFor ? { title: session.waitingFor.title } : undefined}
|
|
256
|
-
expandable={hasChildren}
|
|
257
|
-
isExpanded={childrenExpanded}
|
|
258
|
-
onToggleExpand={() => toggleChild(key)}
|
|
259
|
-
hasSubagents={hasSubagents}
|
|
260
|
-
subagentsExpanded={rosterExpanded}
|
|
261
|
-
onToggleSubagents={() => toggleSession(key)}
|
|
262
|
-
onClick={() => onSelectSession(session.id)}
|
|
263
|
-
onArchive={() => handleArchive(session)}
|
|
264
|
-
// A pending `new-…` chat has no transcript anywhere yet, so
|
|
265
|
-
// there is nothing to delete and nothing to rename from.
|
|
266
|
-
onDelete={pending ? undefined : () => sessionDelete.requestDelete(session)}
|
|
267
|
-
onRename={pending ? undefined : (name) => void handleRename(session, name)}
|
|
268
|
-
onRenameWithAi={pending ? undefined : () => void handleRenameWithAi(session)}
|
|
269
|
-
onCancelWait={
|
|
270
|
-
session.waitingFor ? () => onCancelWait?.(session.waitingFor!.waitId) : undefined
|
|
271
|
-
}
|
|
272
|
-
selectable={sessionCheckboxes}
|
|
273
|
-
selected={Boolean(batch?.selected.includes(key))}
|
|
274
|
-
onToggleSelect={batch ? () => batch.toggle(key) : undefined}
|
|
275
|
-
/>
|
|
276
|
-
{childrenExpanded && (
|
|
277
|
-
<ChildSessionList parentId={key} childrenOf={tree.childrenOf} onSelect={onSelectSession} />
|
|
278
|
-
)}
|
|
279
|
-
{rosterExpanded && (
|
|
280
|
-
<SubagentList
|
|
281
|
-
sessionId={session.id}
|
|
282
|
-
isActiveSession={activeSessionId !== null && key === String(activeSessionId)}
|
|
275
|
+
{renderSessionRow(session, control)}
|
|
276
|
+
{control.isExpanded && (
|
|
277
|
+
<SessionBranch
|
|
278
|
+
parentId={key}
|
|
279
|
+
hasSubagents={Boolean(session.hasSubagents)}
|
|
280
|
+
childrenOf={tree.childrenOf}
|
|
281
|
+
expandedIds={expandedSessionIds}
|
|
282
|
+
onToggle={toggleSession}
|
|
283
|
+
activeSessionId={activeSessionId === null ? null : String(activeSessionId)}
|
|
284
|
+
renderSession={renderSessionRow}
|
|
285
|
+
style={sessionRowBranchStyle(density === 'touch')}
|
|
283
286
|
/>
|
|
284
287
|
)}
|
|
285
288
|
</div>
|
|
286
289
|
);
|
|
287
290
|
})}
|
|
288
291
|
|
|
289
|
-
{
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
{
|
|
295
|
-
|
|
296
|
-
type="button"
|
|
297
|
-
onClick={showMore}
|
|
298
|
-
className="min-w-0 truncate rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80"
|
|
299
|
-
>
|
|
300
|
-
<ChevronDown size={11} className="mr-1 inline align-[-2px]" />
|
|
301
|
-
{hiddenCount} more
|
|
302
|
-
</button>
|
|
303
|
-
)}
|
|
304
|
-
{canShowLess && (
|
|
305
|
-
<button
|
|
306
|
-
type="button"
|
|
307
|
-
onClick={showLess}
|
|
308
|
-
className="ml-auto shrink-0 rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80"
|
|
309
|
-
>
|
|
310
|
-
<ChevronUp size={11} className="mr-1 inline align-[-2px]" />
|
|
311
|
-
Less
|
|
312
|
-
</button>
|
|
313
|
-
)}
|
|
314
|
-
</div>
|
|
292
|
+
{!forceExpanded && !sessionCheckboxes && (
|
|
293
|
+
<WorkspaceRevealRow
|
|
294
|
+
hiddenCount={hiddenCount}
|
|
295
|
+
canShowLess={canShowLess}
|
|
296
|
+
onShowMore={showMore}
|
|
297
|
+
onShowLess={showLess}
|
|
298
|
+
/>
|
|
315
299
|
)}
|
|
316
300
|
|
|
317
301
|
{offered.length === 0 && (
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `modern` sidebar's reveal row.
|
|
8
|
+
*
|
|
9
|
+
* Two controls, never one toggle: the window is truncated for height, so a
|
|
10
|
+
* partial reveal must leave both "N more" and "Less" reachable. A single
|
|
11
|
+
* alternating control strands the user after the first reveal — the bug this
|
|
12
|
+
* row exists to prevent.
|
|
13
|
+
*
|
|
14
|
+
* Rendered with `h()` against happy-dom, following
|
|
15
|
+
* `modern/workspace-header.test.tsx`.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
19
|
+
import { Window } from 'happy-dom';
|
|
20
|
+
import { h, render } from 'preact';
|
|
21
|
+
|
|
22
|
+
import { WorkspaceRevealRow } from '@/client/components/layout/session-sidebar/modern/RevealRow';
|
|
23
|
+
|
|
24
|
+
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event', 'MouseEvent'] as const;
|
|
25
|
+
const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
|
|
26
|
+
|
|
27
|
+
let container: HTMLElement;
|
|
28
|
+
|
|
29
|
+
beforeAll(() => {
|
|
30
|
+
const win = new Window({ url: 'http://localhost' });
|
|
31
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
32
|
+
for (const key of DOM_GLOBALS) {
|
|
33
|
+
if (!(key in nativeGlobals)) nativeGlobals[key] = target[key];
|
|
34
|
+
target[key] = (win as unknown as Record<string, unknown>)[key];
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
afterAll(() => {
|
|
39
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
40
|
+
for (const key of DOM_GLOBALS) {
|
|
41
|
+
if (nativeGlobals[key] === undefined) delete target[key];
|
|
42
|
+
else target[key] = nativeGlobals[key];
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
afterEach(() => {
|
|
47
|
+
if (container) render(null, container);
|
|
48
|
+
container?.remove();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
function mount(props: { hiddenCount: number; canShowLess: boolean; onShowMore?: () => void; onShowLess?: () => void }) {
|
|
52
|
+
if (container) {
|
|
53
|
+
render(null, container);
|
|
54
|
+
container.remove();
|
|
55
|
+
}
|
|
56
|
+
container = document.createElement('div');
|
|
57
|
+
document.body.appendChild(container);
|
|
58
|
+
render(
|
|
59
|
+
h(WorkspaceRevealRow, {
|
|
60
|
+
onShowMore: () => {},
|
|
61
|
+
onShowLess: () => {},
|
|
62
|
+
...props,
|
|
63
|
+
}),
|
|
64
|
+
container,
|
|
65
|
+
);
|
|
66
|
+
return container.firstElementChild as HTMLElement | null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const buttons = () => Array.from(container.querySelectorAll('button'));
|
|
70
|
+
|
|
71
|
+
describe('modern workspace reveal row', () => {
|
|
72
|
+
test('it renders nothing when every row is already visible', () => {
|
|
73
|
+
expect(mount({ hiddenCount: 0, canShowLess: false })).toBeNull();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('it names the hidden row count on the reveal control', () => {
|
|
77
|
+
mount({ hiddenCount: 4, canShowLess: false });
|
|
78
|
+
expect(buttons()).toHaveLength(1);
|
|
79
|
+
expect(buttons()[0]!.textContent).toContain('4 more');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('a partial reveal keeps both controls on screen', () => {
|
|
83
|
+
mount({ hiddenCount: 2, canShowLess: true });
|
|
84
|
+
const labels = buttons().map((button) => button.textContent);
|
|
85
|
+
expect(labels).toHaveLength(2);
|
|
86
|
+
expect(labels[0]).toContain('2 more');
|
|
87
|
+
expect(labels[1]).toContain('Less');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('each control calls its own handler', () => {
|
|
91
|
+
const calls: string[] = [];
|
|
92
|
+
mount({
|
|
93
|
+
hiddenCount: 1,
|
|
94
|
+
canShowLess: true,
|
|
95
|
+
onShowMore: () => calls.push('more'),
|
|
96
|
+
onShowLess: () => calls.push('less'),
|
|
97
|
+
});
|
|
98
|
+
const [more, less] = buttons();
|
|
99
|
+
more!.click();
|
|
100
|
+
expect(calls).toEqual(['more']);
|
|
101
|
+
less!.click();
|
|
102
|
+
expect(calls).toEqual(['more', 'less']);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -25,6 +25,7 @@ import { TaskForm } from '@/client/components/layout/session-sidebar/scheduler-m
|
|
|
25
25
|
import { TaskList } from '@/client/components/layout/session-sidebar/scheduler-modal/TaskList';
|
|
26
26
|
import { useScheduleFolders } from '@/client/components/layout/session-sidebar/scheduler-modal/folders';
|
|
27
27
|
import type { ScheduledTask } from '@/shared/types/schedule';
|
|
28
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
28
29
|
|
|
29
30
|
export interface SchedulerModalProps {
|
|
30
31
|
isOpen: boolean;
|
|
@@ -32,7 +33,7 @@ export interface SchedulerModalProps {
|
|
|
32
33
|
/** Session the composer is on, offered as "resume this conversation". */
|
|
33
34
|
activeSessionId?: string | null;
|
|
34
35
|
/** Surfaces a failure outside the modal (the sidebar's toast stack). */
|
|
35
|
-
onToast?: (message: string, type?:
|
|
36
|
+
onToast?: (message: string, type?: ToastTone) => void;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
/** The editor's shape: a draft plus the id it edits, or null when creating. */
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
import type { SessionSortOption, WorkspaceFolderData } from '@/shared/types';
|
|
23
23
|
import type { BatchBinding } from '@/client/components/common/batch-selection/types';
|
|
24
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
24
25
|
|
|
25
26
|
export type SessionStatusMap = Record<string, 'stream' | 'finish' | 'abort'>;
|
|
26
27
|
|
|
@@ -67,7 +68,7 @@ export interface SessionSidebarVariantProps {
|
|
|
67
68
|
/** Start a chat in a worktree made from this folder. */
|
|
68
69
|
onNewWorktreeSession?: (folderId: number, worktreePath: string) => void;
|
|
69
70
|
/** Reports a refused folder action (the reveal endpoint's own reason). */
|
|
70
|
-
onToast: (message: string, type?:
|
|
71
|
+
onToast: (message: string, type?: ToastTone) => void;
|
|
71
72
|
onCancelWait?: (waitId: string) => void;
|
|
72
73
|
|
|
73
74
|
/** The active batch mode, or undefined when the list is not selecting. */
|
|
@@ -11,6 +11,7 @@ import { useWaitingDispatch } from '@/client/hooks/chat/waiting/dispatch';
|
|
|
11
11
|
import { useUpdates } from '@/client/hooks/ui/updates';
|
|
12
12
|
import { useSidebarStyle } from '@/client/hooks/workspace/sidebar-style';
|
|
13
13
|
import { UPDATE_REQUEST_EVENT } from '@/shared/lib/updates/popup-state';
|
|
14
|
+
import { updateOutcomeTone } from '@/shared/lib/ui/toast-duration';
|
|
14
15
|
import { useScheduledTaskCount } from '@/client/hooks/workspace/scheduled-tasks';
|
|
15
16
|
import { phoneLeftStripVisible } from '@/shared/lib/workspace/mobile-dock';
|
|
16
17
|
import { MobileDockBody, MobileDockStrip } from '@/client/components/mobile/mobile-session-sidebar/Dock';
|
|
@@ -123,7 +124,7 @@ export function MobileSessionSidebar({
|
|
|
123
124
|
setAboutOpen(true);
|
|
124
125
|
void updates.apply('kabmo').then((result) => {
|
|
125
126
|
if (!result) return;
|
|
126
|
-
pushToast(result.message, result
|
|
127
|
+
pushToast(result.message, updateOutcomeTone(result));
|
|
127
128
|
});
|
|
128
129
|
});
|
|
129
130
|
|
|
@@ -20,6 +20,7 @@ import { MobileSessionListSkeleton } from '@/client/components/mobile/mobile-ses
|
|
|
20
20
|
import { SessionListNotice } from '@/client/components/layout/session-sidebar/SessionListNotice';
|
|
21
21
|
import type { BatchBinding } from '@/client/components/common/batch-selection/types';
|
|
22
22
|
import type { SessionSortOption, WorkspaceFolderData } from '@/shared/types';
|
|
23
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
23
24
|
|
|
24
25
|
export interface ClassicDrawerProps {
|
|
25
26
|
folders: WorkspaceFolderData[];
|
|
@@ -54,7 +55,7 @@ export interface ClassicDrawerProps {
|
|
|
54
55
|
onNewSessionForFolder: (folderId: number) => void;
|
|
55
56
|
onNewWorktreeSession?: (folderId: number, worktreePath: string) => void;
|
|
56
57
|
onToggleFolder: (folderId: number) => void;
|
|
57
|
-
onToast: (message: string, type?:
|
|
58
|
+
onToast: (message: string, type?: ToastTone) => void;
|
|
58
59
|
onStartSessionSelection: (folderId: number) => void;
|
|
59
60
|
onCancelWait?: (waitId: string) => void;
|
|
60
61
|
}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { ChevronDown, ChevronRight, GitBranch, MessageSquare, Plus } from 'lucide-preact';
|
|
2
2
|
import { FolderItemMenu } from '@/client/components/mobile/mobile-session-sidebar/ItemMenu';
|
|
3
3
|
import { useSearchParams } from '@/client/lib/router/search-params';
|
|
4
|
-
import { MobileSessionRow } from '@/client/components/mobile/mobile-session-sidebar/SessionRow';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { MobileSessionRow, MOBILE_BRANCH_STYLE } from '@/client/components/mobile/mobile-session-sidebar/SessionRow';
|
|
5
|
+
import { SessionBranch, branchControlFor } from '@/client/components/common/session-branch';
|
|
6
|
+
import type { BranchControl } from '@/client/components/common/session-branch';
|
|
7
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
7
8
|
import { buildSessionTree } from '@/client/lib/session-tree';
|
|
8
9
|
import { useWorktreeDialog } from '@/client/components/mobile/mobile-session-sidebar/WorktreeDialog';
|
|
9
10
|
import { useShowMore } from '@/client/hooks/ui/show-more';
|
|
10
11
|
import { useExpandedSessions } from '@/client/hooks/workspace/expanded-sessions';
|
|
11
|
-
import { useChildExpansion } from '@/client/hooks/workspace/child-expansion';
|
|
12
12
|
import { useWorkspaceFolderActions } from '@/client/hooks/workspace/workspace-folder-actions';
|
|
13
13
|
import { useSessionDelete } from '@/client/hooks/workspace/session-delete';
|
|
14
14
|
import { SessionDeleteModal } from '@/client/components/common/session-delete-modal';
|
|
15
15
|
import { getProjectIcon } from '@/shared/lib/workspace/project-icon';
|
|
16
16
|
import { relativeTimeAgo } from '@/shared/lib/workspace/relative-time';
|
|
17
|
+
import { isPendingSessionId } from '@/shared/lib/omp/session/default-title';
|
|
17
18
|
import { useSidebarData } from '@/client/hooks/chat/omp/session-list';
|
|
18
|
-
import type { WorkspaceFolderData } from '@/shared/types';
|
|
19
|
+
import type { SessionItemData, WorkspaceFolderData } from '@/shared/types';
|
|
19
20
|
import type { BatchBinding } from '@/client/components/common/batch-selection/types';
|
|
20
21
|
import { folderBatchState } from '@/client/components/common/batch-selection/folder-state';
|
|
21
22
|
import { SelectionCheckbox } from '@/client/components/common/batch-selection/SelectionCheckbox';
|
|
@@ -33,7 +34,7 @@ interface MobileSessionCategoryProps {
|
|
|
33
34
|
onToggleExpand: () => void;
|
|
34
35
|
showArchived?: boolean;
|
|
35
36
|
sessionStatus?: Record<string, 'stream' | 'finish' | 'abort'>;
|
|
36
|
-
onToast?: (message: string, type?:
|
|
37
|
+
onToast?: (message: string, type?: ToastTone) => void;
|
|
37
38
|
/** Present only while a batch selection is active; absent is the normal list. */
|
|
38
39
|
batch?: BatchBinding;
|
|
39
40
|
/** Start a session selection scoped to this workspace, from its `⋯` menu. */
|
|
@@ -65,7 +66,6 @@ export function MobileSessionCategory({
|
|
|
65
66
|
);
|
|
66
67
|
const { refresh } = useSidebarData();
|
|
67
68
|
const { expandedSessionIds, toggleSession } = useExpandedSessions();
|
|
68
|
-
const { expandedChildIds, toggleChild } = useChildExpansion();
|
|
69
69
|
// The viewed transcript, so its session row dims while a roster entry is
|
|
70
70
|
// open (desktop parity — same params, same rule).
|
|
71
71
|
const [searchParams] = useSearchParams();
|
|
@@ -119,6 +119,48 @@ export function MobileSessionCategory({
|
|
|
119
119
|
const tree = buildSessionTree(visibleSessions);
|
|
120
120
|
const listOpen = isExpanded || sessionCheckboxes;
|
|
121
121
|
|
|
122
|
+
// Roots and descendants share this renderer, so the phone cannot draw a
|
|
123
|
+
// child session differently from the row it hangs under.
|
|
124
|
+
const renderSessionRow = (session: SessionItemData, control: BranchControl) => {
|
|
125
|
+
const sessionKey = String(session.id);
|
|
126
|
+
const isSessionActive = String(activeSessionId) === sessionKey;
|
|
127
|
+
// While one of its subagents is being viewed, the row dims so the
|
|
128
|
+
// highlighted leaf reads as the active one (desktop parity).
|
|
129
|
+
const isViewingSubagent = isSessionActive && urlSessionId === sessionKey && Boolean(urlSubagentId);
|
|
130
|
+
const pending = isPendingSessionId(sessionKey);
|
|
131
|
+
return (
|
|
132
|
+
<MobileSessionRow
|
|
133
|
+
session={session}
|
|
134
|
+
harness={session.harness}
|
|
135
|
+
folderId={session.folder_id}
|
|
136
|
+
isActive={isSessionActive && !isViewingSubagent}
|
|
137
|
+
status={sessionStatus[sessionKey]}
|
|
138
|
+
awaitingInput={Boolean(session.awaitingInput)}
|
|
139
|
+
timeAgo={relativeTimeAgo(session.updated_at ?? session.created_at)}
|
|
140
|
+
expandable={control.expandable} isChild={control.isChild}
|
|
141
|
+
isExpanded={control.isExpanded}
|
|
142
|
+
onToggleExpand={control.onToggleExpand}
|
|
143
|
+
onSelect={() => onSelectSession(session.id)}
|
|
144
|
+
onArchive={() => handleArchive(session)}
|
|
145
|
+
// A pending `new-…` chat has no transcript anywhere yet, so there is
|
|
146
|
+
// nothing to delete and nothing to rename from.
|
|
147
|
+
onDelete={pending ? undefined : () => sessionDelete.requestDelete(session)}
|
|
148
|
+
onRename={pending ? undefined : (name) => void handleRename(session, name)}
|
|
149
|
+
onRenameWithAi={pending ? undefined : () => void handleRenameWithAi(session)}
|
|
150
|
+
waitingFor={session.waitingFor ? { title: session.waitingFor.title } : undefined}
|
|
151
|
+
onCancelWait={
|
|
152
|
+
session.waitingFor ? () => onCancelWait?.(session.waitingFor!.waitId) : undefined
|
|
153
|
+
}
|
|
154
|
+
selectable={sessionCheckboxes}
|
|
155
|
+
selected={Boolean(batch?.selected.includes(sessionKey))}
|
|
156
|
+
onToggleSelect={batch ? () => batch.toggle(sessionKey) : undefined}
|
|
157
|
+
/>
|
|
158
|
+
);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const controlFor = (session: SessionItemData): BranchControl =>
|
|
162
|
+
branchControlFor(session, tree.childrenOf, expandedSessionIds, toggleSession);
|
|
163
|
+
|
|
122
164
|
return (
|
|
123
165
|
<div className={folderGroupGap(listOpen)} data-testid="session-folder">
|
|
124
166
|
<div
|
|
@@ -231,67 +273,22 @@ export function MobileSessionCategory({
|
|
|
231
273
|
<div className="mt-0.5 space-y-0.5">
|
|
232
274
|
{tree.roots.map((session) => {
|
|
233
275
|
const sessionKey = String(session.id);
|
|
234
|
-
const
|
|
235
|
-
// While one of its subagents is being viewed, the parent session
|
|
236
|
-
// row dims so the highlighted roster entry reads as the active one
|
|
237
|
-
// (desktop parity).
|
|
238
|
-
const isViewingSubagent = isSessionActive && urlSessionId === sessionKey && Boolean(urlSubagentId);
|
|
239
|
-
// Same gate as desktop: the omp-side loader flag is authoritative,
|
|
240
|
-
// so a session whose roster exists on disk can be opened without a
|
|
241
|
-
// live process. Children are a separate, tree-level disclosure.
|
|
242
|
-
const hasSubagents = Boolean(session.hasSubagents);
|
|
243
|
-
const hasChildren = (tree.childrenOf.get(sessionKey)?.length ?? 0) > 0;
|
|
244
|
-
const isRosterOpen = hasSubagents && expandedSessionIds.has(sessionKey);
|
|
245
|
-
const childrenOpen = hasChildren && expandedChildIds.has(sessionKey);
|
|
246
|
-
|
|
276
|
+
const control = controlFor(session);
|
|
247
277
|
return (
|
|
248
278
|
<div key={session.id} className="space-y-0.5">
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
isActive={isSessionActive && !isViewingSubagent}
|
|
253
|
-
status={sessionStatus[sessionKey]}
|
|
254
|
-
awaitingInput={Boolean(session.awaitingInput)}
|
|
255
|
-
timeAgo={relativeTimeAgo(session.updated_at ?? session.created_at)}
|
|
256
|
-
hasSubagents={hasSubagents}
|
|
257
|
-
subagentsExpanded={isRosterOpen}
|
|
258
|
-
onToggleSubagents={() => toggleSession(sessionKey)}
|
|
259
|
-
expandable={hasChildren}
|
|
260
|
-
isExpanded={childrenOpen}
|
|
261
|
-
onToggleExpand={() => toggleChild(sessionKey)}
|
|
262
|
-
onSelect={() => onSelectSession(session.id)}
|
|
263
|
-
onArchive={() => handleArchive(session)}
|
|
264
|
-
onDelete={
|
|
265
|
-
// A pending `new-…` chat has no transcript anywhere yet —
|
|
266
|
-
// there is nothing to delete, and the server refuses it.
|
|
267
|
-
sessionKey.startsWith('new-')
|
|
268
|
-
? undefined
|
|
269
|
-
: () => sessionDelete.requestDelete(session)
|
|
270
|
-
}
|
|
271
|
-
onRename={sessionKey.startsWith('new-') ? undefined : (name) => void handleRename(session, name)}
|
|
272
|
-
onRenameWithAi={
|
|
273
|
-
sessionKey.startsWith('new-') ? undefined : () => void handleRenameWithAi(session)
|
|
274
|
-
}
|
|
275
|
-
waitingFor={session.waitingFor ? { title: session.waitingFor.title } : undefined}
|
|
276
|
-
onCancelWait={
|
|
277
|
-
session.waitingFor
|
|
278
|
-
? () => onCancelWait?.(session.waitingFor!.waitId)
|
|
279
|
-
: undefined
|
|
280
|
-
}
|
|
281
|
-
selectable={sessionCheckboxes}
|
|
282
|
-
selected={Boolean(batch?.selected.includes(sessionKey))}
|
|
283
|
-
onToggleSelect={batch ? () => batch.toggle(sessionKey) : undefined}
|
|
284
|
-
/>
|
|
285
|
-
{childrenOpen && (
|
|
286
|
-
<ChildSessionList
|
|
279
|
+
{renderSessionRow(session, control)}
|
|
280
|
+
{control.isExpanded && (
|
|
281
|
+
<SessionBranch
|
|
287
282
|
parentId={sessionKey}
|
|
283
|
+
hasSubagents={Boolean(session.hasSubagents)}
|
|
288
284
|
childrenOf={tree.childrenOf}
|
|
289
|
-
|
|
285
|
+
expandedIds={expandedSessionIds}
|
|
286
|
+
onToggle={toggleSession}
|
|
287
|
+
activeSessionId={activeSessionId === null ? null : String(activeSessionId)}
|
|
288
|
+
renderSession={renderSessionRow}
|
|
289
|
+
style={MOBILE_BRANCH_STYLE}
|
|
290
290
|
/>
|
|
291
291
|
)}
|
|
292
|
-
{isRosterOpen && (
|
|
293
|
-
<SubagentList sessionId={session.id} isActiveSession={isSessionActive} />
|
|
294
|
-
)}
|
|
295
292
|
</div>
|
|
296
293
|
);
|
|
297
294
|
})}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MobileSessionCategory } from '@/client/components/mobile/mobile-session-sidebar/Item';
|
|
2
2
|
import type { BatchBinding } from '@/client/components/common/batch-selection/types';
|
|
3
3
|
import type { WorkspaceFolderData } from '@/shared/types';
|
|
4
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
4
5
|
|
|
5
6
|
interface MobileSessionListProps {
|
|
6
7
|
folders: WorkspaceFolderData[];
|
|
@@ -14,7 +15,7 @@ interface MobileSessionListProps {
|
|
|
14
15
|
onNewWorktreeSession?: (folderId: number, worktreePath: string) => void;
|
|
15
16
|
onToggleFolder: (folderId: number) => void;
|
|
16
17
|
/** Surfaces a refused folder action (the reveal endpoint's own reason). */
|
|
17
|
-
onToast?: (message: string, type?:
|
|
18
|
+
onToast?: (message: string, type?: ToastTone) => void;
|
|
18
19
|
/** Present only while a batch selection is active. */
|
|
19
20
|
batch?: BatchBinding;
|
|
20
21
|
onStartSessionSelection?: (folderId: number) => void;
|
|
@@ -89,6 +89,11 @@ describe('mobile session row status slot', () => {
|
|
|
89
89
|
const slot = el.querySelector('span.w-4');
|
|
90
90
|
expect(slot?.querySelector('svg')).toBeNull();
|
|
91
91
|
});
|
|
92
|
+
|
|
93
|
+
test('a leaf child fills the empty slot with the child mark', async () => {
|
|
94
|
+
const el = await mount({ isChild: true });
|
|
95
|
+
expect(el.querySelector('[data-testid="child-indicator"] svg')).not.toBeNull();
|
|
96
|
+
});
|
|
92
97
|
});
|
|
93
98
|
|
|
94
99
|
/**
|