Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 89e40bd66e feat(run): Pause Output in the console context menu
The console's context menu gets a Pause Output toggle: while it is on, the
output shown so far stays put and new output (including the rest of the open
line) is held back; turning it off shows everything that arrived meanwhile.
Clear All also resumes.

Fixes #5998
2026-11-27 03:02:47 +08:00
7 змінених файлів з 78 додано та 2 видалено

No files matched your search

+21 -2
Переглянути файл
@@ -128,6 +128,11 @@ export interface FileLink extends LinkPosition {
}
/** The file links on the `shown` lines (a collapsed fold hides its links), in output order. */
/** A copy of a line the model may still append to (the open last line). */
function copyLine(line: ConsoleLine): ConsoleLine {
return { ...line, spans: line.spans.map((span) => ({ ...span })) };
}
export function fileLinks(lines: readonly ConsoleLine[], shown: (index: number) => boolean): FileLink[] {
const links: FileLink[] = [];
lines.forEach((line, i) => {
@@ -257,7 +262,12 @@ export function ConsoleView({
}: ConsoleViewProps) {
const scrollRef = useRef<HTMLDivElement>(null);
const innerRef = useRef<HTMLDivElement>(null);
const lines = model.lines;
// Pause Output: the output so far stays on screen while the process keeps
// writing; resuming shows everything that arrived meanwhile.
const [paused, setPaused] = useState<readonly ConsoleLine[] | null>(null);
const lines = paused ?? model.lines;
const togglePaused = () =>
setPaused((p) => (p ? null : model.lines.map((l, i, all) => (i === all.length - 1 ? copyLine(l) : l))));
const patterns = useWorkflowSettings((s) => s.console.foldPatterns);
const logColors = useWorkflowSettings((s) => s.console.logColors);
const consoleRules = compileConsoleRules(useConsoleRules((s) => s.providers));
@@ -539,7 +549,16 @@ export function ConsoleView({
// Opens Settings › Console with the text added to the fold patterns, for OK / Cancel there.
run: () => void executeAction("file.settings", `build.console#${foldText}`),
},
{ label: "Clear All", icon: "trash", disabled: !onClear, run: () => onClear?.() },
{ label: "Pause Output", icon: "pause", checked: !!paused, run: togglePaused },
{
label: "Clear All",
icon: "trash",
disabled: !onClear,
run: () => {
setPaused(null);
onClear?.();
},
},
...(input
? [{ kind: "separator" } as const, { label: "Send EOF", shortcut: "⌃D", run: () => input.onEof() }]
: []),
+52
Переглянути файл
@@ -0,0 +1,52 @@
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import { act, fireEvent, render, within } from "@testing-library/react";
import { useProject } from "@/platform/project";
import { hideContextMenu, useContextMenuStore } from "@/ui";
import { ConsoleModel } from "./console";
import { ConsoleView } from "./ConsoleView";
vi.mock("@tanstack/react-virtual", () => ({
useVirtualizer: ({ count }: { count: number }) => ({
getTotalSize: () => count * 20,
getVirtualItems: () => Array.from({ length: count }, (_, index) => ({ index, start: index * 20, key: index })),
scrollToIndex: () => {},
measureElement: () => {},
measure: () => {},
}),
}));
beforeEach(() => useProject.setState({ settings: null }));
afterEach(() => act(hideContextMenu));
function pauseItem(log: Element) {
fireEvent.contextMenu(log);
const items = useContextMenuStore.getState().menu?.items ?? [];
return items.find((i) => "label" in i && i.label === "Pause Output") as
| { checked?: boolean; run?: () => void }
| undefined;
}
it("Pause Output keeps the output on screen until it is resumed, then shows what arrived meanwhile", () => {
const model = new ConsoleModel();
model.append({ kind: "stdout", text: "first\nsecond " });
const view = (version: number) => (
<ConsoleView model={model} version={version} softWrap={false} follow={false} onFollowChange={() => {}} cwd="/" />
);
const { container, rerender } = render(view(1));
const log = within(container).getByRole("log");
expect(pauseItem(log)?.checked).toBe(false);
act(() => pauseItem(log)!.run!());
// The open line and new lines keep arriving while paused, but are not shown.
model.append({ kind: "stdout", text: "half\nthird\n" });
rerender(view(2));
expect(log.textContent).toContain("first");
expect(log.textContent).toContain("second");
expect(log.textContent).not.toContain("half");
expect(log.textContent).not.toContain("third");
expect(pauseItem(log)?.checked).toBe(true);
act(() => pauseItem(log)!.run!());
expect(log.textContent).toContain("second half");
expect(log.textContent).toContain("third");
});
+1
Переглянути файл
@@ -3645,6 +3645,7 @@
"Shelve Silently": "Shelve Silently",
"Unshelve Silently": "Unshelve Silently",
"Fold Lines Like This": "Fold Lines Like This",
"Pause Output": "Pause Output",
"Remove All Watches": "Remove All Watches",
"Not Cherry-Picked Commits": "Not Cherry-Picked Commits",
"Show Branch Diff": "Show Branch Diff",
+1
Переглянути файл
@@ -3905,6 +3905,7 @@
"Hold Shift to Run, F4 to edit, Delete to remove": "Удерживайте Shift для запуска, F4 — для редактирования, Delete — для удаления",
"Send EOF": "Отправить EOF",
"Fold Lines Like This": "Свернуть похожие строки",
"Pause Output": "Приостановить вывод",
"Collapse folded lines": "Сворачивать свернутые строки",
"Close Tool Window Tab": "Закрыть вкладку окна инструментов",
"No open files": "Нет открытых файлов",
+1
Переглянути файл
@@ -2757,6 +2757,7 @@
"Shelve Silently": "Bildirim Vermeden Rafa Al",
"Unshelve Silently": "Bildirim Vermeden Raftan Çıkar",
"Fold Lines Like This": "Buna Benzer Satırları Daralt",
"Pause Output": "Çıktıyı Duraklat",
"Remove All Watches": "İzlenen Tüm İfadeleri Kaldır",
"GitHub account": "GitHub hesabı",
"Leave empty to use the active GitHub CLI account. OpenIDEA resolves the token at launch and never stores it.": "Etkin GitHub CLI hesabını kullanmak için boş bırakın. OpenIDEA tokeni başlatma sırasında çözümler ve saklamaz.",
+1
Переглянути файл
@@ -3474,6 +3474,7 @@
"Hold Shift to Run, F4 to edit, Delete to remove": "按住 Shift 執行,F4 編輯,Delete 刪除",
"Send EOF": "傳送 EOF",
"Fold Lines Like This": "摺疊與此類似的行",
"Pause Output": "暫停輸出",
"Collapse folded lines": "摺疊行",
"Close Tool Window Tab": "關閉工具視窗分頁",
"No open files": "沒有開啟的檔案",
+1
Переглянути файл
@@ -4039,6 +4039,7 @@
"Hold Shift to Run, F4 to edit, Delete to remove": "按住 Shift 运行,F4 编辑,Delete 删除",
"Send EOF": "发送 EOF",
"Fold Lines Like This": "折叠与此类似的行",
"Pause Output": "暂停输出",
"Collapse folded lines": "折叠行",
"Close Tool Window Tab": "关闭工具窗口标签页",
"No open files": "没有打开的文件",