plugin(collab-buckets): collaborative buckets via relay

End-to-end shared buckets between relay tenants. Bucket metadata + members
sync through new relay routes (collab-buckets, collab-cards, collab-locks);
card content rides the existing inter-tenant encryption hop. Edit locks,
ownership transfer, LWW conflict stashing, undo for local-bucket destructive
actions, "Make collaborative…" upgrade path, and a resilient outbox for
relay-down create attempts. See plugins/collab-buckets/README.md and
TODO.md for the full picture.

Core hooks added so the plugin can integrate without monkey-patching:
- buckets.js context menu: collab-aware rename/color/delete + Members &
  owner / Make collaborative entries
- editor.js dispatches hyprcrd:editor-open / hyprcrd:editor-close for the
  per-card edit-lock heartbeat
- app.js exposes window.state for the plugin's MutationObserver
- index.php POST/PATCH/DELETE on /api/buckets refuse to mutate collab
  buckets directly (must go through the relay)
- Database.php adds buckets.collab_uid column + unique partial index
- import handler now restores color and collab_uid (was silently dropping
  color, which caused the test runner's auto-restore to wipe custom
  bucket colors)
- relay bootstrap creates collab_buckets, collab_bucket_members,
  collab_cards, collab_card_locks tables and prunes tombstones / expired
  locks on every request

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
thandClaude Opus 4.6 committed 2026-04-11 18:49:53 +02:00
1 parent a29708df85
commit 26ffa0e71f
16 files changed
+3017 -13

No files matched your search

@@ -0,0 +1,304 @@
/* ── Collab buckets plugin ── */
/* Decoration for bucket-bar tabs that represent a collab bucket. The core
still renders the tab via its normal `.bucket-tab` rule; the plugin only
layers a few extras on top: a small 👥 icon swap (done in JS), an unread
dot pinned top-right, and a 3-cycle pulse animation when a fresh update
arrives. */
.bucket-tab.bucket-tab-collab {
position: relative;
/* Subtle left emphasis so collab tabs read differently at a glance */
box-shadow: inset 2px 0 0 0 color-mix(in srgb, var(--t-accent2) 70%, transparent);
}
.bucket-tab.bucket-tab-collab .collab-tab-dot {
position: absolute;
top: -3px;
right: -3px;
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--t-danger);
border: 1px solid var(--t-bg);
box-shadow: 0 0 6px color-mix(in srgb, var(--t-danger) 60%, transparent);
pointer-events: none;
}
.bucket-tab.bucket-tab-collab.pulsing {
animation: collab-bucket-pulse 1.2s ease-in-out 3;
}
/* Keep the 3-cycle cadence regardless of global animation-speed override */
body.anim-fast .bucket-tab.bucket-tab-collab.pulsing,
body.anim-slow .bucket-tab.bucket-tab-collab.pulsing {
animation: collab-bucket-pulse 1.2s ease-in-out 3 !important;
animation-duration: 1.2s !important;
}
@keyframes collab-bucket-pulse {
0%, 100% {
box-shadow: inset 2px 0 0 0 color-mix(in srgb, var(--t-accent2) 70%, transparent),
0 0 0 0 color-mix(in srgb, var(--t-danger) 60%, transparent);
}
50% {
box-shadow: inset 2px 0 0 0 color-mix(in srgb, var(--t-accent2) 70%, transparent),
0 0 0 4px color-mix(in srgb, var(--t-danger) 0%, transparent);
}
}
/* ── Create / edit modal (used by the + Bucket button when the plugin
is loaded) ── */
.collab-modal-overlay {
position: fixed;
inset: 0;
z-index: 240;
background: var(--t-overlay, rgba(0,0,0,0.6));
display: flex;
align-items: center;
justify-content: center;
padding: 24px;
backdrop-filter: blur(var(--ui-blur-overlay, 0px));
-webkit-backdrop-filter: blur(var(--ui-blur-overlay, 0px));
}
.collab-modal {
width: 100%;
max-width: 480px;
max-height: 85vh;
background: var(--t-surface);
border: 1px solid var(--t-border);
border-radius: var(--ui-radius-modal);
box-shadow: var(--ui-shadow-modal);
display: flex;
flex-direction: column;
overflow: hidden;
}
.collab-modal-header {
display: flex;
align-items: center;
gap: 8px;
padding: 12px 16px;
border-bottom: 1px solid var(--t-border);
flex-shrink: 0;
}
.collab-modal-close {
background: transparent;
border: 1px solid var(--t-border);
border-radius: var(--ui-radius-button);
color: var(--t-muted);
cursor: pointer;
padding: 4px 8px;
display: flex;
align-items: center;
transition: color 0.12s, border-color 0.12s;
}
.collab-modal-close:hover { color: var(--t-danger); border-color: var(--t-danger); }
.collab-modal-body {
padding: 16px;
overflow-y: auto;
flex: 1;
min-height: 0;
}
.collab-field { display: block; margin-bottom: 14px; }
.collab-field:last-child { margin-bottom: 0; }
.collab-field.hidden { display: none; }
.collab-label {
display: block;
font-family: var(--t-font-pixel, 'Silkscreen', cursive);
font-size: 9px;
color: var(--t-dim);
text-transform: uppercase;
letter-spacing: 0.05em;
margin-bottom: 5px;
}
.collab-input {
width: 100%;
background: var(--t-bg);
border: 1px solid var(--t-border);
border-radius: var(--ui-radius-input);
color: var(--t-bright);
padding: 7px 10px;
font-size: 12px;
font-family: var(--t-font-content, 'JetBrains Mono', monospace);
outline: none;
transition: border-color 0.12s;
}
.collab-input:focus { border-color: var(--t-accent); }
.collab-color {
width: 52px;
height: 32px;
border: 1px solid var(--t-border);
border-radius: var(--ui-radius-input);
background: transparent;
cursor: pointer;
padding: 2px;
}
.collab-toggle-row {
display: flex !important;
align-items: center;
gap: 8px;
padding: 8px 10px;
background: var(--t-bg);
border: 1px solid var(--t-border);
border-radius: var(--ui-radius-input);
cursor: pointer;
font-size: 12px;
color: var(--t-text);
user-select: none;
}
.collab-toggle-row input { accent-color: var(--t-accent); cursor: pointer; }
.collab-toggle-row:hover { border-color: var(--t-accent); color: var(--t-bright); }
.collab-members-wrap { margin-top: 10px; }
.collab-members {
border: 1px solid var(--t-border);
border-radius: var(--ui-radius-input);
background: var(--t-bg);
max-height: 200px;
overflow-y: auto;
padding: 4px;
}
.collab-members-empty {
font-size: 11px;
color: var(--t-dim);
font-style: italic;
padding: 8px 10px;
}
.collab-member-row {
display: flex;
align-items: center;
gap: 8px;
padding: 5px 8px;
cursor: pointer;
font-size: 12px;
color: var(--t-text);
border-radius: 2px;
user-select: none;
}
.collab-member-row:hover {
background: var(--t-raised);
color: var(--t-bright);
}
.collab-member-row input { cursor: pointer; accent-color: var(--t-accent); }
.collab-modal-footer {
display: flex;
align-items: center;
gap: 8px;
padding: 12px 16px;
border-top: 1px solid var(--t-border);
flex-shrink: 0;
}
.collab-modal-status {
font-family: var(--t-font-pixel, 'Silkscreen', cursive);
font-size: 9px;
color: var(--t-dim);
min-height: 14px;
}
.collab-btn-cancel,
.collab-btn-submit {
padding: 6px 14px;
font-family: var(--t-font-pixel, 'Silkscreen', cursive);
font-size: 10px;
background: transparent;
cursor: pointer;
border: 1px solid var(--t-border);
border-radius: var(--ui-radius-button);
color: var(--t-muted);
transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.collab-btn-cancel:hover {
color: var(--t-danger);
border-color: var(--t-danger);
}
.collab-btn-submit {
color: var(--t-accent);
border-color: var(--t-accent);
}
.collab-btn-submit:hover {
background: color-mix(in srgb, var(--t-accent) 12%, transparent);
}
.collab-readonly {
display: block;
padding: 7px 10px;
background: var(--t-bg);
border: 1px solid var(--t-border);
border-radius: var(--ui-radius-input);
color: var(--t-text);
font-family: var(--t-font-content, 'JetBrains Mono', monospace);
font-size: 12px;
}
.collab-hint {
margin-top: 4px;
font-size: 10px;
color: var(--t-dim);
font-style: italic;
}
/* ── Phase 4: edit-lock indicator on board cards ── */
.board-card.collab-locked {
box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--t-accent2) 55%, transparent);
}
.collab-lock-badge {
position: absolute;
top: 6px;
right: 6px;
width: 20px;
height: 20px;
display: flex;
align-items: center;
justify-content: center;
color: var(--t-accent2);
background: color-mix(in srgb, var(--t-surface) 92%, transparent);
border: 1px solid color-mix(in srgb, var(--t-accent2) 60%, var(--t-border));
border-radius: 50%;
z-index: 6;
pointer-events: none;
font-size: 11px;
}
/* ── Conflict toast (LWW losers stashed into the Conflicts bucket) ── */
.collab-conflict-toast {
position: fixed;
bottom: 24px;
left: 50%;
transform: translateX(-50%);
z-index: 220;
display: flex;
align-items: center;
gap: 10px;
padding: 10px 14px 10px 12px;
max-width: 480px;
font-family: var(--t-font-pixel, 'Silkscreen', cursive);
font-size: 10px;
color: var(--t-bright);
background: var(--t-surface);
border: 1px solid var(--t-danger);
border-radius: var(--ui-radius-modal);
box-shadow: var(--ui-shadow-modal);
transition: opacity 0.4s;
}
.collab-conflict-toast i.ph-warning { color: var(--t-danger); flex-shrink: 0; }
.collab-conflict-toast b { color: var(--t-danger); font-weight: 700; }
.collab-conflict-toast.fade-out { opacity: 0; }
/* Queued variant reuses the layout but switches the danger accents for
a neutral info color — used for "relay was down, bucket is queued" and
"queued bucket finally synced" messages. */
.collab-conflict-toast.collab-queued-toast {
border-color: var(--t-accent2);
}
.collab-conflict-toast.collab-queued-toast i.ph-cloud-arrow-up {
color: var(--t-accent2);
flex-shrink: 0;
}
.collab-conflict-close {
background: transparent;
border: none;
color: var(--t-dim);
cursor: pointer;
padding: 2px 4px;
margin-left: 6px;
display: flex;
align-items: center;
}
.collab-conflict-close:hover { color: var(--t-danger); }