Skip to content

Commit efc12f2

Browse files
BunsDevsteipete
andauthored
feat(workboard): polish drag feedback (#89821)
* feat(workboard): polish drag feedback Co-authored-by: BunsDev <[email protected]> * test(workboard): prove drag feedback in browser * refactor(workboard): keep card rendering lean * test(workboard): avoid drag proof shadowing --------- Co-authored-by: Peter Steinberger <[email protected]>
1 parent a62d7aa commit efc12f2

5 files changed

Lines changed: 76 additions & 7 deletions

File tree

‎docs/plugins/workboard.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ the template id is stored as card metadata.
330330
optional linked session - or open Sessions and choose **Add to Workboard**
331331
for an existing session.
332332
3. Drag the card between columns, or focus its compact status control and use
333-
the menu or ArrowLeft/ArrowRight.
333+
the menu or ArrowLeft/ArrowRight. During a drag, the source card dims and
334+
available drop columns gain an outline.
334335
4. Start work from the card to create or reuse a dashboard session.
335336
5. Open the linked session from the card while the agent works.
336337
6. Let lifecycle sync move running work into `review`/`blocked`, then manually

‎ui/src/pages/workboard/view.test.ts‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,49 @@ describe("renderWorkboard", () => {
422422
expect(container.querySelector(".workboard-health")?.textContent).toContain("running");
423423
});
424424

425+
it("distinguishes the dragged card from its available drop columns", () => {
426+
const host = {};
427+
const state = getWorkboardState(host);
428+
state.loaded = true;
429+
state.cards = [
430+
{
431+
id: "card-1",
432+
title: "Drag feedback",
433+
status: "todo",
434+
priority: "normal",
435+
labels: [],
436+
position: 1000,
437+
createdAt: 1,
438+
updatedAt: 1,
439+
},
440+
];
441+
state.draggedCardId = "card-1";
442+
const container = document.createElement("div");
443+
const props: WorkboardRenderProps = {
444+
host,
445+
client: null,
446+
connected: true,
447+
canWrite: true,
448+
pluginEnabled: true,
449+
agentsList: null,
450+
sessions: [],
451+
onOpenSession: () => undefined,
452+
};
453+
454+
renderInto(container, props);
455+
456+
expect(container.querySelector(".workboard-card")?.classList).toContain(
457+
"workboard-card--dragging",
458+
);
459+
expect(container.querySelectorAll(".workboard-column--drop")).toHaveLength(9);
460+
461+
state.draggedCardId = null;
462+
renderInto(container, props);
463+
464+
expect(container.querySelector(".workboard-card--dragging")).toBeNull();
465+
expect(container.querySelector(".workboard-column--drop")).toBeNull();
466+
});
467+
425468
it("hides cached card mutation controls until a lifecycle teardown reload succeeds", async () => {
426469
const host = {};
427470
const state = getWorkboardState(host);

‎ui/src/pages/workboard/view.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,6 @@ function getCardActionState(props: WorkboardProps, card: WorkboardCard) {
598598
return {
599599
state,
600600
task,
601-
session,
602601
busy,
603602
activeTask,
604603
live,
@@ -1829,7 +1828,8 @@ function renderCard(props: WorkboardProps, card: WorkboardCard) {
18291828
<article
18301829
class="workboard-card priority-${card.priority} ${busy
18311830
? "workboard-card--busy"
1832-
: ""} ${archived ? "workboard-card--archived" : ""} ${healthHighlighted
1831+
: ""} ${archived ? "workboard-card--archived" : ""}
1832+
${state.draggedCardId === card.id ? "workboard-card--dragging" : ""} ${healthHighlighted
18331833
? `workboard-card--health-highlight workboard-card--health-highlight-${state.activeHealthHighlight}`
18341834
: ""} workboard-card--openable"
18351835
role="button"

‎ui/src/pages/workboard/workboard.e2e.test.ts‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,23 @@ describeControlUiE2e("Control UI Workboard mocked Gateway E2E", () => {
526526
await details.locator('button[aria-label="Cancel"]').click();
527527

528528
await writableGateway.deferNext("workboard.cards.move");
529+
const dragSource = cardInColumn(writable.page, "Todo", editedCard.title);
530+
await dragSource.dispatchEvent("dragstart");
531+
await expect
532+
.poll(() => dragSource.getAttribute("class"))
533+
.toContain("workboard-card--dragging");
534+
await expect
535+
.poll(() => dragSource.evaluate((element) => window.getComputedStyle(element).opacity))
536+
.toBe("0.45");
537+
expect(await writable.page.locator(".workboard-column--drop").count()).toBe(9);
538+
await captureScreenshot(writable.page, artifacts, "06-drag-feedback");
539+
await dragSource.dispatchEvent("dragend");
540+
await expect
541+
.poll(() => dragSource.getAttribute("class"))
542+
.not.toContain("workboard-card--dragging");
543+
529544
const moveBefore = (await writableGateway.getRequests("workboard.cards.move")).length;
530-
await cardInColumn(writable.page, "Todo", editedCard.title).dragTo(
545+
await dragSource.dragTo(
531546
statusColumn(writable.page, "Running").locator(".workboard-column__cards"),
532547
);
533548
const moveRequest = await waitForNextRequest(
@@ -543,7 +558,7 @@ describeControlUiE2e("Control UI Workboard mocked Gateway E2E", () => {
543558
await cardInColumn(writable.page, "Running", editedCard.title).waitFor({
544559
state: "visible",
545560
});
546-
await captureScreenshot(writable.page, artifacts, "06-moved-running");
561+
await captureScreenshot(writable.page, artifacts, "07-moved-running");
547562

548563
await writableGateway.deferNext("workboard.cards.update");
549564
const syncBefore = (await writableGateway.getRequests("workboard.cards.update")).length;
@@ -583,7 +598,7 @@ describeControlUiE2e("Control UI Workboard mocked Gateway E2E", () => {
583598
await writable.page.locator(".workboard-detail").getByText("Moved to Review").waitFor({
584599
state: "visible",
585600
});
586-
await captureScreenshot(writable.page, artifacts, "07-lifecycle-review");
601+
await captureScreenshot(writable.page, artifacts, "08-lifecycle-review");
587602
await details.locator('button[aria-label="Cancel"]').click();
588603
await details.waitFor({ state: "hidden" });
589604

@@ -636,7 +651,7 @@ describeControlUiE2e("Control UI Workboard mocked Gateway E2E", () => {
636651
await writable.page
637652
.getByText("Acceptance: live Gateway invalidation refreshed this card")
638653
.waitFor({ state: "visible" });
639-
await captureScreenshot(writable.page, artifacts, "08-reloaded-review");
654+
await captureScreenshot(writable.page, artifacts, "09-reloaded-review");
640655
} finally {
641656
await closeRecordedPage(writable, artifacts, "workboard-writable");
642657
}

‎ui/src/styles/workboard.css‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,16 @@
694694
opacity: 0.72;
695695
}
696696

697+
.workboard-card.workboard-card--dragging {
698+
opacity: 0.45;
699+
border-color: color-mix(in srgb, var(--accent) 70%, var(--border-strong));
700+
box-shadow:
701+
0 0 0 2px color-mix(in srgb, var(--accent) 34%, transparent),
702+
0 8px 22px color-mix(in srgb, #000 18%, transparent);
703+
transform: scale(0.985);
704+
cursor: grabbing;
705+
}
706+
697707
.workboard-card h3 {
698708
margin: 0;
699709
color: var(--text-strong);

0 commit comments

Comments
 (0)