mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 01:50:39 +09:00
## Thinking Path > - Paperclip orchestrates AI agents for zero-human companies > - That operator experience depends not just on issue chat, but also on how workspaces, inbox groups, and navigation state behave over long-running sessions > - The current branch included a separate cluster of workspace-runtime controls, inbox grouping, sidebar ordering, and worktree lifecycle fixes > - Those changes cross server, shared contracts, database state, and UI navigation, but they still form one coherent operator workflow area > - This pull request isolates the workspace/runtime and navigation ergonomics work into one standalone branch > - The benefit is better workspace recovery and navigation persistence without forcing reviewers through the unrelated issue-detail/chat work ## What Changed - Improved execution workspace and project workspace controls, request wiring, layout, and JSON editor ergonomics - Hardened linked worktree reuse/startup behavior and documented the `worktree repair` flow for recovering linked worktrees safely - Added inbox workspace grouping, mobile collapse, archive undo, keyboard navigation, shared group-header styling, and persisted collapsed-group behavior - Added persistent sidebar order preferences with the supporting DB migration, shared/server contracts, routes, services, hooks, and UI integration - Scoped issue-list preferences by context and added targeted UI/server tests for workspace controls, inbox behavior, sidebar preferences, and worktree validation ## Verification - `pnpm vitest run server/src/__tests__/sidebar-preferences-routes.test.ts ui/src/pages/Inbox.test.tsx ui/src/components/ProjectWorkspaceSummaryCard.test.tsx ui/src/components/WorkspaceRuntimeControls.test.tsx ui/src/api/workspace-runtime-control.test.ts` - `server/src/__tests__/workspace-runtime.test.ts` was attempted, but the embedded Postgres suite self-skipped/hung on this host after reporting an init-script issue, so it is not counted as a local pass here ## Risks - Medium: this branch includes migration-backed preference storage plus worktree/runtime behavior, so merge review should pay attention to state persistence and worktree recovery semantics - The sidebar preference migration is standalone, but it should still be watched for conflicts if another migration lands first ## Model Used - OpenAI Codex coding agent (GPT-5-class runtime in Codex CLI; exact deployed model ID is not exposed in this environment), reasoning enabled, tool use and local code execution enabled ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [ ] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] If this change affects the UI, I have included before/after screenshots - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
274 lines
7.7 KiB
TypeScript
274 lines
7.7 KiB
TypeScript
// @vitest-environment jsdom
|
|
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import {
|
|
findPageSearchShortcutTarget,
|
|
focusPageSearchShortcutTarget,
|
|
hasBlockingShortcutDialog,
|
|
isKeyboardShortcutTextInputTarget,
|
|
resolveIssueDetailGoKeyAction,
|
|
resolveInboxQuickArchiveKeyAction,
|
|
resolveInboxUndoArchiveKeyAction,
|
|
shouldBlurPageSearchOnEnter,
|
|
shouldBlurPageSearchOnEscape,
|
|
} from "./keyboardShortcuts";
|
|
|
|
describe("keyboardShortcuts helpers", () => {
|
|
it("detects editable shortcut targets", () => {
|
|
const wrapper = document.createElement("div");
|
|
wrapper.innerHTML = `
|
|
<div contenteditable="true"><span id="contenteditable-child">Editable</span></div>
|
|
<div role="textbox"><span id="textbox-child">Textbox</span></div>
|
|
<button id="button">Action</button>
|
|
`;
|
|
|
|
const editableChild = wrapper.querySelector("#contenteditable-child");
|
|
const textboxChild = wrapper.querySelector("#textbox-child");
|
|
const button = wrapper.querySelector("#button");
|
|
|
|
expect(isKeyboardShortcutTextInputTarget(editableChild)).toBe(true);
|
|
expect(isKeyboardShortcutTextInputTarget(textboxChild)).toBe(true);
|
|
expect(isKeyboardShortcutTextInputTarget(button)).toBe(false);
|
|
});
|
|
|
|
it("reports when a modal dialog is open", () => {
|
|
const root = document.createElement("div");
|
|
root.innerHTML = `<div role="dialog" aria-modal="true"></div>`;
|
|
|
|
expect(hasBlockingShortcutDialog(root)).toBe(true);
|
|
expect(hasBlockingShortcutDialog(document.createElement("div"))).toBe(false);
|
|
});
|
|
|
|
it("ignores non-dialog elements that happen to be aria-modal", () => {
|
|
const root = document.createElement("div");
|
|
root.innerHTML = `<section aria-modal="true"></section>`;
|
|
|
|
expect(hasBlockingShortcutDialog(root)).toBe(false);
|
|
});
|
|
|
|
it("finds the visible page search shortcut target", () => {
|
|
const root = document.createElement("div");
|
|
const hidden = document.createElement("input");
|
|
hidden.setAttribute("data-page-search-target", "true");
|
|
vi.spyOn(hidden, "getClientRects").mockReturnValue([] as unknown as DOMRectList);
|
|
|
|
const visible = document.createElement("input");
|
|
visible.setAttribute("data-page-search-target", "true");
|
|
vi.spyOn(visible, "getClientRects").mockReturnValue([{}] as unknown as DOMRectList);
|
|
|
|
root.append(hidden, visible);
|
|
document.body.appendChild(root);
|
|
|
|
expect(findPageSearchShortcutTarget(root)).toBe(visible);
|
|
|
|
root.remove();
|
|
});
|
|
|
|
it("focuses and selects the page search shortcut target", () => {
|
|
const root = document.createElement("div");
|
|
const input = document.createElement("input");
|
|
input.value = "existing query";
|
|
input.setAttribute("data-page-search-target", "true");
|
|
vi.spyOn(input, "getClientRects").mockReturnValue([{}] as unknown as DOMRectList);
|
|
root.appendChild(input);
|
|
document.body.appendChild(root);
|
|
|
|
expect(focusPageSearchShortcutTarget(root)).toBe(true);
|
|
expect(document.activeElement).toBe(input);
|
|
expect(input.selectionStart).toBe(0);
|
|
expect(input.selectionEnd).toBe(input.value.length);
|
|
|
|
root.remove();
|
|
});
|
|
|
|
it("blurs page search on a plain Enter press", () => {
|
|
expect(shouldBlurPageSearchOnEnter({
|
|
key: "Enter",
|
|
isComposing: false,
|
|
})).toBe(true);
|
|
});
|
|
|
|
it("keeps focus while composing with an IME", () => {
|
|
expect(shouldBlurPageSearchOnEnter({
|
|
key: "Enter",
|
|
isComposing: true,
|
|
})).toBe(false);
|
|
});
|
|
|
|
it("blurs page search on Escape when the field is already empty", () => {
|
|
expect(shouldBlurPageSearchOnEscape({
|
|
key: "Escape",
|
|
isComposing: false,
|
|
currentValue: "",
|
|
})).toBe(true);
|
|
});
|
|
|
|
it("keeps focus on the first Escape while the field still has text", () => {
|
|
expect(shouldBlurPageSearchOnEscape({
|
|
key: "Escape",
|
|
isComposing: false,
|
|
currentValue: "query",
|
|
})).toBe(false);
|
|
});
|
|
|
|
it("archives only the first clean y press", () => {
|
|
const button = document.createElement("button");
|
|
|
|
expect(resolveInboxQuickArchiveKeyAction({
|
|
armed: true,
|
|
defaultPrevented: false,
|
|
key: "y",
|
|
metaKey: false,
|
|
ctrlKey: false,
|
|
altKey: false,
|
|
target: button,
|
|
hasOpenDialog: false,
|
|
})).toBe("archive");
|
|
});
|
|
|
|
it("ignores non-y keypresses", () => {
|
|
const button = document.createElement("button");
|
|
|
|
expect(resolveInboxQuickArchiveKeyAction({
|
|
armed: true,
|
|
defaultPrevented: false,
|
|
key: "n",
|
|
metaKey: false,
|
|
ctrlKey: false,
|
|
altKey: false,
|
|
target: button,
|
|
hasOpenDialog: false,
|
|
})).toBe("ignore");
|
|
});
|
|
|
|
it("stays inert for modifier combos before a real keypress", () => {
|
|
const button = document.createElement("button");
|
|
|
|
expect(resolveInboxQuickArchiveKeyAction({
|
|
armed: true,
|
|
defaultPrevented: false,
|
|
key: "Meta",
|
|
metaKey: false,
|
|
ctrlKey: false,
|
|
altKey: false,
|
|
target: button,
|
|
hasOpenDialog: false,
|
|
})).toBe("ignore");
|
|
|
|
expect(resolveInboxQuickArchiveKeyAction({
|
|
armed: true,
|
|
defaultPrevented: false,
|
|
key: "y",
|
|
metaKey: true,
|
|
ctrlKey: false,
|
|
altKey: false,
|
|
target: button,
|
|
hasOpenDialog: false,
|
|
})).toBe("ignore");
|
|
});
|
|
|
|
it("ignores input typing instead of archiving", () => {
|
|
const input = document.createElement("input");
|
|
|
|
expect(resolveInboxQuickArchiveKeyAction({
|
|
armed: true,
|
|
defaultPrevented: false,
|
|
key: "y",
|
|
metaKey: false,
|
|
ctrlKey: false,
|
|
altKey: false,
|
|
target: input,
|
|
hasOpenDialog: false,
|
|
})).toBe("ignore");
|
|
});
|
|
|
|
it("undoes only a clean lowercase u press when an archive is available", () => {
|
|
const button = document.createElement("button");
|
|
|
|
expect(resolveInboxUndoArchiveKeyAction({
|
|
hasUndoableArchive: true,
|
|
defaultPrevented: false,
|
|
key: "u",
|
|
metaKey: false,
|
|
ctrlKey: false,
|
|
altKey: false,
|
|
target: button,
|
|
hasOpenDialog: false,
|
|
})).toBe("undo_archive");
|
|
});
|
|
|
|
it("keeps uppercase U available for mark-unread handling", () => {
|
|
const button = document.createElement("button");
|
|
|
|
expect(resolveInboxUndoArchiveKeyAction({
|
|
hasUndoableArchive: true,
|
|
defaultPrevented: false,
|
|
key: "U",
|
|
metaKey: false,
|
|
ctrlKey: false,
|
|
altKey: false,
|
|
target: button,
|
|
hasOpenDialog: false,
|
|
})).toBe("ignore");
|
|
});
|
|
|
|
it("arms go-to-inbox on a clean g press", () => {
|
|
const button = document.createElement("button");
|
|
|
|
expect(resolveIssueDetailGoKeyAction({
|
|
armed: false,
|
|
defaultPrevented: false,
|
|
key: "g",
|
|
metaKey: false,
|
|
ctrlKey: false,
|
|
altKey: false,
|
|
target: button,
|
|
hasOpenDialog: false,
|
|
})).toBe("arm");
|
|
});
|
|
|
|
it("navigates to inbox on i after g", () => {
|
|
const button = document.createElement("button");
|
|
|
|
expect(resolveIssueDetailGoKeyAction({
|
|
armed: true,
|
|
defaultPrevented: false,
|
|
key: "i",
|
|
metaKey: false,
|
|
ctrlKey: false,
|
|
altKey: false,
|
|
target: button,
|
|
hasOpenDialog: false,
|
|
})).toBe("navigate_inbox");
|
|
});
|
|
|
|
it("focuses the comment composer on c after g", () => {
|
|
const button = document.createElement("button");
|
|
|
|
expect(resolveIssueDetailGoKeyAction({
|
|
armed: true,
|
|
defaultPrevented: false,
|
|
key: "c",
|
|
metaKey: false,
|
|
ctrlKey: false,
|
|
altKey: false,
|
|
target: button,
|
|
hasOpenDialog: false,
|
|
})).toBe("focus_comment");
|
|
});
|
|
|
|
it("disarms go-to-inbox instead of firing from an editor", () => {
|
|
const input = document.createElement("textarea");
|
|
|
|
expect(resolveIssueDetailGoKeyAction({
|
|
armed: true,
|
|
defaultPrevented: false,
|
|
key: "i",
|
|
metaKey: false,
|
|
ctrlKey: false,
|
|
altKey: false,
|
|
target: input,
|
|
hasOpenDialog: false,
|
|
})).toBe("disarm");
|
|
});
|
|
});
|