@chatcode/cco-better-sidebar 0.18.0-rc.11 → 0.18.0-rc.12
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/README.md +8 -6
- package/README_EN.md +8 -6
- package/lib/client-editor.js +298 -296
- package/lib/client-mermaid.js +296 -296
- package/lib/client-registry.js +838 -601
- package/lib/client-terminal.js +299 -297
- package/lib/client.js +838 -601
- package/lib/index.js +18 -1
- package/lib/types/client/api.d.ts +4 -0
- package/lib/types/client/locales-ja.d.ts +25 -0
- package/lib/types/client/ui-tweaks/archive.d.ts +8 -23
- package/lib/types/client/ui-tweaks/branding.d.ts +1 -1
- package/lib/types/client/ui-tweaks/dom-text.d.ts +2 -0
- package/lib/types/client/ui-tweaks/index.d.ts +10 -2
- package/lib/types/ui-tweaks/config.d.ts +1 -1
- package/package.json +1 -1
- package/src/client/api.ts +3 -0
- package/src/client/locales-ja.ts +26 -0
- package/src/client/ui-tweaks/archive.tsx +118 -90
- package/src/client/ui-tweaks/branding.tsx +85 -24
- package/src/client/ui-tweaks/cachehit.tsx +24 -14
- package/src/client/ui-tweaks/dom-text.ts +12 -0
- package/src/client/ui-tweaks/index.tsx +41 -6
- package/src/index.ts +4 -1
- package/src/ui-tweaks/config.ts +1 -1
package/lib/index.js
CHANGED
|
@@ -3221,8 +3221,24 @@ var CodingPlanCatalogue = class {
|
|
|
3221
3221
|
}
|
|
3222
3222
|
}
|
|
3223
3223
|
};
|
|
3224
|
+
//#endregion
|
|
3225
|
+
//#region src/chatcode-update.ts
|
|
3226
|
+
/**
|
|
3227
|
+
* ChatCode self-update for the account menu's "check for updates / update now"
|
|
3228
|
+
* action. Mirrors the semantics of the upstream `yuanjing-wanma-cli /update`
|
|
3229
|
+
* flow (query the npm registry for the latest version, compare against the
|
|
3230
|
+
* globally installed version, then `npm install -f -g <pkg>@<latest>`), applied
|
|
3231
|
+
* to the CLI package this sidebar is responsible for.
|
|
3232
|
+
*
|
|
3233
|
+
* All subprocess work goes through `execFile` with a plain argv array (no
|
|
3234
|
+
* shell), the same posture the rest of the host uses. The npm registry (and
|
|
3235
|
+
* the global install target) is the machine running the DSH host, not the
|
|
3236
|
+
* browser.
|
|
3237
|
+
*/
|
|
3238
|
+
/** CLI package the sidebar keeps up to date. */
|
|
3239
|
+
const CHATCODE_CLI_PKG = "@chatcode/chatcode-cli";
|
|
3224
3240
|
/** The single package a "one-click update" upgrades. */
|
|
3225
|
-
const CHATCODE_UPDATE_PACKAGES = [
|
|
3241
|
+
const CHATCODE_UPDATE_PACKAGES = [CHATCODE_CLI_PKG];
|
|
3226
3242
|
/** npm registry used for both the version lookup and the global install. */
|
|
3227
3243
|
const NPM_REGISTRY = "https://registry.npmjs.org";
|
|
3228
3244
|
/** Windows ships npm as a `npm.cmd` shim, which `execFile` cannot spawn
|
|
@@ -6530,6 +6546,7 @@ function buildApi(ctx, ptyManager, agentPtyRegistry, resolved, terminalShell, ge
|
|
|
6530
6546
|
"chatcode.start": () => requireChatcodeAuth().startLogin(),
|
|
6531
6547
|
"chatcode.cancel": (payload) => requireChatcodeAuth().cancelLogin(requireString(payload, "sessionId")).then(() => ({ ok: true })),
|
|
6532
6548
|
"chatcode.logout": () => requireChatcodeAuth().logout().then(() => ({ ok: true })),
|
|
6549
|
+
"chatcode.installed-version": async () => ({ version: await installedGlobalVersion(CHATCODE_CLI_PKG) }),
|
|
6533
6550
|
"chatcode.update.check": async () => ({ packages: await checkAllChatcodeUpdates() }),
|
|
6534
6551
|
"chatcode.update.perform": async () => ({ results: await performAllUpdates(await checkAllChatcodeUpdates()) }),
|
|
6535
6552
|
"release-note.current": (payload) => {
|
|
@@ -212,6 +212,10 @@ export declare const api: {
|
|
|
212
212
|
chatcodeLogout: () => Promise<{
|
|
213
213
|
ok: true;
|
|
214
214
|
}>;
|
|
215
|
+
/** The globally installed CLI version, read from npm global modules. */
|
|
216
|
+
chatcodeInstalledVersion: (signal?: AbortSignal) => Promise<{
|
|
217
|
+
version: string | null;
|
|
218
|
+
}>;
|
|
215
219
|
/** Check both ChatCode packages (web + CLI) against the npm registry. */
|
|
216
220
|
chatcodeUpdateCheck: (signal?: AbortSignal) => Promise<{
|
|
217
221
|
packages: ChatCodeUpdateCheck[];
|
|
@@ -13,5 +13,30 @@
|
|
|
13
13
|
* - Placeholders keep `{name}` verbatim (interpolation runs after lookup).
|
|
14
14
|
* - English brand names (VS Code, Cursor, Zed, SSH) stay as-is.
|
|
15
15
|
*/
|
|
16
|
+
/** Japanese archive-management copy registered under the ui-tweaks namespace. */
|
|
17
|
+
export declare const uiTweaksArchiveJa: {
|
|
18
|
+
readonly archiveNav: "アーカイブ";
|
|
19
|
+
readonly archiveTitle: "アーカイブ済みセッション";
|
|
20
|
+
readonly archiveEmpty: "アーカイブ済みセッションはありません。";
|
|
21
|
+
readonly archiveRestore: "復元";
|
|
22
|
+
readonly archiveRestoring: "処理中…";
|
|
23
|
+
readonly archiveConfirmTitle: "セッションを完全に削除しますか?";
|
|
24
|
+
readonly archiveConfirmDescription: "所有するサブエージェントを含む {count} 件のセッション記録を完全に削除します。この操作は取り消せません。独立した分岐、ワークスペースのファイル、Git データは保持されます。";
|
|
25
|
+
readonly archiveCancel: "キャンセル";
|
|
26
|
+
readonly archiveDelete: "削除";
|
|
27
|
+
readonly archiveDeleteAll: "すべて削除";
|
|
28
|
+
readonly archiveSelectAll: "すべて選択";
|
|
29
|
+
readonly archiveSelectedCount: "{count} 件のセッションを選択中";
|
|
30
|
+
readonly archiveClearSelection: "選択を解除";
|
|
31
|
+
readonly archiveDeleteSelected: "選択したセッションを削除({count})";
|
|
32
|
+
readonly archiveDeleteFailed: "「{title}」:{error}";
|
|
33
|
+
readonly archiveRestoreAll: "すべて復元";
|
|
34
|
+
readonly archiveCount: "件のセッション";
|
|
35
|
+
readonly archiveUnavailable: "アーカイブを利用できません。";
|
|
36
|
+
readonly archiveLiveError: "このセッションは実行中です。完全に削除する前に閉じてください。";
|
|
37
|
+
readonly archiveDisabledHint: "アーカイブ管理は無効です。「UI 調整」で有効にすると、ここでアーカイブ済みセッションを復元または完全に削除できます。";
|
|
38
|
+
readonly archiveEnable: "アーカイブ管理を有効にする";
|
|
39
|
+
readonly archiveRestored: "復元しました。";
|
|
40
|
+
};
|
|
16
41
|
/** The ja dictionary (key-set-equal to zh, enforced by the type annotation in locales.ts). */
|
|
17
42
|
export declare const ja: Record<string, string>;
|
|
@@ -1,38 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dsh-ui-tweaks — Archive manager (browser half).
|
|
3
|
-
*
|
|
4
|
-
* Renders the "归档" settings section (shown in the Settings dialog; usable
|
|
5
|
-
* when the `archiveManagerEnabled` toggle in 界面调整 is on — otherwise it
|
|
6
|
-
* shows an invite card with a one-click enable). The section lists every
|
|
7
|
-
* archived session — enriched from the framework `useSessions` /
|
|
8
|
-
* `useWorkspaces` feeds — with per-row actions and batch actions that go
|
|
9
|
-
* through the same-origin archive route (`/_dsh/ui-tweaks/archive`):
|
|
10
|
-
*
|
|
11
|
-
* - **恢复** (Restore): remove the session from the archive set — its log and
|
|
12
|
-
* workspace slot are kept, so the conversation reappears in the normal
|
|
13
|
-
* sidebar list.
|
|
14
|
-
* - **全部恢复**: restore every archived session.
|
|
15
|
-
*
|
|
16
|
-
* Live (open/running) sessions are refused by the server; the client maps the
|
|
17
|
-
* `session-live` error code to localized copy.
|
|
18
|
-
* @module dsh-ui-tweaks/client/archive
|
|
19
|
-
*/
|
|
20
1
|
import type { SessionListState } from '@deepseek-ai/dsh-api-session-controller/client';
|
|
21
2
|
import type { WorkspaceSnapshot } from '@deepseek-ai/dsh-api-workspace-controller/client';
|
|
22
3
|
import type { SnapshotSelectorHook } from '@deepseek-ai/dsh-client-ui-slots';
|
|
23
4
|
import type { SettingsClient } from './index.tsx';
|
|
24
|
-
/** Locale keys
|
|
25
|
-
type ArchiveLabelKey = '
|
|
5
|
+
/** Locale keys read by archive management. */
|
|
6
|
+
type ArchiveLabelKey = 'archiveTitle' | 'archiveEmpty' | 'archiveRestore' | 'archiveRestoring' | 'archiveDelete' | 'archiveDeleteAll' | 'archiveRestoreAll' | 'archiveCount' | 'archiveDisabledHint' | 'archiveEnable' | 'unavailable' | 'archiveConfirmTitle' | 'archiveConfirmDescription' | 'archiveCancel' | 'archiveSelectAll' | 'archiveSelectedCount' | 'archiveClearSelection' | 'archiveDeleteSelected' | 'archiveDeleteFailed';
|
|
26
7
|
type Translate = (key: ArchiveLabelKey) => string;
|
|
27
|
-
export declare const ARCHIVE_CSS = "\n.dut-arc{display:grid;gap:12px;max-width:680px;padding:6px 2px 36px}\n.dut-arc-head{display:flex;align-items:center;gap:10px;padding:14px 16px 0}\n.dut-arc-head h2{margin:0;font-size:15px;font-weight:600;letter-spacing:-.01em;color:var(--dsw-alias-label-primary)}\n.dut-arc-count{font-size:11.5px;color:var(--dsw-alias-label-secondary);padding:2px 8px;border-radius:999px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1)}\n.dut-arc-spacer{flex:1}\n.dut-arc-btn{display:inline-flex;align-items:center;height:28px;padding:0 12px;border-radius:999px;border:1px solid var(--dsw-alias-border-l1);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;cursor:pointer;transition:background .15s ease,color .15s ease,border-color .15s ease}\n.dut-arc-btn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}\n.dut-arc-btn:disabled{opacity:.5;cursor:default}\n.dut-arc-btn.dut-arc-del:hover{border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 55%,transparent);color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent)}\n.dut-arc-btn.dut-arc-confirm{border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 55%,transparent);color:var(--dsw-alias-state-error-primary);font-weight:600}\n.dut-arc-body{display:grid;gap:2px;margin-top:4px}\n.dut-arc-row{display:flex;align-items:center;gap:8px;padding:10px 16px;border-radius:12px}\n.dut-arc-row:hover{background:var(--dsw-alias-interactive-bg-hover)}\n.dut-arc-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px;text-align:left;background:transparent;border:none;padding:0;
|
|
8
|
+
export declare const ARCHIVE_CSS = "\n.dut-arc{display:grid;grid-template-columns:minmax(0,1fr);gap:12px;max-width:680px;padding:6px 2px 36px}\n.dut-arc-head{display:flex;align-items:center;flex-wrap:wrap;gap:10px;padding:14px 16px 0}\n.dut-arc-head h2{margin:0;font-size:15px;font-weight:600;letter-spacing:-.01em;color:var(--dsw-alias-label-primary)}\n.dut-arc-count{font-size:11.5px;color:var(--dsw-alias-label-secondary);padding:2px 8px;border-radius:999px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1)}\n.dut-arc-spacer{flex:1}\n.dut-arc-btn{display:inline-flex;align-items:center;height:28px;padding:0 12px;border-radius:999px;border:1px solid var(--dsw-alias-border-l1);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;cursor:pointer;transition:background .15s ease,color .15s ease,border-color .15s ease}\n.dut-arc-btn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}\n.dut-arc-btn:disabled{opacity:.5;cursor:default}\n.dut-arc-btn.dut-arc-del:hover{border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 55%,transparent);color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent)}\n.dut-arc-btn.dut-arc-confirm{border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 55%,transparent);color:var(--dsw-alias-state-error-primary);font-weight:600}\n.dut-arc-body{display:grid;grid-template-columns:minmax(0,1fr);gap:2px;margin-top:4px}\n.dut-arc-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:10px;padding:12px 16px 0;font-size:12px;color:var(--dsw-alias-label-secondary)}\n.dut-arc-select{display:flex;align-items:center;gap:10px;cursor:pointer}\n.dut-arc-select input{flex-shrink:0;width:14px;height:14px;margin:0;accent-color:var(--dsw-alias-label-primary);cursor:inherit}\n.dut-arc-session{flex:1;min-width:0}\n.dut-arc-row{display:flex;align-items:center;gap:8px;padding:10px 16px;border-radius:12px}\n.dut-arc-row:hover{background:var(--dsw-alias-interactive-bg-hover)}\n.dut-arc-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px;text-align:left;background:transparent;border:none;padding:0;color:var(--dsw-alias-label-primary);font:inherit}\n.dut-arc-title{font-size:13.5px;font-weight:600;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}\n.dut-arc-sub{font-size:11.5px;color:var(--dsw-alias-label-secondary);white-space:nowrap;text-overflow:ellipsis;overflow:hidden}\n.dut-arc-empty{padding:32px 16px;text-align:center;font-size:12.5px;color:var(--dsw-alias-label-secondary)}\n.dut-arc-alert{margin:8px 16px 0;padding:8px 12px;border-radius:10px;font-size:12px;line-height:1.5;white-space:pre-line;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent);color:var(--dsw-alias-state-error-primary)}\n.dut-arc-targets{max-height:240px;overflow:auto;padding-inline-start:20px;overflow-wrap:anywhere}\n.dut-arc-off{padding:20px 16px;display:grid;gap:12px}\n.dut-arc-off p{margin:0;font-size:12.5px;line-height:1.6;color:var(--dsw-alias-label-secondary)}\n";
|
|
28
9
|
/** Install the Archive stylesheet once (idempotent); returns the disposer. */
|
|
29
10
|
export declare function installArchiveStyles(): () => void;
|
|
30
11
|
export interface ArchiveSectionProps {
|
|
31
12
|
controller: SettingsClient;
|
|
32
13
|
t: Translate;
|
|
14
|
+
restoreSession: (id: string) => Promise<void>;
|
|
15
|
+
previewDeletion: (id: string) => Promise<readonly string[]>;
|
|
16
|
+
deleteSession: (id: string, scope: readonly string[]) => Promise<void>;
|
|
33
17
|
/** Framework standard feeds: session list + workspace archive set. */
|
|
34
18
|
useSessions: SnapshotSelectorHook<SessionListState>;
|
|
35
19
|
useWorkspaces: SnapshotSelectorHook<WorkspaceSnapshot>;
|
|
36
20
|
}
|
|
37
|
-
|
|
21
|
+
/** Select archived sessions for confirmed deletion, retaining failed targets for retry. */
|
|
22
|
+
export declare function ArchiveSection({ controller, t, restoreSession, previewDeletion, deleteSession, useSessions, useWorkspaces }: ArchiveSectionProps): import("react").JSX.Element;
|
|
38
23
|
export {};
|
|
@@ -40,6 +40,6 @@ export declare function SidebarProjectLogo({ size }: {
|
|
|
40
40
|
}): ReactNode;
|
|
41
41
|
/** Expanded-sidebar wordmark supplied through the host's dedicated slot. */
|
|
42
42
|
export declare function SidebarProjectName(): ReactNode;
|
|
43
|
-
export declare const BRANDING_CSS = "\n/*
|
|
43
|
+
export declare const BRANDING_CSS = "\n/* Solid branding is limited to primary actions. Question choices only get a\n faint token-derived tint; other surfaces remain owned by the host theme. */\nbody:not([data-ds-dark-theme]) .dut-unicom-primary-action{background:linear-gradient(135deg,#9B0B09,#b71916) !important;border-color:#9B0B09 !important;color:#fff !important;box-shadow:0 7px 18px rgba(155,11,9,.24) !important}\nbody:not([data-ds-dark-theme]) .dut-unicom-primary-action:hover{background:linear-gradient(135deg,#b71916,#cf302c) !important;border-color:#b71916 !important;color:#fff !important;box-shadow:0 10px 24px rgba(155,11,9,.30) !important}\nbody:not([data-ds-dark-theme]) .dut-unicom-primary-action:active{transform:translateY(1px);box-shadow:0 4px 11px rgba(155,11,9,.22) !important}\n/* In dark mode, alter only the resting background of primary buttons. Once\n hovered, the host owns the complete interaction treatment again. */\nbody[data-ds-dark-theme] .dut-unicom-primary-action:not(:hover){background:#9B0B09 !important}\n/* Only the host's question composer, never global radio/checkbox controls.\n Keep normal text, focus rings and disabled behavior; no gradient or shadow. */\n[data-question-key] button:is([role=\"radio\"],[role=\"checkbox\"]):hover:not(:disabled){background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 5%,transparent)}\n[data-question-key] button:is([role=\"radio\"],[role=\"checkbox\"])[aria-checked=\"true\"]{background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 8%,transparent);border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 18%,transparent)}\n[data-question-key] button:is([role=\"radio\"],[role=\"checkbox\"])[aria-checked=\"true\"]:hover:not(:disabled){background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent)}\n.dut-project-logo{display:block;object-fit:contain}\n.dut-left-logo{width:24px !important;height:24px !important}\n/* Legacy host marks remain in React's tree; only their painted appearance changes. */\nsvg.dut-project-logo{background:url(\"/_dsh/ui-tweaks/assets/logo.svg\") center/contain no-repeat}\nsvg.dut-project-logo>*{visibility:hidden}\n.dut-brand-title{font:var(--dsw-font-s-strong-14) !important}\n.dut-sidebar-logo{width:24px !important;height:24px !important}\n.dut-sidebar-brand-name{font:var(--dsw-font-s-strong-14) !important;letter-spacing:-.01em !important;white-space:nowrap}\n/* The version the plugin injects beside the sidebar wordmark. */\n.dut-sidebar-version{margin-left:8px;font-size:12px !important;font-weight:500 !important;line-height:22px !important;color:var(--dsw-alias-label-secondary) !important;letter-spacing:0 !important;white-space:nowrap}\n.dut-version-row-hidden{display:none !important}\n\n.dut-sidebar-header{height:44px !important;padding:0 4px !important;margin-bottom:8px !important;gap:8px !important}\n.dut-sidebar-brand{min-width:0 !important;background:transparent !important;box-shadow:none !important}\n.dut-sidebar-identity{height:24px !important;gap:8px !important}\n.dut-sidebar-wordmark{font:var(--dsw-font-s-strong-14) !important;letter-spacing:-.01em !important;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.dut-sidebar-toggle{width:28px !important;height:28px !important;border-radius:8px !important;color:var(--dsw-alias-label-secondary) !important}\n.dut-sidebar-toggle:hover{background:var(--dsw-alias-interactive-bg-hover) !important}\n/* Reuse the original ChatCode primary-action red, scoped to this marked CTA. */\n.dut-sidebar-new-session{height:40px !important;justify-content:flex-start !important;gap:8px !important;margin:0 0 10px !important;padding:8px 10px !important;border:1px solid #9B0B09 !important;border-radius:10px !important;background:linear-gradient(135deg,#9B0B09,#b71916) !important;color:#fff !important;font:var(--dsw-font-s-strong-14) !important;font-weight:600 !important;box-shadow:none !important;transform:none !important}\n.dut-sidebar-new-session:hover{background:linear-gradient(135deg,#b71916,#cf302c) !important}\n.dut-sidebar-new-session:active{background:#9B0B09 !important}\n.dut-sidebar-new-session:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}\n.dut-sidebar-new-session > span:first-child{flex:1;min-width:0;overflow:hidden;mask-image:none !important}\n.dut-sidebar-new-session > span:first-child > span{width:auto !important;justify-content:flex-start !important;gap:8px !important;min-width:0}\n.dut-sidebar-new-session > span:first-child > span > svg{width:16px;height:16px;flex:none;color:inherit}\n.dut-sidebar-new-session > span:first-child > span > span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.dut-sidebar-new-session > span + span{opacity:1 !important;flex:none;color:color-mix(in srgb,currentColor 75%,transparent);font:var(--dsw-font-xxs-12)}\n/* Temporary navigation-only hide. Remove this block to restore Plugins;\n registrations, settings, installed plugins and other panel entries stay intact. */\nnav:is([aria-label=\"\u5168\u5C40\u9762\u677F\"],[aria-label=\"Global panels\"]) > button:is([aria-label=\"\u63D2\u4EF6\"],[aria-label=\"Plugins\"]),\nnav:is([aria-label=\"\u5168\u5C40\u9762\u677F\"],[aria-label=\"Global panels\"]):has(> button:is([aria-label=\"\u63D2\u4EF6\"],[aria-label=\"Plugins\"]):only-child){display:none !important}\n\n.dut-brand-version{display:none !important}\n.dut-hero-preview{display:none !important}\n.dut-hero-logo{width:60px !important;height:60px !important}\n.dut-hero-title{font-size:30px !important;line-height:40px !important;font-weight:600 !important;letter-spacing:.06em !important;white-space:nowrap}\n[class*=\"headline\"]:has(.dut-hero-logo){grid-template-columns:60px auto !important;font-size:30px !important;line-height:40px !important}\n.dut-settings-logo{width:19px;height:19px;object-fit:contain}\n";
|
|
44
44
|
/** Install the brand theme and retain it across host navigation/rerenders. */
|
|
45
45
|
export declare function installBranding(): () => void;
|
|
@@ -70,7 +70,7 @@ declare const en: {
|
|
|
70
70
|
readonly gitBarOn: "On";
|
|
71
71
|
readonly gitBarOff: "Off";
|
|
72
72
|
readonly archiveManager: "Archive manager";
|
|
73
|
-
readonly archiveManagerHint: "An Archive settings page to
|
|
73
|
+
readonly archiveManagerHint: "An Archive settings page to restore or permanently delete archived sessions.";
|
|
74
74
|
readonly archiveManagerOn: "On";
|
|
75
75
|
readonly archiveManagerOff: "Off";
|
|
76
76
|
readonly mcpManager: "MCP manager";
|
|
@@ -169,13 +169,21 @@ declare const en: {
|
|
|
169
169
|
readonly archiveEmpty: "No archived sessions.";
|
|
170
170
|
readonly archiveRestore: "Restore";
|
|
171
171
|
readonly archiveRestoring: "Working…";
|
|
172
|
+
readonly archiveConfirmTitle: "Permanently delete sessions?";
|
|
173
|
+
readonly archiveConfirmDescription: "Delete {count} session records including owned subagents? This cannot be undone. Independent forks, workspace files and Git data are retained.";
|
|
174
|
+
readonly archiveCancel: "Cancel";
|
|
172
175
|
readonly archiveDelete: "Delete";
|
|
173
176
|
readonly archiveDeleteAll: "Delete all";
|
|
177
|
+
readonly archiveSelectAll: "Select all";
|
|
178
|
+
readonly archiveSelectedCount: "{count} sessions selected";
|
|
179
|
+
readonly archiveClearSelection: "Clear selection";
|
|
180
|
+
readonly archiveDeleteSelected: "Delete selected ({count})";
|
|
181
|
+
readonly archiveDeleteFailed: "{title}: {error}";
|
|
174
182
|
readonly archiveRestoreAll: "Restore all";
|
|
175
183
|
readonly archiveCount: "sessions";
|
|
176
184
|
readonly archiveUnavailable: "Archive unavailable.";
|
|
177
185
|
readonly archiveLiveError: "This session is running; close it before permanently deleting it.";
|
|
178
|
-
readonly archiveDisabledHint: "Archive management is off. Turn it on in 界面调整 (UI Tweaks) to
|
|
186
|
+
readonly archiveDisabledHint: "Archive management is off. Turn it on in 界面调整 (UI Tweaks) to restore or permanently delete archived sessions here.";
|
|
179
187
|
readonly archiveEnable: "Enable archive management";
|
|
180
188
|
readonly archiveRestored: "Restored.";
|
|
181
189
|
readonly defaultAction: "Default";
|
|
@@ -46,7 +46,7 @@ export interface UITweaksConfig {
|
|
|
46
46
|
gitBarEnabled?: boolean;
|
|
47
47
|
/**
|
|
48
48
|
* Whether the Archive manager is shown: the "归档" Settings page that lists
|
|
49
|
-
* archived sessions and can restore
|
|
49
|
+
* archived sessions and can restore or confirm permanent deletion through the shared Host. Off by
|
|
50
50
|
* default; users turn it on in Settings.
|
|
51
51
|
*/
|
|
52
52
|
archiveManagerEnabled?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatcode/cco-better-sidebar",
|
|
3
|
-
"version": "0.18.0-rc.
|
|
3
|
+
"version": "0.18.0-rc.12",
|
|
4
4
|
"description": "ChatCode CLI Web plugin: a VS Code-like right sidebar (explorer / editor / terminal / git / browser), isolated per conversation session. Exposes a service for other plugins to register sidebar tabs and file viewers.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
package/src/client/api.ts
CHANGED
|
@@ -300,6 +300,9 @@ export const api = {
|
|
|
300
300
|
chatcodeStart: () => call<{ sessionId: string; url: string }>('chatcode.start', {}),
|
|
301
301
|
chatcodeCancel: (sessionId: string) => call<{ ok: true }>('chatcode.cancel', { sessionId }),
|
|
302
302
|
chatcodeLogout: () => call<{ ok: true }>('chatcode.logout', {}),
|
|
303
|
+
/** The globally installed CLI version, read from npm global modules. */
|
|
304
|
+
chatcodeInstalledVersion: (signal?: AbortSignal) =>
|
|
305
|
+
call<{ version: string | null }>('chatcode.installed-version', {}, signal),
|
|
303
306
|
/** Check both ChatCode packages (web + CLI) against the npm registry. */
|
|
304
307
|
chatcodeUpdateCheck: (signal?: AbortSignal) =>
|
|
305
308
|
call<{ packages: ChatCodeUpdateCheck[] }>('chatcode.update.check', {}, signal),
|
package/src/client/locales-ja.ts
CHANGED
|
@@ -14,6 +14,32 @@
|
|
|
14
14
|
* - English brand names (VS Code, Cursor, Zed, SSH) stay as-is.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
/** Japanese archive-management copy registered under the ui-tweaks namespace. */
|
|
18
|
+
export const uiTweaksArchiveJa = {
|
|
19
|
+
archiveNav: 'アーカイブ',
|
|
20
|
+
archiveTitle: 'アーカイブ済みセッション',
|
|
21
|
+
archiveEmpty: 'アーカイブ済みセッションはありません。',
|
|
22
|
+
archiveRestore: '復元',
|
|
23
|
+
archiveRestoring: '処理中…',
|
|
24
|
+
archiveConfirmTitle: 'セッションを完全に削除しますか?',
|
|
25
|
+
archiveConfirmDescription: '所有するサブエージェントを含む {count} 件のセッション記録を完全に削除します。この操作は取り消せません。独立した分岐、ワークスペースのファイル、Git データは保持されます。',
|
|
26
|
+
archiveCancel: 'キャンセル',
|
|
27
|
+
archiveDelete: '削除',
|
|
28
|
+
archiveDeleteAll: 'すべて削除',
|
|
29
|
+
archiveSelectAll: 'すべて選択',
|
|
30
|
+
archiveSelectedCount: '{count} 件のセッションを選択中',
|
|
31
|
+
archiveClearSelection: '選択を解除',
|
|
32
|
+
archiveDeleteSelected: '選択したセッションを削除({count})',
|
|
33
|
+
archiveDeleteFailed: '「{title}」:{error}',
|
|
34
|
+
archiveRestoreAll: 'すべて復元',
|
|
35
|
+
archiveCount: '件のセッション',
|
|
36
|
+
archiveUnavailable: 'アーカイブを利用できません。',
|
|
37
|
+
archiveLiveError: 'このセッションは実行中です。完全に削除する前に閉じてください。',
|
|
38
|
+
archiveDisabledHint: 'アーカイブ管理は無効です。「UI 調整」で有効にすると、ここでアーカイブ済みセッションを復元または完全に削除できます。',
|
|
39
|
+
archiveEnable: 'アーカイブ管理を有効にする',
|
|
40
|
+
archiveRestored: '復元しました。',
|
|
41
|
+
} as const
|
|
42
|
+
|
|
17
43
|
/** The ja dictionary (key-set-equal to zh, enforced by the type annotation in locales.ts). */
|
|
18
44
|
export const ja: Record<string, string> = {
|
|
19
45
|
pluginMarketTitle: 'プラグインマーケット',
|
|
@@ -1,75 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Renders the "归档" settings section (shown in the Settings dialog; usable
|
|
5
|
-
* when the `archiveManagerEnabled` toggle in 界面调整 is on — otherwise it
|
|
6
|
-
* shows an invite card with a one-click enable). The section lists every
|
|
7
|
-
* archived session — enriched from the framework `useSessions` /
|
|
8
|
-
* `useWorkspaces` feeds — with per-row actions and batch actions that go
|
|
9
|
-
* through the same-origin archive route (`/_dsh/ui-tweaks/archive`):
|
|
10
|
-
*
|
|
11
|
-
* - **恢复** (Restore): remove the session from the archive set — its log and
|
|
12
|
-
* workspace slot are kept, so the conversation reappears in the normal
|
|
13
|
-
* sidebar list.
|
|
14
|
-
* - **全部恢复**: restore every archived session.
|
|
15
|
-
*
|
|
16
|
-
* Live (open/running) sessions are refused by the server; the client maps the
|
|
17
|
-
* `session-live` error code to localized copy.
|
|
18
|
-
* @module dsh-ui-tweaks/client/archive
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
import { useMemo, useState, useSyncExternalStore } from 'react'
|
|
1
|
+
/** Archived sessions use the shared Host operations for restore and confirmed deletion. */
|
|
2
|
+
import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react'
|
|
3
|
+
import { Button, Modal } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
22
4
|
import type { SessionListState, SessionSummary } from '@deepseek-ai/dsh-api-session-controller/client'
|
|
23
5
|
import type { WorkspaceSnapshot } from '@deepseek-ai/dsh-api-workspace-controller/client'
|
|
24
6
|
import type { SnapshotSelectorHook } from '@deepseek-ai/dsh-client-ui-slots'
|
|
25
7
|
import type { SettingsClient } from './index.tsx'
|
|
26
8
|
|
|
27
|
-
/**
|
|
28
|
-
const ARCHIVE_ROUTE = '/_dsh/ui-tweaks/archive'
|
|
29
|
-
|
|
30
|
-
/** Locale keys the Archive manager reads off the `ui-tweaks` dictionary. */
|
|
9
|
+
/** Locale keys read by archive management. */
|
|
31
10
|
type ArchiveLabelKey =
|
|
32
|
-
| '
|
|
33
|
-
| 'archiveDelete' | 'archiveDeleteAll' | 'archiveRestoreAll'
|
|
34
|
-
| '
|
|
35
|
-
| '
|
|
36
|
-
|
|
11
|
+
| 'archiveTitle' | 'archiveEmpty' | 'archiveRestore' | 'archiveRestoring'
|
|
12
|
+
| 'archiveDelete' | 'archiveDeleteAll' | 'archiveRestoreAll' | 'archiveCount'
|
|
13
|
+
| 'archiveDisabledHint' | 'archiveEnable' | 'unavailable'
|
|
14
|
+
| 'archiveConfirmTitle' | 'archiveConfirmDescription' | 'archiveCancel'
|
|
15
|
+
| 'archiveSelectAll' | 'archiveSelectedCount' | 'archiveClearSelection'
|
|
16
|
+
| 'archiveDeleteSelected' | 'archiveDeleteFailed'
|
|
37
17
|
type Translate = (key: ArchiveLabelKey) => string
|
|
38
18
|
|
|
39
|
-
interface ApiSuccess<T> { ok: true; value: T }
|
|
40
|
-
interface ApiFailure { ok: false; error: { code: string; message: string } }
|
|
41
|
-
|
|
42
|
-
interface ArchiveSnapshot {
|
|
43
|
-
archivedSessionIds: string[]
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Fetch one archive route call, attaching the server error code when present. */
|
|
47
|
-
async function archiveRequest<T>(init?: RequestInit): Promise<T> {
|
|
48
|
-
const response = await fetch(ARCHIVE_ROUTE, { credentials: 'same-origin', ...init })
|
|
49
|
-
let body: ApiSuccess<T> | ApiFailure | undefined
|
|
50
|
-
try {
|
|
51
|
-
body = await response.json() as ApiSuccess<T> | ApiFailure
|
|
52
|
-
} catch {
|
|
53
|
-
// Non-JSON response (e.g. the route is not mounted yet) — fall through to
|
|
54
|
-
// a clean error instead of a JSON-parse exception.
|
|
55
|
-
body = undefined
|
|
56
|
-
}
|
|
57
|
-
if (!response.ok || body === undefined || !body.ok) {
|
|
58
|
-
const failure = body as ApiFailure | undefined
|
|
59
|
-
const error = new Error(failure?.error?.message ?? `UI Tweaks archive request failed with HTTP ${response.status}`) as Error & { code: string | undefined }
|
|
60
|
-
error.code = failure?.error?.code
|
|
61
|
-
throw error
|
|
62
|
-
}
|
|
63
|
-
return body.value
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** Map a thrown archive error to user-facing copy. */
|
|
67
|
-
function errorMessage(error: unknown, t: Translate): string {
|
|
68
|
-
const code = (error as { code?: string } | null)?.code
|
|
69
|
-
if (code === 'session-live') return t('archiveLiveError')
|
|
70
|
-
return error instanceof Error ? error.message : String(error)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
19
|
/** Workspace display title: the path's last non-empty segment. */
|
|
74
20
|
function basenameOf(path: string | undefined): string {
|
|
75
21
|
if (path === undefined || path === '') return ''
|
|
@@ -90,8 +36,8 @@ function relativeTime(ms: number, now: number, formatter: Intl.RelativeTimeForma
|
|
|
90
36
|
}
|
|
91
37
|
|
|
92
38
|
export const ARCHIVE_CSS = `
|
|
93
|
-
.dut-arc{display:grid;gap:12px;max-width:680px;padding:6px 2px 36px}
|
|
94
|
-
.dut-arc-head{display:flex;align-items:center;gap:10px;padding:14px 16px 0}
|
|
39
|
+
.dut-arc{display:grid;grid-template-columns:minmax(0,1fr);gap:12px;max-width:680px;padding:6px 2px 36px}
|
|
40
|
+
.dut-arc-head{display:flex;align-items:center;flex-wrap:wrap;gap:10px;padding:14px 16px 0}
|
|
95
41
|
.dut-arc-head h2{margin:0;font-size:15px;font-weight:600;letter-spacing:-.01em;color:var(--dsw-alias-label-primary)}
|
|
96
42
|
.dut-arc-count{font-size:11.5px;color:var(--dsw-alias-label-secondary);padding:2px 8px;border-radius:999px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1)}
|
|
97
43
|
.dut-arc-spacer{flex:1}
|
|
@@ -100,14 +46,19 @@ export const ARCHIVE_CSS = `
|
|
|
100
46
|
.dut-arc-btn:disabled{opacity:.5;cursor:default}
|
|
101
47
|
.dut-arc-btn.dut-arc-del:hover{border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 55%,transparent);color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent)}
|
|
102
48
|
.dut-arc-btn.dut-arc-confirm{border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 55%,transparent);color:var(--dsw-alias-state-error-primary);font-weight:600}
|
|
103
|
-
.dut-arc-body{display:grid;gap:2px;margin-top:4px}
|
|
49
|
+
.dut-arc-body{display:grid;grid-template-columns:minmax(0,1fr);gap:2px;margin-top:4px}
|
|
50
|
+
.dut-arc-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:10px;padding:12px 16px 0;font-size:12px;color:var(--dsw-alias-label-secondary)}
|
|
51
|
+
.dut-arc-select{display:flex;align-items:center;gap:10px;cursor:pointer}
|
|
52
|
+
.dut-arc-select input{flex-shrink:0;width:14px;height:14px;margin:0;accent-color:var(--dsw-alias-label-primary);cursor:inherit}
|
|
53
|
+
.dut-arc-session{flex:1;min-width:0}
|
|
104
54
|
.dut-arc-row{display:flex;align-items:center;gap:8px;padding:10px 16px;border-radius:12px}
|
|
105
55
|
.dut-arc-row:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
106
|
-
.dut-arc-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px;text-align:left;background:transparent;border:none;padding:0;
|
|
56
|
+
.dut-arc-main{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px;text-align:left;background:transparent;border:none;padding:0;color:var(--dsw-alias-label-primary);font:inherit}
|
|
107
57
|
.dut-arc-title{font-size:13.5px;font-weight:600;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}
|
|
108
58
|
.dut-arc-sub{font-size:11.5px;color:var(--dsw-alias-label-secondary);white-space:nowrap;text-overflow:ellipsis;overflow:hidden}
|
|
109
59
|
.dut-arc-empty{padding:32px 16px;text-align:center;font-size:12.5px;color:var(--dsw-alias-label-secondary)}
|
|
110
|
-
.dut-arc-alert{margin:8px 16px 0;padding:8px 12px;border-radius:10px;font-size:12px;line-height:1.5;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent);color:var(--dsw-alias-state-error-primary)}
|
|
60
|
+
.dut-arc-alert{margin:8px 16px 0;padding:8px 12px;border-radius:10px;font-size:12px;line-height:1.5;white-space:pre-line;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent);color:var(--dsw-alias-state-error-primary)}
|
|
61
|
+
.dut-arc-targets{max-height:240px;overflow:auto;padding-inline-start:20px;overflow-wrap:anywhere}
|
|
111
62
|
.dut-arc-off{padding:20px 16px;display:grid;gap:12px}
|
|
112
63
|
.dut-arc-off p{margin:0;font-size:12.5px;line-height:1.6;color:var(--dsw-alias-label-secondary)}
|
|
113
64
|
`
|
|
@@ -134,17 +85,24 @@ interface ArchiveRow {
|
|
|
134
85
|
export interface ArchiveSectionProps {
|
|
135
86
|
controller: SettingsClient
|
|
136
87
|
t: Translate
|
|
88
|
+
restoreSession: (id: string) => Promise<void>
|
|
89
|
+
previewDeletion: (id: string) => Promise<readonly string[]>
|
|
90
|
+
deleteSession: (id: string, scope: readonly string[]) => Promise<void>
|
|
137
91
|
/** Framework standard feeds: session list + workspace archive set. */
|
|
138
92
|
useSessions: SnapshotSelectorHook<SessionListState>
|
|
139
93
|
useWorkspaces: SnapshotSelectorHook<WorkspaceSnapshot>
|
|
140
94
|
}
|
|
141
95
|
|
|
142
|
-
|
|
96
|
+
/** Select archived sessions for confirmed deletion, retaining failed targets for retry. */
|
|
97
|
+
export function ArchiveSection({ controller, t, restoreSession, previewDeletion, deleteSession, useSessions, useWorkspaces }: ArchiveSectionProps) {
|
|
143
98
|
const settingsState = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot)
|
|
144
99
|
const enabled = settingsState.value?.archiveManagerEnabled === true
|
|
145
100
|
const sessions = useSessions(state => state)
|
|
146
101
|
const workspaces = useWorkspaces(state => state)
|
|
147
102
|
const [busy, setBusy] = useState<string | null>(null)
|
|
103
|
+
const busyRef = useRef(false)
|
|
104
|
+
const [selected, setSelected] = useState<readonly string[]>([])
|
|
105
|
+
const [deletion, setDeletion] = useState<readonly { id: string; title: string; scope: readonly string[] }[] | null>(null)
|
|
148
106
|
const [error, setError] = useState<string | null>(null)
|
|
149
107
|
const timeFormatter = useMemo(() => new Intl.RelativeTimeFormat(navigator.language, { numeric: 'auto' }), [])
|
|
150
108
|
const now = Date.now()
|
|
@@ -157,26 +115,62 @@ export function ArchiveSection({ controller, t, useSessions, useWorkspaces }: Ar
|
|
|
157
115
|
return tb - ta
|
|
158
116
|
})
|
|
159
117
|
}, [workspaces.archivedSessionIds, sessions.byId])
|
|
118
|
+
const selectedSet = useMemo(() => new Set(selected), [selected])
|
|
119
|
+
const selectedIds = rows.filter(row => selectedSet.has(row.id)).map(row => row.id)
|
|
120
|
+
const allSelected = rows.length > 0 && selectedIds.length === rows.length
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
const available = new Set(rows.map(row => row.id))
|
|
123
|
+
setSelected(previous => previous.every(id => available.has(id)) ? previous : previous.filter(id => available.has(id)))
|
|
124
|
+
}, [rows])
|
|
160
125
|
|
|
161
|
-
const run = (key: string,
|
|
126
|
+
const run = async (key: string, operation: () => Promise<void>): Promise<void> => {
|
|
127
|
+
if (busyRef.current) return
|
|
128
|
+
busyRef.current = true
|
|
162
129
|
setBusy(key)
|
|
163
130
|
setError(null)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
body: JSON.stringify(body),
|
|
168
|
-
}).catch((reason: unknown) => {
|
|
169
|
-
setError(errorMessage(reason, t))
|
|
170
|
-
}).finally(() => { setBusy(current => (current === key ? null : current)) })
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const restore = (id: string): void => {
|
|
174
|
-
run(`restore:${id}`, { action: 'restore', sessionId: id })
|
|
131
|
+
try { await operation() }
|
|
132
|
+
catch (reason) { setError(reason instanceof Error ? reason.message : String(reason)) }
|
|
133
|
+
finally { busyRef.current = false; setBusy(null) }
|
|
175
134
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
135
|
+
const restore = (id: string): void => { void run(`restore:${id}`, async () => {
|
|
136
|
+
await restoreSession(id)
|
|
137
|
+
setSelected(previous => previous.filter(value => value !== id))
|
|
138
|
+
}) }
|
|
139
|
+
const restoreAll = (): void => { void run('restore-all', async () => {
|
|
140
|
+
for (const row of rows) {
|
|
141
|
+
await restoreSession(row.id)
|
|
142
|
+
setSelected(previous => previous.filter(id => id !== row.id))
|
|
143
|
+
}
|
|
144
|
+
}) }
|
|
145
|
+
const requestDelete = (ids: readonly string[]): void => { void run('preview-delete', async () => {
|
|
146
|
+
const targets = []
|
|
147
|
+
const titles = new Map(rows.map(row => [row.id, row.summary?.displayTitle ?? row.id]))
|
|
148
|
+
for (const id of ids) targets.push({ id, title: titles.get(id) ?? id, scope: await previewDeletion(id) })
|
|
149
|
+
if (targets.length > 0) setDeletion(targets)
|
|
150
|
+
}) }
|
|
151
|
+
const confirmDelete = (): void => {
|
|
152
|
+
if (deletion === null) return
|
|
153
|
+
void run('delete', async () => {
|
|
154
|
+
const failed = []
|
|
155
|
+
const failures: string[] = []
|
|
156
|
+
for (const target of deletion) {
|
|
157
|
+
try { await deleteSession(target.id, target.scope) }
|
|
158
|
+
catch (reason) {
|
|
159
|
+
failed.push(target)
|
|
160
|
+
const message = reason instanceof Error ? reason.message : String(reason)
|
|
161
|
+
failures.push(deletion.length > 1
|
|
162
|
+
? t('archiveDeleteFailed').replace('{title}', () => target.title).replace('{error}', () => message)
|
|
163
|
+
: message)
|
|
164
|
+
continue
|
|
165
|
+
}
|
|
166
|
+
const removed = new Set([target.id, ...target.scope])
|
|
167
|
+
setSelected(previous => previous.filter(id => !removed.has(id)))
|
|
168
|
+
}
|
|
169
|
+
setDeletion(failed.length > 0 ? failed : null)
|
|
170
|
+
if (failures.length > 0) setError(failures.join('\n'))
|
|
171
|
+
})
|
|
179
172
|
}
|
|
173
|
+
const dismissDeletion = (): void => { if (!busyRef.current) { setDeletion(null); setError(null) } }
|
|
180
174
|
|
|
181
175
|
if (!enabled) {
|
|
182
176
|
return (
|
|
@@ -203,10 +197,25 @@ export function ArchiveSection({ controller, t, useSessions, useWorkspaces }: Ar
|
|
|
203
197
|
{rows.length > 1 ? (
|
|
204
198
|
<>
|
|
205
199
|
<button type="button" className="dut-arc-btn" disabled={busy !== null} onClick={restoreAll}>{busy === 'restore-all' ? t('archiveRestoring') : t('archiveRestoreAll')}</button>
|
|
200
|
+
<button type="button" className="dut-arc-btn dut-arc-del" disabled={busy !== null} onClick={() => requestDelete(rows.map(row => row.id))}>{t('archiveDeleteAll')}</button>
|
|
206
201
|
</>
|
|
207
202
|
) : null}
|
|
208
203
|
</div>
|
|
209
|
-
{
|
|
204
|
+
{rows.length > 0 && <div className="dut-arc-toolbar">
|
|
205
|
+
<label className="dut-arc-select">
|
|
206
|
+
<input type="checkbox" checked={allSelected} disabled={busy !== null}
|
|
207
|
+
ref={input => { if (input !== null) input.indeterminate = selectedIds.length > 0 && !allSelected }}
|
|
208
|
+
onChange={event => { setSelected(event.target.checked ? rows.map(row => row.id) : []) }} />
|
|
209
|
+
<span>{t('archiveSelectAll')}</span>
|
|
210
|
+
</label>
|
|
211
|
+
<span role="status">{t('archiveSelectedCount').replace('{count}', String(selectedIds.length))}</span>
|
|
212
|
+
<span className="dut-arc-spacer" />
|
|
213
|
+
<button type="button" className="dut-arc-btn" disabled={busy !== null || selectedIds.length === 0}
|
|
214
|
+
onClick={() => { setSelected([]) }}>{t('archiveClearSelection')}</button>
|
|
215
|
+
<button type="button" className="dut-arc-btn dut-arc-del" disabled={busy !== null || selectedIds.length === 0}
|
|
216
|
+
onClick={() => requestDelete(selectedIds)}>{t('archiveDeleteSelected').replace('{count}', String(selectedIds.length))}</button>
|
|
217
|
+
</div>}
|
|
218
|
+
{error !== null && deletion === null ? <div role="alert" className="dut-arc-alert">{error}</div> : null}
|
|
210
219
|
<div className="dut-arc-body">
|
|
211
220
|
{rows.length === 0 ? (
|
|
212
221
|
<div className="dut-arc-empty">{t('archiveEmpty')}</div>
|
|
@@ -216,16 +225,35 @@ export function ArchiveSection({ controller, t, useSessions, useWorkspaces }: Ar
|
|
|
216
225
|
const sub = [basenameOf(summary?.cwd), summary !== undefined ? relativeTime(summary.updatedAt, now, timeFormatter) : ''].filter(Boolean).join(' · ')
|
|
217
226
|
return (
|
|
218
227
|
<div className="dut-arc-row" key={row.id}>
|
|
219
|
-
<
|
|
220
|
-
<
|
|
221
|
-
|
|
222
|
-
|
|
228
|
+
<label className="dut-arc-select dut-arc-session" title={title}>
|
|
229
|
+
<input type="checkbox" aria-label={title} checked={selectedSet.has(row.id)} disabled={busy !== null}
|
|
230
|
+
onChange={event => {
|
|
231
|
+
const checked = event.target.checked
|
|
232
|
+
setSelected(previous => checked ? [...previous, row.id] : previous.filter(id => id !== row.id))
|
|
233
|
+
}} />
|
|
234
|
+
<span className="dut-arc-main">
|
|
235
|
+
<span className="dut-arc-title">{title}</span>
|
|
236
|
+
{sub !== '' ? <span className="dut-arc-sub">{sub}</span> : null}
|
|
237
|
+
</span>
|
|
238
|
+
</label>
|
|
223
239
|
<button type="button" className="dut-arc-btn" disabled={busy !== null} onClick={() => { restore(row.id) }}>{busy === `restore:${row.id}` ? t('archiveRestoring') : t('archiveRestore')}</button>
|
|
240
|
+
<button type="button" className="dut-arc-btn dut-arc-del" disabled={busy !== null} onClick={() => requestDelete([row.id])}>{t('archiveDelete')}</button>
|
|
224
241
|
</div>
|
|
225
242
|
)
|
|
226
243
|
})}
|
|
227
244
|
</div>
|
|
228
245
|
</div>
|
|
246
|
+
<Modal open={deletion !== null} title={t('archiveConfirmTitle')} closeLabel={t('archiveCancel')} onClose={dismissDeletion}
|
|
247
|
+
description={t('archiveConfirmDescription').replace('{count}', String(new Set(deletion?.flatMap(target => [...target.scope]) ?? []).size))}
|
|
248
|
+
footer={<>
|
|
249
|
+
<Button data-modal-autofocus autoFocus disabled={busy === 'delete'} onClick={dismissDeletion}>{t('archiveCancel')}</Button>
|
|
250
|
+
<Button disabled={busy !== null} onClick={confirmDelete}>{t('archiveDelete')}</Button>
|
|
251
|
+
</>}>
|
|
252
|
+
{deletion !== null && deletion.length > 1 && <ul className="dut-arc-targets">
|
|
253
|
+
{deletion.map(target => <li key={target.id}>{target.title}</li>)}
|
|
254
|
+
</ul>}
|
|
255
|
+
{error !== null && <p role="alert" style={{ whiteSpace: 'pre-line' }}>{error}</p>}
|
|
256
|
+
</Modal>
|
|
229
257
|
</div>
|
|
230
258
|
)
|
|
231
259
|
}
|