Skip to content

Documents and collections dragged onto the Library's tree open Move set to the place they land on - #734

Open
zlareb1 wants to merge 2 commits into
mainfrom
feat/library-drag
Open

zlareb1 wants to merge 2 commits into
mainfrom
feat/library-drag

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Related: #672
Related: #680
Related: #686

Changelog category (leave one):

  • New Feature

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

In the dashboard's Library, drag a document (or the selection it is in) onto a place in the tree to move it there, and drag a collection onto another to nest it or onto Drop here for the top level. Each drop opens the same Move dialog as the menus, already set to that place.

Why

A collection works like a folder of documents, and people move things between folders by dragging them. The Library already had Move to… for documents (knowledge.move) and Move… for a collection (collection.move). Dragging onto the tree is a quicker way to start those same moves.

Scope and risk

  • Dropping documents: at tree width, a row whose writes are available can be dragged. If the dragged row is part of the selection, the whole selection goes with it. A drop opens Move to… (MoveDocumentsDialog) with the destination already picked. It moves through the existing dialog and moveKnowledge, and the summary toast, partial-failure handling and list reload are unchanged. A drop asks for one confirm instead of moving straight away because a move changes who can read the documents, and the dialog says how ("They take X's sharing").
  • Which places take a drop: exactly the places Move to… lists for the documents being dragged, computed by the same placesFrom that builds the dialog's list. So the source place, a collection the person only reads, All documents, and the namespace or My files where Move to… leaves them out all refuse a drop. A selection that spans several places has no place that takes it, because knowledge.move moves from one namespace. A place that takes the drop gets a dashed accent outline while the drag is held, and a solid one with a fill while the pointer is over it. A place that refuses gets no outline, its dragover is not cancelled, and a drop on it does nothing.
  • Nesting collections: a collection the person administers (collection.move requires admin), other than My files, can be dragged in the tree. It can land on a collection the person writes (the handler checks writer on the new parent), but not on itself, on anything under it (isUnder, moved from the dialog into lib/collections.ts so the tree and the dialog share it), or on the parent it is already in. While a nested collection is held, Drop here for the top level appears at the tree's foot, since collection.move takes parent: "". A drop opens MoveCollectionDialog already set to that parent. When the dialog closes, focus goes to the parent it was dropped on, or to New collection for the top level, because the moved row is drawn again elsewhere.
  • States: while a move runs, its dialog's Move button shows it is busy. The target row does not show a busy state of its own, because it sits behind the modal while the move runs. A failure keeps the dialog open with an alert saying what to do; that is where Move to… already reports failures, so no toast is added. After a success, the list reads again in place, keeping its rows, and the moved rows leave it.
  • Not in this change: dropping files from the desktop onto a collection in the tree. The batch upload's dialog adds to the place shown and reads the dropped items in its own drop handler. Letting it target another place from a tree drop is a change of its own.
  • No keys: there are no keyboard shortcuts and no key hints. Every drag repeats an existing button or menu item (Move to… on a row or a selection, Move… in a collection's menu). At phone width there is no tree, so nothing can be dragged.
  • Shared code: lib/useDragHold.ts holds the dragged value a tick after dragstart, because Chrome aborts a drag whose dragstart reshapes the page. It also holds nothing if the drag ended within that tick. The tree and the document list both use it.
  • Known limit: Firefox starts no drag on a <button>. Most of a document row is its preview button, so in Firefox a row drags only from its edges and its tag and place lines. Chromium and WebKit drag the whole row. The menus still offer every move.
  • No server change. Tenant isolation and roles are checked by knowledge.move and collection.move as before.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none.
  • Rollback: a revert leaves nothing behind.

Tests

  • make format-check lint typecheck (with the shared venv): pass.
  • tests/unit/test_doc_links.py and tests/unit/test_public_copy.py: 242 passed. The unit tests that read the frontend (test_dashboard_routes, test_every_list_row_is_projectable, test_page_field_lists_name_server_fields, test_list_answers_what_the_page_asked, test_mixed_version_gate, test_op_reach_census, test_agent_instructions): 293 passed. The full make test-unit was not run locally.
  • In frontend/: npx tsc -b passes. npx vitest run --maxWorkers=2 passes: 311 files, 3606 tests. npm run build and npm run budget pass.
  • New src/views/Documents.drag.test.tsx checks:
    • which places take a row's drag;
    • that a drop opens Move to… set to the place and moves through knowledge.move, with the list read again in place;
    • that refused places (the source, a viewer's collection, All documents) leave dragover uncancelled and drop nothing;
    • that a viewer's row does not drag;
    • that a selection drag sends the whole selection, a row outside the selection goes alone, and a selection across places goes nowhere;
    • the failure alert;
    • that nothing drags without the tree.
  • src/views/LibraryTree.test.tsx gains a block for collection drops:
    • a drop onto itself, its parent, a descendant, a viewer's collection or My files is refused;
    • a drop onto a collection opens Move set to it, calls collection.move and hands focus back;
    • the top-level target appears only for a nested collection;
    • only admin collections drag;
    • a failure keeps the dialog open;
    • the page's documentDrop marks the right places and passes the drop to the page.
  • Playwright with --workers=2 on library*.spec.ts, sharing.spec.ts and a11y.spec.ts, and tasks-*.spec.ts (the Tasks board now holds its dragged card through the same useDragHold): pass. The new library-drag.spec.ts uses real mouse drags at 1440 px: a document onto a collection (it moves, and its row leaves the list), a selection, and a collection nested into another.

Screenshots (mocked API, the dashboard's dark theme, 1440 px):

Dragging a document: the places that take it are outlined, the one under the pointer filled
The drop opens Move to… set to that place
After the move: the row has left the list
Dragging a selection of two
Dragging a nested collection: its own parent and itself refuse; the top level is offered
The drop opens the collection's Move set to the new parent

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. I checked the accepted and refused drop targets against Move to…'s place list and collection.move's role checks, and checked the real drags in Chromium with screenshots.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed. (format-check, lint and typecheck pass; see Tests for the unit tests run)
  • Generated files are regenerated in this PR, not by hand: none are touched.
  • A new migration is additive and numbered after the latest on main; no merged migration is edited. (none)
  • A behaviour change to any file a plugin ships bumps both plugin manifests' version. (none)
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers.
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

zlareb1 and others added 2 commits November 16, 2026 07:56
…et to the place they land on

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>
…on's Move hands focus on only after a move

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: zlareb1 <lareb.zafar@clickhouse.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant