提交记录修改internal/workbench/session_metadata.go+8 −2看文件
修改internal/workbench/session_metadata_test.go+131 −0看文件
新增ui/scripts/archive-contention-smoke.mjs+54 −0看文件
修改ui/scripts/archive-position-smoke.mjs+27 −3看文件
修改ui/src/main.jsx+26 −19看文件
修改ui/src/style.css+7 −6看文件
修改ui/src/workspace-tabs.jsx+3 −5看文件
| @@ -69,10 +69,16 @@ func (s *Server) updateSessionMetadata(id string, input sessionMetadataInput, re | ||
| 69 | 69 | |
| 70 | 70 | // Archive state belongs to the shared catalog and survives terminal exits. |
| 71 | 71 | func (s *Server) setSessionArchived(id string, archived bool, requestContext context.Context) error { |
| 72 | 删除: if !s.op.TryLock() { | |
| 73 | 删除: return errTerminalBusy | |
| 72 | 新增: if requestContext != nil && requestContext.Err() != nil { | |
| 73 | 新增: return requestContext.Err() | |
| 74 | 74 | } |
| 75 | 新增: // Serialize with terminal creation and teardown, but let an explicit archive | |
| 76 | 新增: // wait for background network probes instead of rejecting the user's click. | |
| 77 | 新增: s.op.Lock() | |
| 75 | 78 | defer s.op.Unlock() |
| 79 | 新增: if requestContext != nil && requestContext.Err() != nil { | |
| 80 | 新增: return requestContext.Err() | |
| 81 | 新增: } | |
| 76 | 82 | s.conversationMu.Lock() |
| 77 | 83 | defer s.conversationMu.Unlock() |
| 78 | 84 | m := &s.mobileCLI |
| @@ -1,16 +1,147 @@ | ||
| 1 | 1 | package workbench |
| 2 | 2 | |
| 3 | 3 | import ( |
| 4 | 新增: "context" | |
| 4 | 5 | "encoding/json" |
| 6 | 新增: "errors" | |
| 5 | 7 | "net/http" |
| 8 | 新增: "net/http/httptest" | |
| 6 | 9 | "os" |
| 10 | 新增: "os/exec" | |
| 7 | 11 | "path/filepath" |
| 8 | 12 | "strings" |
| 13 | 新增: "sync" | |
| 14 | 新增: "sync/atomic" | |
| 9 | 15 | "testing" |
| 16 | 新增: "time" | |
| 10 | 17 | |
| 11 | 18 | "github.com/google/uuid" |
| 12 | 19 | ) |
| 13 | 20 | |
| 21 | 新增:func TestSessionArchiveContentionInBrowser(t *testing.T) { | |
| 22 | 新增: if os.Getenv("CAGE_TEST_ARCHIVE_BROWSER") == "" { | |
| 23 | 新增: t.Skip("set CAGE_TEST_ARCHIVE_BROWSER after building the UI to test with real archive handlers") | |
| 24 | 新增: } | |
| 25 | 新增: s, id, project := metadataFixture(t) | |
| 26 | 新增: record, _ := s.mobileCLI.record(s.profile, id) | |
| 27 | 新增: record.Title = "软件宣传视频制作" | |
| 28 | 新增: if err := writePrivate(mobileRecordPath(s.profile, id), record); err != nil { | |
| 29 | 新增: t.Fatal(err) | |
| 30 | 新增: } | |
| 31 | 新增: s.op.Lock() | |
| 32 | 新增: var releaseOnce sync.Once | |
| 33 | 新增: release := func() { releaseOnce.Do(s.op.Unlock) } | |
| 34 | 新增: defer release() | |
| 35 | 新增: var archives atomic.Int32 | |
| 36 | 新增: handler := s.handler() | |
| 37 | 新增: host := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | |
| 38 | 新增: if r.URL.Path == "/fixture/release-operation" { | |
| 39 | 新增: release() | |
| 40 | 新增: jsonReply(w, map[string]bool{"ok": true}) | |
| 41 | 新增: return | |
| 42 | 新增: } | |
| 43 | 新增: if r.URL.Path == "/api/cli/sessions/"+id+"/archive" { | |
| 44 | 新增: archives.Add(1) | |
| 45 | 新增: } | |
| 46 | 新增: handler.ServeHTTP(w, r) | |
| 47 | 新增: })) | |
| 48 | 新增: defer host.Close() | |
| 49 | 新增: // Release a blocked request before httptest waits for its handler at cleanup. | |
| 50 | 新增: defer release() | |
| 51 | 新增: s.origin = host.URL | |
| 52 | 新增: input, _ := json.Marshal(map[string]string{ | |
| 53 | 新增: "origin": host.URL, "cookie": s.cookieName() + "=" + s.session, | |
| 54 | 新增: "id": id, "workspace": project, "title": record.Title, | |
| 55 | 新增: }) | |
| 56 | 新增: ctx, cancel := context.WithTimeout(context.Background(), time.Minute) | |
| 57 | 新增: defer cancel() | |
| 58 | 新增: driver := exec.CommandContext(ctx, "node", "../../ui/scripts/archive-contention-smoke.mjs") | |
| 59 | 新增: driver.Env = append(os.Environ(), "CAGE_TEST_BROWSER="+os.Getenv("CAGE_TEST_ARCHIVE_BROWSER")) | |
| 60 | 新增: driver.Stdin = strings.NewReader(string(input)) | |
| 61 | 新增: if output, err := driver.CombinedOutput(); err != nil { | |
| 62 | 新增: t.Fatalf("browser: %v\n%s", err, output) | |
| 63 | 新增: } else { | |
| 64 | 新增: t.Log(string(output)) | |
| 65 | 新增: } | |
| 66 | 新增: if archives.Load() != 1 { | |
| 67 | 新增: t.Fatalf("archive submissions: %d", archives.Load()) | |
| 68 | 新增: } | |
| 69 | 新增: s.mobileCLI = mobileCLIStore{} | |
| 70 | 新增: restored, err := s.mobileCLI.record(s.profile, id) | |
| 71 | 新增: if err != nil || !restored.Archived || restored.Deleted { | |
| 72 | 新增: t.Fatal("UI archive was not durable", restored, err) | |
| 73 | 新增: } | |
| 74 | 新增:} | |
| 75 | 新增: | |
| 76 | 新增:func TestSessionArchiveWaitsForEnvironmentOperation(t *testing.T) { | |
| 77 | 新增: for _, route := range []string{"/api/cli/sessions/", "/api/mobile/cli/sessions/"} { | |
| 78 | 新增: t.Run(route, func(t *testing.T) { | |
| 79 | 新增: s, id, project := metadataFixture(t) | |
| 80 | 新增: // Network monitoring holds this lock even when the UI reports no job. | |
| 81 | 新增: s.op.Lock() | |
| 82 | 新增: locked := true | |
| 83 | 新增: defer func() { | |
| 84 | 新增: if locked { | |
| 85 | 新增: s.op.Unlock() | |
| 86 | 新增: } | |
| 87 | 新增: }() | |
| 88 | 新增: done := make(chan *httptest.ResponseRecorder, 1) | |
| 89 | 新增: go func() { done <- request(s, "POST", route+id+"/archive", s.origin, `{}`, true) }() | |
| 90 | 新增: select { | |
| 91 | 新增: case response := <-done: | |
| 92 | 新增: t.Fatalf("archive rejected during background operation: %d %s", response.Code, response.Body.String()) | |
| 93 | 新增: case <-time.After(100 * time.Millisecond): | |
| 94 | 新增: } | |
| 95 | 新增: s.op.Unlock() | |
| 96 | 新增: locked = false | |
| 97 | 新增: select { | |
| 98 | 新增: case response := <-done: | |
| 99 | 新增: if response.Code != http.StatusOK { | |
| 100 | 新增: t.Fatal(response.Code, response.Body.String()) | |
| 101 | 新增: } | |
| 102 | 新增: case <-time.After(3 * time.Second): | |
| 103 | 新增: t.Fatal("archive did not finish after background operation released the lock") | |
| 104 | 新增: } | |
| 105 | 新增: if len(s.terminals.snapshot()) != 0 { | |
| 106 | 新增: t.Fatal("archive left its terminal visible") | |
| 107 | 新增: } | |
| 108 | 新增: s.mobileCLI = mobileCLIStore{} | |
| 109 | 新增: active, err := s.mobileCLI.summaries(s.profile, map[string]bool{project: true}, false) | |
| 110 | 新增: if err != nil || len(active) != 0 { | |
| 111 | 新增: t.Fatal("archived session remained active after reload", active, err) | |
| 112 | 新增: } | |
| 113 | 新增: archived, err := s.mobileCLI.summaries(s.profile, map[string]bool{project: true}, true) | |
| 114 | 新增: if err != nil || len(archived) != 1 || archived[0].ID != id { | |
| 115 | 新增: t.Fatal("archived history was not retained", archived, err) | |
| 116 | 新增: } | |
| 117 | 新增: }) | |
| 118 | 新增: } | |
| 119 | 新增:} | |
| 120 | 新增: | |
| 121 | 新增:func TestSessionArchiveDoesNotApplyCancelledRequest(t *testing.T) { | |
| 122 | 新增: s, id, _ := metadataFixture(t) | |
| 123 | 新增: ctx, cancel := context.WithCancel(context.Background()) | |
| 124 | 新增: defer cancel() | |
| 125 | 新增: s.op.Lock() | |
| 126 | 新增: done := make(chan error, 1) | |
| 127 | 新增: go func() { done <- s.setSessionArchived(id, true, ctx) }() | |
| 128 | 新增: select { | |
| 129 | 新增: case err := <-done: | |
| 130 | 新增: s.op.Unlock() | |
| 131 | 新增: t.Fatalf("archive did not wait for the operation: %v", err) | |
| 132 | 新增: case <-time.After(100 * time.Millisecond): | |
| 133 | 新增: } | |
| 134 | 新增: cancel() | |
| 135 | 新增: s.op.Unlock() | |
| 136 | 新增: if err := <-done; !errors.Is(err, context.Canceled) { | |
| 137 | 新增: t.Fatalf("cancelled archive: %v", err) | |
| 138 | 新增: } | |
| 139 | 新增: record, err := s.mobileCLI.record(s.profile, id) | |
| 140 | 新增: if err != nil || record.Archived || len(s.terminals.snapshot()) != 1 { | |
| 141 | 新增: t.Fatal("cancelled archive changed the session", record, err) | |
| 142 | 新增: } | |
| 143 | 新增:} | |
| 144 | 新增: | |
| 14 | 145 | func metadataFixture(t *testing.T) (*Server, string, string) { |
| 15 | 146 | t.Helper() |
| 16 | 147 | s := testServer(t) |
| @@ -0,0 +1,54 @@ | ||
| 1 | 新增:// Real archive/catalog/terminal handlers; only unrelated workbench services use fixtures. | |
| 2 | 新增:import assert from "node:assert/strict"; | |
| 3 | 新增:import { createWorkbench } from "./workbench-fixture.mjs"; | |
| 4 | 新增: | |
| 5 | 新增:let input = ""; | |
| 6 | 新增:for await (const chunk of process.stdin) input += chunk; | |
| 7 | 新增:const fixture = JSON.parse(input); | |
| 8 | 新增:const forward = async route => { | |
| 9 | 新增: const request = route.request(); | |
| 10 | 新增: const url = new URL(request.url()); | |
| 11 | 新增: const response = await fetch(fixture.origin + url.pathname + url.search, { | |
| 12 | 新增: method: request.method(), | |
| 13 | 新增: headers: { Origin: fixture.origin, Cookie: fixture.cookie, "Content-Type": "application/json" }, | |
| 14 | 新增: body: request.postData() || undefined, | |
| 15 | 新增: }); | |
| 16 | 新增: return route.fulfill({ status: response.status, contentType: response.headers.get("Content-Type"), body: await response.text() }); | |
| 17 | 新增:}; | |
| 18 | 新增:const { page, browser, errors } = await createWorkbench({ | |
| 19 | 新增: url: process.env.CAGE_UI_URL || fixture.origin, | |
| 20 | 新增: cliRequest: forward, | |
| 21 | 新增: beforeNavigate: async (page, state) => { | |
| 22 | 新增: state.settings.workspace = fixture.workspace; | |
| 23 | 新增: Object.assign(state.status, { ready: true, vm_running: true, projects: [fixture.workspace], environment_directory: fixture.workspace }); | |
| 24 | 新增: await page.route("**/api/terminals", forward); | |
| 25 | 新增: }, | |
| 26 | 新增:}); | |
| 27 | 新增:try { | |
| 28 | 新增: const actions = page.getByRole("group", { name: `${fixture.title} 的操作`, exact: true, includeHidden: true }); | |
| 29 | 新增: await page.locator(".sidebar-tab").filter({ has: actions }).hover(); | |
| 30 | 新增: await actions.getByRole("button", { name: "归档", exact: true }).hover(); | |
| 31 | 新增: await actions.locator(".terminal-action-label").filter({ hasText: /^归档$/ }).click(); | |
| 32 | 新增: const dialog = page.getByRole("dialog", { name: "归档这段会话?", exact: true }); | |
| 33 | 新增: await dialog.getByRole("button", { name: "归档会话", exact: true }).click(); | |
| 34 | 新增: const pending = dialog.getByRole("button", { name: "正在归档…", exact: true }); | |
| 35 | 新增: await pending.waitFor(); | |
| 36 | 新增: assert.equal(await pending.isDisabled(), true); | |
| 37 | 新增: await page.keyboard.press("Enter"); | |
| 38 | 新增: await page.keyboard.press("Escape"); | |
| 39 | 新增: assert.equal(await dialog.isVisible(), true); | |
| 40 | 新增: await fetch(fixture.origin + "/fixture/release-operation", { method: "POST" }); | |
| 41 | 新增: await dialog.waitFor({ state: "hidden" }); | |
| 42 | 新增: await actions.waitFor({ state: "hidden" }); | |
| 43 | 新增: // Reload fetches the durable catalog again through the real backend. | |
| 44 | 新增: const reloadedSessions = page.waitForResponse(response => new URL(response.url()).pathname === "/api/cli/sessions"); | |
| 45 | 新增: await page.reload(); | |
| 46 | 新增: await page.getByRole("button", { name: "打开浏览器", exact: true }).waitFor(); | |
| 47 | 新增: await reloadedSessions; | |
| 48 | 新增: assert.equal(await actions.count(), 0); | |
| 49 | 新增: assert.deepEqual(errors, []); | |
| 50 | 新增: console.log(`${process.env.CAGE_TEST_BROWSER}: UI archive waited for the environment operation, submitted once, removed the row, retained history and survived reload`); | |
| 51 | 新增:} finally { | |
| 52 | 新增: await fetch(fixture.origin + "/fixture/release-operation", { method: "POST" }); | |
| 53 | 新增: await browser.close(); | |
| 54 | 新增:} | |
| @@ -14,6 +14,8 @@ const sessions = Array.from({ length: 18 }, (_, i) => ({ | ||
| 14 | 14 | })); |
| 15 | 15 | const evidence = []; |
| 16 | 16 | let failArchive = false; |
| 17 | 新增:let holdArchive = false, releaseArchive; | |
| 18 | 新增:let archiveRequests = 0; | |
| 17 | 19 | let archived = 0; |
| 18 | 20 | const dialog = page.getByRole("dialog", { name: "归档这段会话?", exact: true }); |
| 19 | 21 | const actions = title => page.getByRole("group", { name: `${title} 的操作`, exact: true, includeHidden: true }); |
| @@ -28,7 +30,9 @@ const open = async title => { | ||
| 28 | 30 | try { |
| 29 | 31 | await page.route("**/api/cli/sessions", route => route.fulfill({ json: { sessions } })); |
| 30 | 32 | await page.route("**/api/cli/sessions/*/archive", async route => { |
| 31 | 删除: if (failArchive) return route.fulfill({ status: 500, contentType: "text/plain", body: "测试:归档暂时失败" }); | |
| 33 | 新增: archiveRequests++; | |
| 34 | 新增: if (holdArchive) await new Promise(resolve => { releaseArchive = resolve; }); | |
| 35 | 新增: if (failArchive) return route.fulfill({ status: 400, contentType: "text/plain", body: "环境正在执行其他操作" }); | |
| 32 | 36 | const id = route.request().url().split("/").at(-2); |
| 33 | 37 | sessions.splice(sessions.findIndex(session => session.id === id), 1); |
| 34 | 38 | state.terminals = state.terminals.filter(terminal => terminal.cli_session_id !== id); |
| @@ -41,6 +45,16 @@ try { | ||
| 41 | 45 | await page.getByRole("tab", { name: sessions[0].title, exact: true }).waitFor(); |
| 42 | 46 | await page.getByRole("button", { name: sessions.at(-1).title, exact: true }).waitFor(); |
| 43 | 47 | await mkdir(output, { recursive: true }); |
| 48 | 新增: // A user can click the visible action text as well as its icon. Locator | |
| 49 | 新增: // clicks on the icon alone hid the inert text beside the old buttons. | |
| 50 | 新增: const firstActions = actions(sessions[0].title); | |
| 51 | 新增: await page.locator(".sidebar-tab").filter({ has: firstActions }).hover(); | |
| 52 | 新增: await firstActions.getByRole("button", { name: "归档", exact: true }).hover(); | |
| 53 | 新增: await page.screenshot({ path: `${output}/${engine}-archive-label.png` }); | |
| 54 | 新增: await firstActions.locator(".terminal-action-label").filter({ hasText: /^归档$/ }).click(); | |
| 55 | 新增: await dialog.waitFor({ timeout: 2000 }); | |
| 56 | 新增: await dialog.getByRole("button", { name: "取消", exact: true }).click(); | |
| 57 | 新增: assert.equal(archived, 0, "action text bypassed archive confirmation"); | |
| 44 | 58 | for (const width of [1280, 820]) { |
| 45 | 59 | await page.setViewportSize({ width, height: 850 }); |
| 46 | 60 | const trigger = await open(sessions[0].title); |
| @@ -82,11 +96,21 @@ try { | ||
| 82 | 96 | await open(sessions[0].title); |
| 83 | 97 | failArchive = true; |
| 84 | 98 | await dialog.getByRole("button", { name: "归档会话", exact: true }).click(); |
| 85 | 删除: await page.getByRole("status").filter({ hasText: "归档暂时失败" }).waitFor(); | |
| 99 | 新增: await dialog.getByRole("alert").filter({ hasText: "环境正在执行其他操作" }).waitFor(); | |
| 86 | 100 | assert.equal(archived, 0, "failed archive removed a session"); |
| 87 | 101 | failArchive = false; |
| 88 | 删除: await open(sessions[0].title); | |
| 102 | 新增: holdArchive = true; | |
| 89 | 103 | await dialog.getByRole("button", { name: "归档会话", exact: true }).press("Enter"); |
| 104 | 新增: await dialog.getByRole("button", { name: "正在归档…", exact: true }).waitFor(); | |
| 105 | 新增: assert.equal(await dialog.getByRole("button", { name: "取消", exact: true }).isDisabled(), true); | |
| 106 | 新增: assert.equal(await dialog.getByRole("button", { name: "正在归档…", exact: true }).isDisabled(), true); | |
| 107 | 新增: const pendingRequests = archiveRequests; | |
| 108 | 新增: await page.keyboard.press("Enter"); | |
| 109 | 新增: await page.keyboard.press("Escape"); | |
| 110 | 新增: assert.equal(await dialog.isVisible(), true, "pending archive was dismissed"); | |
| 111 | 新增: assert.equal(archiveRequests, pendingRequests, "pending archive was submitted twice"); | |
| 112 | 新增: await page.screenshot({ path: `${output}/${engine}-pending.png` }); | |
| 113 | 新增: releaseArchive(); holdArchive = false; | |
| 90 | 114 | await actions("正在处理的会话").waitFor({ state: "hidden" }); |
| 91 | 115 | assert.equal(archived, 1, "confirm should archive exactly once"); |
| 92 | 116 | await open(last); |
| @@ -483,13 +483,14 @@ function App() { | ||
| 483 | 483 | } |
| 484 | 484 | }; |
| 485 | 485 | const archiveSession = async (session, anchor) => { |
| 486 | 删除: if (!(await confirm({title:"归档这段会话?", body:"归档会关闭关联终端。历史将保留,可从设置中的已归档会话恢复。", confirm:"归档会话", anchor}))) return; | |
| 487 | 删除: try { | |
| 488 | 删除: await api("/cli/sessions/" + session.id + "/archive", {}); | |
| 489 | 删除: setTabs(list => list.filter(tab => tab.cli_session_id !== session.id)); | |
| 490 | 删除: sessionsChanged(); | |
| 491 | 删除: refreshStatus.current?.(); | |
| 492 | 删除: } catch (error) { notify(error.message); } | |
| 486 | 新增: await confirm({title:"归档这段会话?", body:"归档会关闭关联终端。历史将保留,可从设置中的已归档会话恢复。", confirm:"归档会话", pendingLabel:"正在归档…", anchor, | |
| 487 | 新增: submit: async () => { | |
| 488 | 新增: await api("/cli/sessions/" + session.id + "/archive", {}); | |
| 489 | 新增: setTabs(list => list.filter(tab => tab.cli_session_id !== session.id)); | |
| 490 | 新增: sessionsChanged(); | |
| 491 | 新增: refreshStatus.current?.(); | |
| 492 | 新增: }, | |
| 493 | 新增: }); | |
| 493 | 494 | }; |
| 494 | 495 | const pinSession = async session => { |
| 495 | 496 | try { |
| @@ -862,9 +863,7 @@ function App() { | ||
| 862 | 863 | if (k === "w") { |
| 863 | 864 | event.preventDefault(); |
| 864 | 865 | event.stopImmediatePropagation(); |
| 865 | 删除: const resolve = dialog.resolve; | |
| 866 | 删除: setDialog(null); | |
| 867 | 删除: resolve(false); | |
| 866 | 新增: void finishDialog(false); | |
| 868 | 867 | } |
| 869 | 868 | return; |
| 870 | 869 | } |
| @@ -1005,9 +1004,7 @@ function App() { | ||
| 1005 | 1004 | return; |
| 1006 | 1005 | } |
| 1007 | 1006 | if (dialog) { |
| 1008 | 删除: const resolve = dialog.resolve; | |
| 1009 | 删除: setDialog(null); | |
| 1010 | 删除: resolve(false); | |
| 1007 | 新增: void finishDialog(false); | |
| 1011 | 1008 | } else if ( |
| 1012 | 1009 | settingsOpen || |
| 1013 | 1010 | transfer || |
| @@ -1170,7 +1167,16 @@ function App() { | ||
| 1170 | 1167 | useEffect(() => { |
| 1171 | 1168 | if (status?.workspace) setSelectedProject(status.workspace); |
| 1172 | 1169 | }, [status?.workspace]); |
| 1173 | 删除: const finishDialog = (value) => { | |
| 1170 | 新增: const finishDialog = async (value) => { | |
| 1171 | 新增: if (!dialog || dialog.pending) return; | |
| 1172 | 新增: if (value === true && dialog.submit) { | |
| 1173 | 新增: setDialog({ ...dialog, pending: true, error: "" }); | |
| 1174 | 新增: try { await dialog.submit(); } | |
| 1175 | 新增: catch (error) { | |
| 1176 | 新增: setDialog({ ...dialog, pending: false, error: error.message }); | |
| 1177 | 新增: return; | |
| 1178 | 新增: } | |
| 1179 | 新增: } | |
| 1174 | 1180 | const resolve = dialog.resolve; |
| 1175 | 1181 | setDialog(null); |
| 1176 | 1182 | resolve(value); |
| @@ -1242,23 +1248,24 @@ function App() { | ||
| 1242 | 1248 | <Modal |
| 1243 | 1249 | title={dialog.title} |
| 1244 | 1250 | anchor={dialog.anchor} |
| 1245 | 删除: onClose={() => finishDialog(false)} | |
| 1251 | 新增: onClose={dialog.pending ? undefined : () => finishDialog(false)} | |
| 1246 | 1252 | footer={ |
| 1247 | 1253 | <> |
| 1248 | 删除: <button onClick={() => finishDialog(false)}>取消</button> | |
| 1254 | 新增: <button disabled={dialog.pending} onClick={() => finishDialog(false)}>取消</button> | |
| 1249 | 1255 | {dialog.secondary && ( |
| 1250 | 删除: <button onClick={() => finishDialog("secondary")}> | |
| 1256 | 新增: <button disabled={dialog.pending} onClick={() => finishDialog("secondary")}> | |
| 1251 | 1257 | {dialog.secondary} |
| 1252 | 1258 | </button> |
| 1253 | 1259 | )} |
| 1254 | 删除: <button className="primary" onClick={() => finishDialog(true)}> | |
| 1255 | 删除: {dialog.confirm} | |
| 1260 | 新增: <button className="primary" disabled={dialog.pending} onClick={() => finishDialog(true)}> | |
| 1261 | 新增: {dialog.pending ? dialog.pendingLabel : dialog.confirm} | |
| 1256 | 1262 | </button> |
| 1257 | 1263 | </> |
| 1258 | 1264 | } |
| 1259 | 1265 | > |
| 1260 | 1266 | <div className="modal-body"> |
| 1261 | 1267 | <p>{dialog.body}</p> |
| 1268 | 新增: {dialog.error && <div className="error-message" role="alert">{dialog.error}</div>} | |
| 1262 | 1269 | </div> |
| 1263 | 1270 | </Modal> |
| 1264 | 1271 | )} |
| @@ -1582,8 +1582,10 @@ svg { | ||
| 1582 | 1582 | transform: none; |
| 1583 | 1583 | } |
| 1584 | 1584 | .terminal-row-actions > button { |
| 1585 | 删除: flex: 0 0 25px; | |
| 1586 | 删除: width: 25px; | |
| 1585 | 新增: flex: 0 0 auto; | |
| 1586 | 新增: width: auto; | |
| 1587 | 新增: min-width: 25px; | |
| 1588 | 新增: gap: 4px; | |
| 1587 | 1589 | min-height: 26px; |
| 1588 | 1590 | height: 26px; |
| 1589 | 1591 | padding: 0; |
| @@ -1598,14 +1600,13 @@ svg { | ||
| 1598 | 1600 | } |
| 1599 | 1601 | .terminal-action-label { |
| 1600 | 1602 | display: none; |
| 1601 | 删除: order: -1; | |
| 1602 | 删除: margin-inline: 2px 4px; | |
| 1603 | 新增: margin-left: 4px; | |
| 1603 | 1604 | color: var(--muted); |
| 1604 | 1605 | font-size: 0.7857rem; |
| 1605 | 1606 | white-space: nowrap; |
| 1606 | 1607 | } |
| 1607 | 删除:.terminal-row-actions > button:hover + .terminal-action-label, | |
| 1608 | 删除:.terminal-row-actions:not(:has(> button:hover)) > button:focus-visible + .terminal-action-label { | |
| 1608 | 新增:.terminal-row-actions > button:hover .terminal-action-label, | |
| 1609 | 新增:.terminal-row-actions:not(:has(> button:hover)) > button:focus-visible .terminal-action-label { | |
| 1609 | 1610 | display: block; |
| 1610 | 1611 | } |
| 1611 | 1612 | @media (prefers-reduced-motion: reduce) { |
| @@ -32,12 +32,10 @@ export function TabIcon({ kind, favicon, agent, accountNumber, size = 16 }) { | ||
| 32 | 32 | |
| 33 | 33 | function TerminalAction({ label, icon: Icon, disabled, onClick }) { |
| 34 | 34 | return ( |
| 35 | 删除: <> | |
| 36 | 删除: <button className="icon-button" aria-label={label} disabled={disabled} onClick={onClick}> | |
| 37 | 删除: <Icon size={14} /> | |
| 38 | 删除: </button> | |
| 35 | 新增: <button className="icon-button" aria-label={label} disabled={disabled} onClick={onClick}> | |
| 39 | 36 | <span className="terminal-action-label" aria-hidden="true">{label}</span> |
| 40 | 删除: </> | |
| 37 | 新增: <Icon size={14} /> | |
| 38 | 新增: </button> | |
| 41 | 39 | ); |
| 42 | 40 | } |
| 43 | 41 | |

