6 Commits

Author SHA1 Message Date
Álvaro Tejero Cantero
26d3c45266
✨ Key branch reviews, threads, and tasks to the file family
A branch review, its verdicts, activity, threads, and tasks now hang
off the file family (a file and every branch cut from it), so they
outlive the branch file. Migration 0817:

- adds file_family, family_id on files and on the rows they own, real
  foreign keys for review_id and merge_id, and thread numbers per
  family, renumbered once;
- renames the review entity and its commands (file_branch_review,
  file_branch_reviewer with a nullable verdict, pinned revision
  columns), the compare marks (file_branch_change_mark, directions
  branch->source and source->branch), and the backend's main to
  source;
- derives a review's target from the branch edge.

At a merge, a thread moves to the target only when it holds an open
task, whole with its tasks, or when it was written outside any
review. Every other thread stays on the closed review, survives the
purge of the branch file, and is listed by get-branch-review-threads.
move-branch-review-thread brings one to the target later.

A branch deleted without a merge takes its reviews, threads, and
tasks with it. Branches of branches are built behind the
branch-stacking flag, off by default.

AI-assisted-by: mixed models
2026-11-23 19:23:21 +01:00
Juan de la Cruz
936939fd75
✨ Compare a branch with main on the canvas (#13201)
* ✨ Add per-profile review marks to branch comparisons

A reviewer goes through the changes of a branch one by one, and the
comparison has to remember which ones they have already seen.

Add the `file_branch_change_review` table and two RPC methods,
`get-branch-change-reviews` and `set-branch-change-review`. A mark
belongs to a branch, a profile, a direction and a change, and keeps the
fingerprint of the change at the time it was marked, so the client can
ask for a new review when the change moves again.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

* ✨ Compare a branch with main on the canvas

The comparison and the conflicts of a branch opened in two modals, away
from the design they talk about. Move both to a compare mode on the
canvas of the branch itself.

The left sidebar lists the changes, in either direction, and the right
one shows the change chosen. The canvas marks every change where it is,
or only the one chosen, and a bar goes through them one at a time. The
conflicts of a merge or an update are resolved in the same mode, with a
popover beside the layer in conflict.

The file is never touched: the workspace is read-only while the mode
lasts, and what the canvas shows that the branch does not hold (the
update, the choices made, main itself) is drawn by the WASM render
alone. Main is put together from the changes of both directions, and
can be seen beside the branch or by holding M.

Each direction keeps its own selection of changes, and the changes
marked as reviewed are stored per profile.

The marks and the bar of the design reviews become shared components.
That bar and the bar of the review now center on the canvas the rulers
leave, as the bar of the branch does.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

* ✨ Add end-to-end tests for the compare mode

Cover entering and leaving the mode, a merge with a change left out, an
update from main and the three kinds of conflict. The tests of the
reviews and of the merged branches follow the comparison to the canvas.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

* 💄 Move the WebGL rendering label to the bottom of the canvas

The top right corner of the canvas now holds the name of the branch
while it is compared with main, and the label was drawn under it.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

* ✨ Make the canvas answer for the changes in the compare mode

While a branch is compared with main both sidebars talk about changes,
not about layers, yet the canvas still selected any layer. Make it
answer for the layers with a change or a conflict alone.

The pointer on such a layer marks it and shows its row in the list, a
click chooses it and a double click zooms to it. A click anywhere else
lets the choice go, and the canvas marks every change again. The row
under the pointer marks its layer too. No layer is selected, outlined
or dragged over; pan and zoom stay as they are, and a commenting tool
takes the canvas back while it is in use.

The bar that goes through the changes shows with a change chosen only.

The canvas no longer draws its projection again on every render, only
when what it shows changes.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

* 💄 Keep the compare navigator grey outside a design review

The bar that goes through the changes of a comparison had the blue
border of a design review even with no review open. Give it the grey of
the bar at the bottom of the canvas, and keep the blue inside a review.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

* ✨ Line main up with the change chosen in the side by side view

Main beside the branch showed the same spot of the page, so a layer the
branch moved fell out of the half of main once the canvas went to it.
The side by side view now has two modes: linked, as it was, and aligned
to the change, where main is moved by how far the layer chosen moved,
so both versions sit at the middle of their halves. Zoom and pan stay
linked, and main slides to the next change as it is chosen.

The mode is picked in a submenu of the view, or with the A key, and the
browser keeps the last one for the next comparison. The note on the
canvas says how far main is moved.

Main put a moved group, path or boolean at the place the branch has:
the diff leaves out the box of a layer, and it was only built again for
the layers whose box is their position and size. Their mark in main now
stands where they are.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

* 💄 Name the side by side view alone in the view menu

The control of the view said "Side by side - aligned" with main lined up
with the change chosen, which the note under the toolbar already says.
It names the view alone now, in both modes.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

* 🐛 Fit the whole page in both halves of the side by side view

Fitting the whole page, and zooming from the menu or to 100%, took the
middle of the canvas as the middle of the page, but beside main that is
the divider: both halves showed the page cut on the left, out of its
middle.

While main is beside the branch these zooms now work in the half of the
branch: the page fits in it and stands at its middle, and a zoom with no
pointer turns on that middle. Fitting the whole page takes in main too,
which can reach further than the branch. Fitting the change chosen goes
through the same fit, which every fit of the workspace now shares.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

* 🐛 Zoom the canvas with the wheel over the marks of the changes

The wheel with ctrl or cmd held only zoomed the canvas over the canvas
itself or over the comments. Over the tags of the changes, which take
the pointer, the browser zoomed the whole page instead. It zooms the
canvas over anything drawn on top of it now: marks, tags and bars.

The note that says how main stands beside the branch takes the look of
the other notes of the canvas, in the primary colour.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

* 🐛 Fix the layers, bars and badges of the compare and review modes

- The comments go over the marks of the changes, so a thread or a task
  opened from a bubble is no longer covered by them.
- How far the review of a comparison is reads at the size of the rest
  of its bar, in Spanish too.
- The way out of a comparison, back from its conflicts and out of a
  review are icon buttons, with what they do in a tooltip.
- Beside the branch, main keeps the frame of the canvas, rounded
  corners included: its half covered it.
- The tab of the other direction counts its changes as soon as the
  comparison opens: they come with every diff, but only the tab shown
  was counted.
- The read-only badge is a quiet grey one with a lock, in the pages
  panel and over the changes of a comparison.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

* 🌐 Translate branching and design reviews into Spanish

The Spanish catalog lacked 418 keys, nearly all of them of branching,
comparing, conflicts, merges and design reviews, so those buttons, menus,
messages and tooltips showed in English. Add them all, with the terms
the catalog already uses.

Drop 61 keys of both catalogs that nothing reads any more, left over
from screens that are gone, and spell "colors" as the rest of the
English catalog does. The Spanish word list takes the valid words the
glued-word check flagged.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

* 🐛 Find the way out of a review by its name in the e2e test

The test looked for "Exit review" in the menu of the review bar, but the
way out sits on the bar itself, and it is an icon button now, with its
name in a tooltip. Click it on the bar, by its name.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

* ✨ Rework the detail of a change in the compare mode

The property changes and the buttons of a change stand on the
background the inspect tab gives its blocks, over the whole width of
the sidebar and as one block when they follow each other. The buttons
go one over the other, as wide as the sidebar.

Under a change or a conflict, the comments that wait for an answer and
the tasks still open on its layer give its context, inside a design
review and outside it. They replace the tab of the comments of the
review the detail had inside one.

The bar of a design review says "In review", on one line: a long title
is cut short, whole on hover. The arrows of the bar that goes through
the changes hold the place in the list between them, with no gap.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

* ♻️ Bring the branching styles in line with the design system

Review every stylesheet of branching and design reviews against the
design system rules. None of them depends on the deprecated styles; a
few details did not follow the rules:

- colors that change with a state go through a local custom property
  (the branch counts, the caption of a preview card, the actions of the
  branch switcher and the next step of a task);
- the alias of the canvas frame border resolves to its DS token;
- the panels of the compare mode scroll with overflow-y, as
  overflow-block is not well supported yet;
- unused imports are gone, and a z-index and a variable that are not DS
  tokens say so in a TODO.

The generated CSS stays the same, except the overflow and two
backgrounds that render as before.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

* ♻️ Reuse the design system components in the branching UI

Where the branching and design review UI built its own control, it uses
the one of the design system, keeping what the screens look like:

- the multi-line fields use the DS text area, as high as before, and
  their labels name them;
- renaming a branch uses the DS input;
- the filter of comments and tasks is a DS menu, as wide as its button;
- the read-only badge is a DS tag, and its own component is gone.

The design system had nothing for a floating panel that is not a menu,
so it gets a popover: it only closes on a click out of it or on Escape
and gives the focus back, and the caller draws the panel. The branch
switcher and the branches of a dashboard card use it instead of the
legacy dropdown, unchanged on screen.

The verdicts of a review and its reviewers read as radios and as
checkboxes. The preview card of the design system, unused since the
old conflicts dialog went away, is deleted.

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>

---------

Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>
2026-11-20 16:24:27 +01:00
Juan de la Cruz
ea61730f61
✨ Add review mode, review comments and tasks to design reviews (#12939)
* ✨ Add review mode, review comments and tasks to design reviews

A design review now opens a read-only review mode. The left panel shows
the pages and layers with the View only badge, the toolbar offers the
review tools (move, comment, comment an area, create a task, show the
changes) and the right panel holds the inspect of the selection, the
comments of the review and its tasks. A bar at the bottom names the
review, shows the progress of its tasks and opens its details.

Comments can point at a spot, a layer or an area, and a comment written
in a review says so with its own mark, wherever the file is open. The
layers panel counts the open comments of each layer.

Tasks are new: work on a file, assigned to someone and tied to a layer
or to a spot of the canvas. A comment can become a task and stays
attached to it. A task moves through open, done, verified, reopened and
won't do; anybody may move it, and each move is an event that records
who made it. Deleting a layer with open tasks moves them to its board
and offers to undo the deletion or to mark them done; a task can then
be linked to another layer or get its layer back. Assignees are told by
email. Merging a branch moves its tasks and their threads into main:
the open ones keep going, the closed ones stay as its history, and the
merge dialog lists them and can tell their assignees.

The details of a review show its overview, its tasks and its activity:
what the saves of the branch did to each layer since the review opened,
by person and day, with the values before and after. The changes can be
shown on the canvas one after another.

The backend adds the review fields of a comment thread, the task and
task event tables, the activity of a review (recorded by each save of a
branch under review) and the commands of the tasks.

* ♻️ Bring the design review styles and components up to the DS

Move what the review UI repeated into the design system: layer-chip*,
progress-bar*, comment-card*, link-button* and textarea*, each with its
story and docs. The screens keep the look they had: the same review states
compare equal, pixel by pixel, before and after.

The stylesheets follow the rules of the UI guide: local variables for the
colors that change by state, the right tokens, no unused imports and fewer
element and nested selectors. What has no DS token or typography says so in
a TODO. The aliases left in comments.scss resolve to their tokens.

The components get complete schemas and a single owner for the copyright.
Translations take literal keys and templates instead of dynamic keys and
glued strings, and comments.cljs no longer depends on the review tasks: the
workspace passes it what a thread shows about its task.

Fix three bugs of the review:

- The inspect took the width of a narrower panel and its height from the
  window, so it looked squeezed and cut its last rows. It now fills the
  panel that holds it.
- Enter on the menu of a task opened the task. The row now reacts only to
  keys on itself, and the menu keeps Enter from the workspace shortcuts.
- The resolved and lost marks ignored the pointer: hover now wins over the
  state of a mark.

* ✨ Turn each review message into a task and restore the filter dropdown

Each message of a thread can now become a task, so one thread can hold
several. The new file_task.comment_id column records the message, the
migration fills it with the first message of the thread for existing tasks,
and the backend rejects a message from another thread or one that already
has a task.

Comments and tasks of a review behave like normal ones. The canvas marks
show a short preview on hover and there is one mark per task. A blue label
marks what belongs to a review, in the thread and in the sidebar, and a
selected card takes a blue border there and the primary color elsewhere.
The new review-label* component holds the label.

The sidebar and the review panel go back to a filter dropdown in place of
the chips. Comments offer the views all, yours and mentions, with an option
to hide the resolved ones. Tasks offer all, yours, open and to verify, with
an option to hide the closed ones. Resolved comments now show by default.

"New task" outside a review now arms the task tool: it shows the task cursor
and the next click opens the task form, not a comment. Then the comment tool
returns, and Esc leaves the tool.

The details modal shows changed properties in the format of the compare
dialogs, and showing a task on the canvas syncs the WASM viewport. The sidebar
cards put the layer chip on the line of the replies, and task states lose the
dot and take a color each.

Fix these bugs:

- The hover card of the activity tab crashed on a change with no token.
- The assignee and reviewer dropdowns came out cut. The select now portals
  into the closest dialog, because the modal makes the rest of the page inert.
- The review label cut the header of the thread. It now sits below it.

* ✨ Group overlapping review marks and let tasks change assignee

Comments and tasks of a review that fall on the same spot now show as one
mark with a counter in a white bubble. A click fans them out, as the comment
bubbles do, and the user picks one. They group on the same layer and, by
proximity, at a low zoom. The card of the mark lists up to five items.

Hovering a mark outlines its layer, or its board when the layer is gone. The
WASM viewport draws no outlines under the comments tool, so it now draws the
highlighted ones there. Opening a comment from a mark closes the open task.

A task can change assignee from the selector in its state and from "Assign
to" in its menu, which holds the team in the same popover. The change shows
right away and goes to the history of the task. A closed task keeps its
assignee.

Deleting a task or a comment now asks first, with the usual confirmation. A
task deleted from the details of a review brings the dialog back on its tab.

The state of a task takes two rows, in its panel and in a thread: state and
layer, then assignee and the review it comes from, which a review omits. The
text of tasks and comments sits in a box. The history no longer says that the
task was created.

* ✨ Keep the branch bar and the palettes at one level on a branch

The open branch bar covered the horizontal scroll of the canvas. It now sits
as far from the bottom as the review bar. Folded, it stays flush.

On a branch the palettes no longer lift over the branch bar: both sit at the
same level and work as a toggle. Opening one folds the other, also through
the palette shortcuts, and both can stay folded. The new `:bottom-bar` state
says which one is open. It exists only while the branch bar does, so a file
that is not a branch keeps the palettes on their layout flags and at their
usual place, and what happens on a branch does not reach them.

The branch bar comes open on a branch and centers on the canvas, not on the
window, so that it clears the folded palettes at usual widths. The room it
published for the palettes goes away with the lifting.

* ✨ Give every task a thread and tidy the design review screens

Every task now lives in a message of a comment thread, so anyone can go on
commenting on it. A task made from scratch gets a thread whose first message
is its title, on its layer and in its review, created in the same
transaction. A comment turned into a task keeps its thread, as before. The
panel of a task with no thread is gone: a task always opens as its thread.
Migration 0814 gives a thread to the tasks that had none. Deleting a thread
deletes its tasks, after a confirmation that says so.

The anchor of a task was a plain map, not a point, so a thread on a layer
refused replies. It is now a point.

The details of a review filter the tasks by state with the chips of the
activity, in the colour of each state, and show how many are closed on the
right. The "New task" button leaves the dialog.

Descriptions look the same everywhere: the box of the branch info dialog,
an "Edit" button and a dashed box when empty. Read, they grow up to 400px
and scroll inside; edited, the textarea starts at 400px. The text of a
review in the sidebar does the same once unfolded.

In the review bar, the author gets a "Publish latest changes" button when
the branch moved past the review, with a hint that approvals must be
renewed. The others keep a badge, now "Unpublished changes", with a hint.
The bar refreshes once the publish lands.

Smaller changes: the resolve checkbox lines up with the task button and has
a tooltip, messages sit in a filled box, task events take an outline, and
the change navigator sits right above the review bar.

* 💄 Sort the test runner requires that cljfmt rejects

The Frontend Tests lint step fails on runner.cljs: the requires for
workspace-tasks-test, review-details-test and review-markers-test sat
out of alphabetical order. This is the output of cljfmt fix.

AI-assisted-by: claude-opus-5-5
Signed-off-by: Álvaro Tejero Cantero <alvorithm@teje.ro>

* 🐛 Test the design review mode in the pull request spec

The review bar replaced the branch banner, so four tests still drove
the branch bar: a visible Compare button, the rectangle tool and the
Review button. They now drive the design review instead.

* Opening a file with a pr-id enters the review: the bar names the
  review, the header trades the file name for the review title, and
  comparing, merging and cancelling sit in the bar's options menu.
* The compare dialog opens from that menu.
* The review is read-only rather than an editable file: the review
  toolbar offers its five tools, the drawing tools are gone, the
  sidebar says View only, and the right panel is the review's own
  Inspect, Comments and Tasks tabs.
* The verdict comes from the bar's Submit review button and the
  dialog it opens, scoped by role so the bar action and the dialog
  action do not collide.

The tests also reach the review bar by its region label instead of
walking up three parents from the Reviewing the design review text,
which broke as soon as the bar's markup changed.

AI-assisted-by: claude-opus-5-5
Signed-off-by: Álvaro Tejero Cantero <alvorithm@teje.ro>

* 🐛 Count only the test thread's acquisitions in the climit test

acquires-the-command-own-limits-before-the-root-limits failed on CI
with an extra "root/global" ahead of the expected order. The test
records metrics through with-redefs, which is global, so a call of
another thread of the test JVM, such as an RPC an earlier test left
running, can take a root limiter inside the window and land in the
same atom.

Record the thread with each metrics call and keep, in
acquired-in-order, only the acquisitions of the calling thread. Both
tests that read it acquire their limiters on the test thread. The
same class of flake was fixed on develop for the waiting-count test
(12d73d0f63); this one is still open there.

AI-assisted-by: claude-opus-5-5
Signed-off-by: Álvaro Tejero Cantero <alvorithm@teje.ro>

* 📚 Describe the task moves the server allows in the table comment

The comment on file_task said a task is reopened only from done and
that editors move tasks. files_task.clj::transitions also reopens a
verified or won't-do task, and set-task-status lets anybody who can
read the file move one. Say the same in the schema.

AI-assisted-by: claude-opus-5-5
Signed-off-by: Álvaro Tejero Cantero <alvorithm@teje.ro>

---------

Signed-off-by: Álvaro Tejero Cantero <alvorithm@teje.ro>
Co-authored-by: Álvaro Tejero Cantero <alvorithm@teje.ro>
2026-11-17 22:30:22 +01:00
Álvaro Tejero Cantero
cd3ba19456
🐛 Follow the branching UI decisions in the Playwright specs
Twelve specs of branches-library, merged-and-archived-branches, and
pull-requests failed on iop-vc-preview before penpot#12780. They still
asserted copy and flows that the branching UI work replaced on purpose:

- The banner of a review now says "Reviewing the design review", and
  its cancel confirmation accepts with "Cancel design review".
- The compare dialog is titled "Review changes".
- A library's header says "Default branch". The popover adds the note
  "Read by library consumers" under the main row.
- Restoring an archived branch asks for confirmation first.
- A merge deletes its branch (penpot#12596), so neither the switcher
  nor the all-branches dialog lists merged branches.

The specs now assert the current behaviour, including that no merged
group or tab shows.

AI-assisted-by: claude-opus-5-5
2026-11-03 12:49:42 +01:00
Juan de la Cruz
720b2f193d
✨ Move branching into the workspace header (#12359)
* ✨ Move the branch switcher to the workspace header

* ✨ Add branch DS components and the all-branches dialog

* 💄 Polish the branch switcher and its menu entry

* ✨ Keep the dashboard to switching branches

* 💄 Polish the branch and pull request review UI

* ♻️ Move the branching UI onto the design system

* 🐛 Address the review of the header branch switcher

The bottom banner turned the nil counts that get-file-branch-info sends
for a branch it cannot compare into zeros, so it said "Up to date with
main". It now says "Couldn't compare this branch with main" in the
warning colour, as the header row already did.

During a review the review banner replaces the branch banner, which was
the only component loading the branch context. The header row now loads
it too, so a review link opened fresh shows the branch under review
instead of "Main".

On a branch, "New branch" in the all-branches dialog is disabled with a
tooltip saying branches are created from main: the server refuses to
branch a branch.

With "Try interactions" gone, the create-review note says reviewers
open the live branch and View mode plays it, and the unused
open-pull-request-viewer event goes.

The pull request specs follow the new banners, and three tests cover
the fixes above.

AI-assisted-by: claude-opus-5-5
Signed-off-by: Álvaro Tejero Cantero <alvorithm@teje.ro>

---------

Signed-off-by: Álvaro Tejero Cantero <alvorithm@teje.ro>
Co-authored-by: Álvaro Tejero Cantero <alvorithm@teje.ro>
2026-10-22 16:50:19 +02:00
Álvaro Tejero Cantero
2a5a235063
✨ Add the design preview of file branching and pull requests
This commit carries the design-branching preview by Juan de la Cruz:
elhombretecla/penpot:branching at 0ac265a3f5, which holds 45 commits
and 3 develop merges and was last synced with develop on 2026-09-16.
The branch is squashed together with a merge of origin/develop at
7c039231f7, so the tree is the merged result.

The merge resolved conflicts in six files:

- backend/src/app/migrations.clj: develop's 0155 and 0156 steps run
  first, then the branching steps; the names differ.
- backend/src/app/rpc/commands/viewer.clj: both requires stay.
- common/src/app/common/flags.cljc: both flags stay.
- frontend/src/app/main/ui/dashboard/file_menu.cljs: "Create branch"
  becomes a menu-item* with the same id, guard and handler.
- frontend/src/app/main/ui/dashboard/grid.cljs: the portal goes with
  develop's menu rewrite; the branches popover stays in the trigger.
- frontend/translations/en.po: both sides' entries stay, with
  develop's source references.

Co-authored-by: Juan de la Cruz <delacruzgarciajuan@gmail.com>
AI-assisted-by: mixed models
2026-10-06 10:36:54 +02:00