Spaces:
Running
Running
github-actions[bot] commited on
Commit Β·
4bc415b
1
Parent(s): 3a8aafc
Deploy ef6c9f1
Browse filesRename and delete a project, fill its card, drop the run feed's rail (#424)
Source: https://github.com/WINTER4000/turingDNA/commit/ef6c9f1ccc355f20fee764f60474b9a505220bce
Files changed (6)
6387 unmodified lines638863896390639163926393639463956396639763986387 unmodified lines# (auth.construct_identity): the card draws its fold from the# accession and the bench opens on that structure.ident = _auth.construct_identity(c)raw.append({"kind": "construct", "id": cid,"name": c.get("name") or "Construct","at": c.get("updated_at") or c.get("created_at"),"created_at": c.get("created_at"),"phase": {"Design": 0, "Build": 1, "Edit": 2, "Learn": 3}.get(c.get("phase"), 0),"gene": ident.get("gene", ""), "organism": ident.get("organism", ""),"uniprot": ident.get("uniprot", "")})for l in libs:6387 unmodified lines6388638963906391639263936394639563966397639863996400640164026403640464056406640764086387 unmodified lines# (auth.construct_identity): the card draws its fold from the# accession and the bench opens on that structure.ident = _auth.construct_identity(c)# WHAT THE PROJECT ACTUALLY HOLDS. The ids are already in hand β# the loop above walks every one of them to build# artifact_projects β and none of the counts reached the card,# so a construct card had nothing in its middle while a library# card had three stat tiles. Counts only: the allowlist above# still holds, and an id is a pointer this rollup has no reason# to hand out.raw.append({"kind": "construct", "id": cid,"name": c.get("name") or "Construct","at": c.get("updated_at") or c.get("created_at"),"created_at": c.get("created_at"),"phase": {"Design": 0, "Build": 1, "Edit": 2, "Learn": 3}.get(c.get("phase"), 0),"n_plasmids": len([x for x in (c.get("plasmid_ids") or []) if x]),"n_crispr": len([x for x in (c.get("crispr_ids") or []) if x]),"n_primers": len([x for x in (c.get("primer_ids") or []) if x]),"gene": ident.get("gene", ""), "organism": ident.get("organism", ""),"uniprot": ident.get("uniprot", "")})for l in libs:
8071 unmodified lines807280738074807580768077807880798080808145 unmodified lines8127812881298130813181328071 unmodified lines(plain or .hot) and .mc-cx-stats' borders both run edge-to-edge, andwithout clipping their SQUARE corners would poke out past the now-roundones at the bottom of the card. */.mc-cx { background: var(--bg-card); cursor: pointer; border: 1px solid var(--line-strong); text-align: left;padding: 0; font-family: inherit; display: flex; flex-direction: column; transition: border-color var(--t-fast);border-radius: var(--r-4); overflow: hidden; }.mc-cx:hover { border-color: var(--ink-strong); }/* flex:1 so the equal-height row's spare space collects HERE, above thebottom block. Without it the spare space lands between the phase rowand the action row (.mc-cx-act's margin-top:auto), which splits the45 unmodified linesaccession with no spaces in it has to break on 15.3 too. Samecombination .mc-recent-nm already uses. */overflow-wrap: anywhere; word-break: break-word; }.mc-cx-badge { font-family: var(--font-mono); font-size: var(--t-1); letter-spacing: 0.06em; text-transform: uppercase;color: var(--success); border: 1px solid var(--success); padding: 2px 6px; font-weight: 400;flex: none; white-space: nowrap; }8071 unmodified lines8072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814245 unmodified lines8188818981908191819281938194819581968197819881998071 unmodified lines(plain or .hot) and .mc-cx-stats' borders both run edge-to-edge, andwithout clipping their SQUARE corners would poke out past the now-roundones at the bottom of the card. *//* The grid item. A construct card carries a β― button for rename/delete, andthat cannot live inside .mc-cx because .mc-cx IS a <button> β nesting oneis invalid and drops the inner control out of the keyboard order. So thewrapper is the grid item, the card stretches to fill it, and the β― sitsover the card as a sibling. _mcCards() hides THIS element, not the card,or a paged-out card would leave its wrapper holding an empty cell. */.mc-cx-wrap { position: relative; display: flex; min-width: 0; }.mc-cx-wrap[hidden] { display: none; }.mc-cx-wrap > .mc-cx { flex: 1; min-width: 0; }.mc-cx { background: var(--bg-card); cursor: pointer; border: 1px solid var(--line-strong); text-align: left;padding: 0; font-family: inherit; display: flex; flex-direction: column; transition: border-color var(--t-fast);border-radius: var(--r-4); overflow: hidden; }.mc-cx:hover { border-color: var(--ink-strong); }/* β― β quiet until the card is under the pointer, because it is the onlydestructive route on this page and should not advertise itself. It staysvisible once focused or once its menu is open, or it would vanish fromunder a keyboard user mid-interaction. */.mc-cx-menu { position: absolute; top: 8px; right: 8px; z-index: 2;width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;padding: 0; border: 1px solid transparent; border-radius: var(--r-2);background: none; color: var(--ink-faint); cursor: pointer; font-size: var(--t-3); line-height: 1;opacity: 0; transition: opacity var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease),color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }.mc-cx-wrap:hover .mc-cx-menu,.mc-cx-menu:focus-visible,.mc-cx-menu[aria-expanded="true"] { opacity: 1; }.mc-cx-menu:hover,.mc-cx-menu[aria-expanded="true"] { background: var(--bg-subtle); border-color: var(--line); color: var(--ink-strong); }@media (hover: none) { .mc-cx-menu { opacity: 1; } }.mc-cx-pop { position: absolute; top: 38px; right: 8px; z-index: 5; min-width: 168px;display: flex; flex-direction: column; padding: 5px;background: var(--bg-card); border: 1px solid var(--line-strong);border-radius: var(--r-3); box-shadow: 0 10px 28px rgba(10, 10, 10, .14); }.mc-cx-pop button { appearance: none; border: 0; background: none; cursor: pointer;font: inherit; font-size: var(--t-2); text-align: left; color: var(--ink-strong);padding: 8px 10px; border-radius: var(--r-2); }.mc-cx-pop button:hover, .mc-cx-pop button:focus-visible { background: var(--bg-subtle); outline: none; }.mc-cx-pop button.is-danger { color: var(--danger); }.mc-cx-pop button.is-danger:hover, .mc-cx-pop button.is-danger:focus-visible { background: var(--danger-light); }/* The empty state of the stats strip. A construct with nothing filed underit used to render nothing at all, and because the grid gives every cardthe height of the tallest, that space collected in .mc-cx-hd and the cardread as unfinished. A sentence that says what goes there fills it and isworth more than three zeroes. */.mc-cx-stats--empty { display: block; padding: 13px 18px; font-size: var(--t-2);line-height: 1.5; color: var(--ink-soft); }/* ββ rename / delete dialog βββββββββββββββββββββββββββββββββββββββββββ */.mc-cx-dlg .modal-panel { max-width: 440px; }.mc-cx-dlg-body { margin: 0; font-size: var(--t-3); line-height: 1.55; color: var(--ink); }.mc-cx-dlg-body b { color: var(--ink-strong); }.mc-cx-dlg-in { width: 100%; margin-top: 14px; padding: 9px 11px; font: inherit; font-size: var(--t-3);color: var(--ink-strong); background: var(--bg-app);border: 1px solid var(--line-strong); border-radius: var(--r-2); }.mc-cx-dlg-in:focus-visible { outline: none; border-color: var(--ink-strong); box-shadow: var(--ring) var(--brand-ring); }.mc-cx-dlg-act { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }.mc-cx-dlg-danger { appearance: none; cursor: pointer; font: inherit; font-size: var(--t-2); font-weight: 600;padding: 9px 16px; border-radius: var(--r-2);color: var(--on-accent); background: var(--danger); border: 1px solid var(--danger); }.mc-cx-dlg-danger:hover { filter: brightness(.93); }.mc-cx-dlg-danger:focus-visible { outline: none; box-shadow: var(--ring) var(--danger-light); }/* flex:1 so the equal-height row's spare space collects HERE, above thebottom block. Without it the spare space lands between the phase rowand the action row (.mc-cx-act's margin-top:auto), which splits the45 unmodified linesaccession with no spaces in it has to break on 15.3 too. Samecombination .mc-recent-nm already uses. */overflow-wrap: anywhere; word-break: break-word; }/* Room for the β―, so a long name never runs under it; only the cards thathave one pay for it. BELOW the two rules above on purpose: the invarianttests for the clamp and for the flex row each read the FIRST`.mc-cx-nm` / `.mc-cx-nm-t` block by regex, so an override declaredearlier shadows the real one and reads as the clamp having been removed. */.mc-cx--menu .mc-cx-nm-t { padding-right: 26px; }.mc-cx-badge { font-family: var(--font-mono); font-size: var(--t-1); letter-spacing: 0.06em; text-transform: uppercase;color: var(--success); border: 1px solid var(--success); padding: 2px 6px; font-weight: 400;flex: none; white-space: nowrap; }
12254 unmodified lines12255122561225712258122591226012261122621226312264122651226613 unmodified lines122801228112282122831228412285122868 unmodified lines12295122961229712298122991230012301392 unmodified lines12694126951269612697126981269912700127011270212703127041270512706667 unmodified lines13374133751337613377133781337913380133811338213383133841338512254 unmodified linesreturn '<span class="mc-cx-pd' + cls + '"></span>';}).join('');const isLib = c.kind === 'library';const stats = isLib ? ('<div class="mc-cx-stats">' +'<div class="mc-cx-st"><div class="mc-cx-st-n">' + fmtScore(c.top_fitness) + '</div><div class="mc-cx-st-l">Top score</div></div>' +'<div class="mc-cx-st"><div class="mc-cx-st-n">' + (c.n_variants != null ? c.n_variants : 'β') + '</div><div class="mc-cx-st-l">Variants</div></div>' +'<div class="mc-cx-st"><div class="mc-cx-st-n">' + (c.n_tested || 0) + '</div><div class="mc-cx-st-l">Tested</div></div>' +'</div>') : '';const nx = c.next || {};/* Both states of the loop earn the emphasis: "round 2 is ready"because the user can act right now, and "waiting on your results"13 unmodified linesconst openedIso = readOpenedAt(c.kind, c.id) || c.updated_at || c.at;const dateLine = 'Created ' + mesc(relTime(createdIso) || 'β') +' Β· Opened ' + mesc(relTime(openedIso) || 'β');return '<button class="mc-cx" data-kind="' + mesc(c.kind) + '" data-id="' + mesc(c.id) +'" data-construct="' + mesc(c.construct_id || '') +'" data-name="' + mesc(c.name) + '" data-sub="' + mesc(dateLine) +'" data-phase="' + c.phase + '" data-route="' + mesc((nx.route) || c.kind) + '">' +8 unmodified lines'<span class="mc-cx-dates">' + dateLine + '</span></span></span>' +stats +'<span class="mc-cx-phase">' + dots + '<span class="mc-cx-ph">' + PHASES[c.phase] + '</span></span>' +act + '</button>';}function projectCardHtml(p) {392 unmodified lineslet _mcShown = MC_PAGE;let _mcWired = false;function _mcCards() {const g = document.getElementById('mcPortfolio');return g ? [].slice.call(g.querySelectorAll('.mc-cx')) : [];}/* Name and kind. Deliberately NOT the date line: "Created 3d ago" wouldmake every card match "ago", and nobody searches for a relative date. */function _mcHay(card) {const kind = card.querySelector('.mc-cx-sub');return ((card.getAttribute('data-name') || '') + ' ' +(kind ? kind.textContent : '')).toLowerCase();667 unmodified linesif (scrim) scrim.addEventListener('click', finderClose);}function wire() {// Both grids, one handler. Collaborative cards are MOVED out of the// portfolio into the shared shelf, and this listener is delegated on// the container β a moved card in an unwired grid is a card that// silently stops opening.const onGridClick = (e) => {const card = e.target.closest('.mc-cx');// A drawn fold opens the project on its Structure tab: the one// place a project's protein was otherwise unreachable from home.12254 unmodified lines12255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228713 unmodified lines12301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123208 unmodified lines12329123301233112332123331233412335392 unmodified lines1272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753667 unmodified lines134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359312254 unmodified linesreturn '<span class="mc-cx-pd' + cls + '"></span>';}).join('');const isLib = c.kind === 'library';/* WHY A CONSTRUCT GETS STATS TOO. The grid sets grid-auto-rows:1fr soevery card is the height of the tallest β a deliberate choice (onecard size, whatever is in the card). A library filled that heightwith three tiles and a construct filled it with nothing, so thespare space collected in .mc-cx-hd and the card read as unfinished.These three counts are what the project actually holds, they comefrom ids the rollup was already walking, and they grow as the workdoes. */const nPlas = c.n_plasmids || 0, nCr = c.n_crispr || 0, nPr = c.n_primers || 0;const tile = (n, label) =>'<div class="mc-cx-st"><div class="mc-cx-st-n">' + n +'</div><div class="mc-cx-st-l">' + label + '</div></div>';const stats = isLib ? ('<div class="mc-cx-stats">' +'<div class="mc-cx-st"><div class="mc-cx-st-n">' + fmtScore(c.top_fitness) + '</div><div class="mc-cx-st-l">Top score</div></div>' +'<div class="mc-cx-st"><div class="mc-cx-st-n">' + (c.n_variants != null ? c.n_variants : 'β') + '</div><div class="mc-cx-st-l">Variants</div></div>' +'<div class="mc-cx-st"><div class="mc-cx-st-n">' + (c.n_tested || 0) + '</div><div class="mc-cx-st-l">Tested</div></div>' +'</div>')/* Three zeroes say nothing a new user can act on, so an emptyproject says what would go in it instead. Still fills thespace, and tells them what the project is for. */: (nPlas + nCr + nPr) === 0? '<div class="mc-cx-stats mc-cx-stats--empty">Nothing filed yet β ' +'plasmids, guide sets and primer sets you save land here.</div>': '<div class="mc-cx-stats">' + tile(nPlas, nPlas === 1 ? 'Plasmid' : 'Plasmids') +tile(nCr, nCr === 1 ? 'Guide set' : 'Guide sets') +tile(nPr, nPr === 1 ? 'Primer set' : 'Primer sets') + '</div>';const nx = c.next || {};/* Both states of the loop earn the emphasis: "round 2 is ready"because the user can act right now, and "waiting on your results"13 unmodified linesconst openedIso = readOpenedAt(c.kind, c.id) || c.updated_at || c.at;const dateLine = 'Created ' + mesc(relTime(createdIso) || 'β') +' Β· Opened ' + mesc(relTime(openedIso) || 'β');/* Rename and delete live on a sibling button, not inside the card.The card IS a <button>; nesting another one is invalid HTML andtakes the inner control out of the keyboard order in every browserthat reparents it. The wrapper is the grid item now, so it carriesthe equal-height stretch and the card fills it. */const menu = c.kind === 'construct'? '<button class="mc-cx-menu" type="button" data-cx-menu="' + mesc(c.id) +'" data-cx-name="' + mesc(c.name) + '" aria-haspopup="menu" aria-expanded="false"' +' aria-label="Rename or delete ' + mesc(c.name) + '">' +'<span aria-hidden="true">⋯</span></button>': '';return '<div class="mc-cx-wrap">' + menu +'<button class="mc-cx' + (menu ? ' mc-cx--menu' : '') +'" data-kind="' + mesc(c.kind) + '" data-id="' + mesc(c.id) +'" data-construct="' + mesc(c.construct_id || '') +'" data-name="' + mesc(c.name) + '" data-sub="' + mesc(dateLine) +'" data-phase="' + c.phase + '" data-route="' + mesc((nx.route) || c.kind) + '">' +8 unmodified lines'<span class="mc-cx-dates">' + dateLine + '</span></span></span>' +stats +'<span class="mc-cx-phase">' + dots + '<span class="mc-cx-ph">' + PHASES[c.phase] + '</span></span>' +act + '</button></div>';}function projectCardHtml(p) {392 unmodified lineslet _mcShown = MC_PAGE;let _mcWired = false;/* The grid ITEM, which is not always the card. A construct card iswrapped so its β― button can be a sibling rather than a nested button;hiding the card inside its wrapper would leave the wrapper holding anempty cell, so the pager and the search both have to act on whicheverelement the grid actually lays out. */function _mcCards() {const g = document.getElementById('mcPortfolio');if (!g) return [];return [].slice.call(g.querySelectorAll('.mc-cx')).map((c) => c.closest('.mc-cx-wrap') || c);}/* Name and kind. Deliberately NOT the date line: "Created 3d ago" wouldmake every card match "ago", and nobody searches for a relative date. */function _mcHay(item) {/* β¦and whatever reads a card's content has to step back in. Inlinedrather than a helper: tests/js/portfolio_pager.cjs lifts thesefunctions out of this file BY NAME and runs them, so a new namethey call is a ReferenceError in the harness. A card has no .mc-cxdescendant, so this resolves to itself for an unwrapped one. */const card = (item && item.querySelector && item.querySelector('.mc-cx')) || item;const kind = card.querySelector('.mc-cx-sub');return ((card.getAttribute('data-name') || '') + ' ' +(kind ? kind.textContent : '')).toLowerCase();667 unmodified linesif (scrim) scrim.addEventListener('click', finderClose);}/* ββ Rename and delete, from the card ββββββββββββββββββββββββββββββββBoth endpoints already existed β PATCH and DELETE /api/constructs/<id>,with `name` on update_construct's writable allowlist β and nothing inthe UI called either, so a project could be created and then neverrenamed or removed. This is the missing half, and only that.Delete is permanent and the dialog says so. What it deletes is thePROJECT, which is a grouping: auth.delete_construct deliberately leavesthe plasmids and libraries filed under it alone, because deleting aproject must never destroy a plasmid the user still has open in anothertab. The dialog states both halves, because a warning that overstateswhat it destroys trains people to ignore the next one. */let cxPop = null;function cxMenuClose(refocus) {if (!cxPop) return;const t = cxPop.trigger;cxPop.el.remove();cxPop = null;document.removeEventListener('keydown', cxMenuKey, true);if (t) { t.setAttribute('aria-expanded', 'false'); if (refocus) t.focus(); }}function cxMenuKey(e) {if (e.key === 'Escape') { e.preventDefault(); cxMenuClose(true); }}function cxMenuOpen(trigger) {const reopening = cxPop && cxPop.trigger === trigger;cxMenuClose();if (reopening) return; // a second click on β― closes itconst id = trigger.getAttribute('data-cx-menu');const name = trigger.getAttribute('data-cx-name') || 'this project';const pop = document.createElement('div');pop.className = 'mc-cx-pop';pop.setAttribute('role', 'menu');pop.innerHTML ='<button type="button" role="menuitem" data-cx-do="rename">Rename\u2026</button>' +'<button type="button" role="menuitem" class="is-danger" data-cx-do="delete">Delete\u2026</button>';pop.addEventListener('click', (e) => {const b = e.target.closest('[data-cx-do]');if (!b) return;e.stopPropagation();const what = b.getAttribute('data-cx-do');cxMenuClose();if (what === 'rename') cxRename(id, name); else cxDelete(id, name);});trigger.parentNode.appendChild(pop);trigger.setAttribute('aria-expanded', 'true');cxPop = { el: pop, trigger };const first = pop.querySelector('button');if (first) first.focus();document.addEventListener('keydown', cxMenuKey, true);}// Any click outside closes it. Captured, so it still runs when a handler// below calls stopPropagation.document.addEventListener('click', (e) => {if (!cxPop) return;if (e.target.closest('.mc-cx-pop') || e.target.closest('.mc-cx-menu')) return;cxMenuClose();}, true);/* A dialog in the app's own .modal furniture, resolving to the answer βthe typed name, true, or null when dismissed β so a caller reads onevalue instead of unwinding callbacks. */function cxDialog(opt) {return new Promise((resolve) => {const wrap = document.createElement('div');wrap.className = 'modal mc-cx-dlg';wrap.setAttribute('role', 'dialog');wrap.setAttribute('aria-modal', 'true');wrap.innerHTML ='<div class="modal-backdrop" data-cx-close></div>' +'<div class="modal-panel" role="document">' +'<header class="modal-header"><div>' +'<p class="modal-sub">' + mesc(opt.sub) + '</p><h2>' + mesc(opt.title) + '</h2></div>' +'<button class="modal-close" aria-label="Close" data-cx-close>×</button></header>' +'<div class="modal-body"><p class="mc-cx-dlg-body">' + opt.body + '</p>' +(opt.field ? '<input class="mc-cx-dlg-in" type="text" maxlength="120" ' +'aria-label="' + mesc(opt.field) + '" value="' + mesc(opt.value || '') + '">' : '') +'<div class="mc-cx-dlg-act">' +'<button type="button" class="ghost" data-cx-close>Cancel</button>' +'<button type="button" class="' + (opt.danger ? 'mc-cx-dlg-danger' : 'primary') +'" data-cx-go>' + mesc(opt.confirmText) + '</button>' +'</div></div></div>';const input = wrap.querySelector('.mc-cx-dlg-in');const done = (v) => {document.removeEventListener('keydown', onKey, true);wrap.remove();resolve(v);};const onKey = (e) => {if (e.key === 'Escape') { e.preventDefault(); done(null); return; }if (e.key === 'Enter' && input && document.activeElement === input) {e.preventDefault(); done(input.value.trim() || null);}};wrap.addEventListener('click', (e) => {if (e.target.closest('[data-cx-close]')) { e.preventDefault(); done(null); return; }if (e.target.closest('[data-cx-go]')) {e.preventDefault();done(input ? (input.value.trim() || null) : true);}});document.addEventListener('keydown', onKey, true);document.body.appendChild(wrap);if (input) { input.focus(); input.select(); return; }const go = wrap.querySelector('[data-cx-go]');if (go) go.focus();});}async function cxRename(id, name) {const next = await cxDialog({sub: 'Project', title: 'Rename project',body: 'This changes what the project is called. Nothing inside it moves.',field: 'Project name', value: name, confirmText: 'Save',});if (!next || next === name) return;try {const r = await fetch('/api/constructs/' + encodeURIComponent(id), {method: 'PATCH', headers: { 'Content-Type': 'application/json' },credentials: 'same-origin', body: JSON.stringify({ name: next }),});const j = await r.json().catch(() => ({}));if (!r.ok || !j.ok) throw new Error(j.error || 'Could not rename this project.');showToast('Renamed to \u201c' + next + '\u201d.', 'info');load(true);} catch (err) {showToast(err.message || 'Could not rename this project.', 'warn');}}async function cxDelete(id, name) {const go = await cxDialog({sub: 'Project', title: 'Delete \u201c' + name + '\u201d?',body: 'This permanently deletes the project. <b>It cannot be undone.</b> ' +'Plasmids, libraries and designs you saved inside it are kept, and ' +'stay reachable from their own tools.',confirmText: 'Delete forever', danger: true,});if (!go) return;try {const r = await fetch('/api/constructs/' + encodeURIComponent(id), {method: 'DELETE', credentials: 'same-origin',});const j = await r.json().catch(() => ({}));if (!r.ok || !j.ok) throw new Error(j.error || 'Could not delete this project.');showToast('Deleted \u201c' + name + '\u201d.', 'info');load(true);} catch (err) {showToast(err.message || 'Could not delete this project.', 'warn');}}function wire() {// Both grids, one handler. Collaborative cards are MOVED out of the// portfolio into the shared shelf, and this listener is delegated on// the container β a moved card in an unwired grid is a card that// silently stops opening.// The β― sits beside the card, not inside it, so it never reaches// openCard β and a click inside the open menu must not fall through// to the card behind it either.const onGridClick = (e) => {const trigger = e.target.closest('.mc-cx-menu');if (trigger) { e.preventDefault(); e.stopPropagation(); cxMenuOpen(trigger); return; }if (e.target.closest('.mc-cx-pop')) { e.stopPropagation(); return; }const card = e.target.closest('.mc-cx');// A drawn fold opens the project on its Structure tab: the one// place a project's protein was otherwise unreachable from home.
291 unmodified lines2922932942952962972983 unmodified lines3023033043053063073083093103 unmodified lines31431531631731831932032132232332432532632732832933033112 unmodified lines34434534634734834935035135235335435535635735835936036136236336457 unmodified lines422423424425426427428147 unmodified lines576577578579580581582291 unmodified linesgrid-template-columns: minmax(0, 1fr);gap: 0;--tl-date: 64px;--tl-node: 46px;}.mc-recent-nm { min-width: 0; line-height: 1.4; overflow-wrap: anywhere; word-break: break-word; }.mc-recent-goal { overflow-wrap: anywhere; word-break: break-word; }3 unmodified lines#mcResume .mc-recent {position: relative;display: grid;grid-template-columns: var(--tl-date) var(--tl-node) minmax(0, 1fr) auto;align-items: start;gap: 0;padding: 0 0 26px;background: none;border: 0;3 unmodified linestext-align: left;color: var(--ink);}/* The spine, drawn per entry so a hidden entry leaves no gap; it stops atthe last entry's node. */#mcResume .mc-recent:not(.mc-recent--featured)::before {content: "";position: absolute;left: calc(var(--tl-date) + var(--tl-node) / 2);top: 0;bottom: 0;width: 1px;background: var(--line-strong);}#mcResume .mc-recent:not(.mc-recent--featured):last-child::before { bottom: auto; height: 12px; }/* app.css hides the conversation already open in the Turing rail with.mc-recent[hidden]; the display above outranks it, so it is restated. */#mcResume .mc-recent[hidden] { display: none; }12 unmodified linesfont-variant-numeric: tabular-nums;color: var(--ink-strong);}#mcResume .mc-recent-node {position: relative;z-index: 1;justify-self: center;width: 11px;height: 11px;margin-top: 4px;border-radius: 50%;background: var(--bg-app);border: 1.5px solid var(--ink-strong);transition: background-color var(--t-fast) var(--ease);}/* Where the pointer is: the node lights amber and the title takes an amberunderline. The entry itself does not move or fill β it is a line in a log. */#mcResume .mc-recent:hover .mc-recent-node { background: var(--amber); }#mcResume .mc-recent:hover .mc-recent-nm {text-decoration: underline;text-decoration-color: var(--amber);57 unmodified lines}#mcResume .mc-recent--featured:hover { background: var(--bg-card); }#mcResume .mc-recent--featured:focus-visible { box-shadow: var(--ring) var(--brand-ring); }#mcResume .mc-recent--featured :is(.mc-recent-when, .mc-recent-node) { display: none; }#mcResume .mc-recent--featured:hover .mc-recent-nm { text-decoration: none; }#mcResume .mc-recent--featured .mc-recent-fold {147 unmodified lines.mc-tools .workbench-tool:nth-child(even) { padding-left: 16px; }@media (max-width: 560px) {.mc-tools > summary span { float: none; display: block; margin-top: 6px; }#mcResume { --tl-date: 40px; --tl-node: 30px; }#mcResume .mc-recent--featured { grid-template-columns: minmax(0, 1fr); grid-template-areas: "fold" "main" "state"; grid-template-rows: auto; }#mcResume .mc-recent--featured .mc-recent-fold { flex-direction: row; justify-content: flex-start; gap: 16px; padding: 14px 18px; border-right: 0; border-bottom: 1px solid var(--line); }#mcResume .mc-recent-cv { width: 96px; height: 96px; }291 unmodified lines2922932942952962972982993003013 unmodified lines3053063073083093103113123133 unmodified lines31731831932032132232332412 unmodified lines33733833934034134234334434534634734857 unmodified lines406407408409410411412147 unmodified lines560561562563564565566291 unmodified linesgrid-template-columns: minmax(0, 1fr);gap: 0;--tl-date: 64px;/* Was --tl-node: 46px, a column holding a circle on a drawn spine.The rail is gone (see .mc-recent below); what the date still needs isair between it and the title, so the same width is now just a gap. */--tl-gap: 20px;}.mc-recent-nm { min-width: 0; line-height: 1.4; overflow-wrap: anywhere; word-break: break-word; }.mc-recent-goal { overflow-wrap: anywhere; word-break: break-word; }3 unmodified lines#mcResume .mc-recent {position: relative;display: grid;grid-template-columns: var(--tl-date) minmax(0, 1fr) auto;align-items: start;gap: 0 var(--tl-gap);padding: 0 0 26px;background: none;border: 0;3 unmodified linestext-align: left;color: var(--ink);}/* No spine. The dates already carry the sequence, and a drawn rail with anode per row added a column of furniture to what is a list of links. *//* app.css hides the conversation already open in the Turing rail with.mc-recent[hidden]; the display above outranks it, so it is restated. */#mcResume .mc-recent[hidden] { display: none; }12 unmodified linesfont-variant-numeric: tabular-nums;color: var(--ink-strong);}/* The markup still emits the node; it is aria-hidden furniture, so hiding ithere keeps this a CSS-only change and leaves nothing in the grid. */#mcResume .mc-recent-node { display: none; }/* Where the pointer is. With the node gone the amber underline on the titleis the whole hover signal, so it has to carry it alone. The entry itselfstill does not move or fill β it is a line in a log. */#mcResume .mc-recent:hover .mc-recent-nm {text-decoration: underline;text-decoration-color: var(--amber);57 unmodified lines}#mcResume .mc-recent--featured:hover { background: var(--bg-card); }#mcResume .mc-recent--featured:focus-visible { box-shadow: var(--ring) var(--brand-ring); }#mcResume .mc-recent--featured .mc-recent-when { display: none; }#mcResume .mc-recent--featured:hover .mc-recent-nm { text-decoration: none; }#mcResume .mc-recent--featured .mc-recent-fold {147 unmodified lines.mc-tools .workbench-tool:nth-child(even) { padding-left: 16px; }@media (max-width: 560px) {.mc-tools > summary span { float: none; display: block; margin-top: 6px; }#mcResume { --tl-date: 40px; --tl-gap: 12px; }#mcResume .mc-recent--featured { grid-template-columns: minmax(0, 1fr); grid-template-areas: "fold" "main" "state"; grid-template-rows: auto; }#mcResume .mc-recent--featured .mc-recent-fold { flex-direction: row; justify-content: flex-start; gap: 16px; padding: 14px 18px; border-right: 0; border-bottom: 1px solid var(--line); }#mcResume .mc-recent-cv { width: 96px; height: 96px; }
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191"""Rename and delete a project from the home page, and fill the card.
Three things the Workspace home was missing, reported 2026-12-01.
1. RENAME AND DELETE. `PATCH /api/constructs/<id>` (with `name` on update_construct's writable allowlist) and `DELETE /api/constructs/<id>` both already existed and worked. Nothing in the UI called either, so a project could be created and then never renamed or removed. The whole gap was the last connection β the same shape as overhangs.check and primers.py in mistake 34, two days running.
2. THE HOLLOW CARD. `.mc-grid` sets `grid-auto-rows: 1fr` so every card is the height of the tallest, which is deliberate (one card size, whatever is in the card). A library filled that height with three stat tiles; a construct rendered none, so the spare space collected in `.mc-cx-hd` and the card read as unfinished. The counts that fill it β plasmids, guide sets, primer sets β were already being walked by the rollup to build `artifact_projects` and were simply never serialized.
3. THE TIMELINE RAIL. The run feed drew a vertical spine with a node per row. Removed; the dates already carry the sequence.
WHAT THIS FILE PINS. The counts reach the card; the card renders them and sayssomething useful when there are none; the menu is a SIBLING of the card buttonrather than a nested one; the pager hides the grid item and not the cardinside it; the delete copy is accurate about what survives; and the rail isgone from the stylesheet."""import jsonimport re
from _frontend import app_js
def _static(name): with open("dee/static/" + name, encoding="utf-8") as fh: return fh.read()
# ββ 1. the counts reach the card ββββββββββββββββββββββββββββββββββββββββββββdef test_the_rollup_serializes_what_a_project_holds(): """Counts, not ids. The allowlist around this call exists to stop the rollup handing out pointers or sequences, and a count is neither.""" src = open("dee/server.py", encoding="utf-8").read() block = src[src.index('raw.append({"kind": "construct"'):] block = block[:block.index("})") + 2]
for key in ("n_plasmids", "n_crispr", "n_primers"): assert key in block, f"{key} never reaches the card" assert "plasmid_ids" in block and "crispr_ids" in block and "primer_ids" in block # The ids themselves must not be serialized. assert '"plasmid_ids":' not in block assert '"crispr_ids":' not in block
def test_the_card_renders_those_counts(): js = app_js() assert "c.n_plasmids" in js and "c.n_crispr" in js and "c.n_primers" in js assert "Guide set" in js and "Primer set" in js
def test_an_empty_project_says_what_goes_in_it(): """Three zeroes tell a new user nothing they can act on, and leaving the strip out entirely is what made the card hollow in the first place.""" js = app_js() assert "mc-cx-stats--empty" in js assert "Nothing filed yet" in js assert ".mc-cx-stats--empty" in _static("app.css")
# ββ 2. the menu is a sibling, not a nested button βββββββββββββββββββββββββββdef test_the_menu_button_is_not_inside_the_card_button(): """`.mc-cx` IS a <button>. A <button> inside it is invalid HTML and drops the inner control out of the keyboard order, so the β― is a sibling and the wrapper is the grid item.""" js = app_js() i_wrap = js.index('<div class="mc-cx-wrap">') frag = js[i_wrap:i_wrap + 400] assert "menu +" in frag, "the menu must be emitted before the card button" assert frag.index("menu +") < frag.index('<button class="mc-cx'), ( "the β― has to come out ahead of the card, not inside it") assert ".mc-cx-wrap" in _static("app.css")
def test_only_a_construct_gets_the_menu(): """Libraries have no rename or delete endpoint, so offering the menu on one would be a button that cannot work.""" js = app_js() # `const menu` also names the download menu earlier in app.js, so anchor # on the one that builds the card's β―. i = js.index("const menu = c.kind") assert "c.kind === 'construct'" in js[i:i + 60]
def test_the_pager_hides_the_grid_item_not_the_card_inside_it(): """The wrapper is what the grid lays out. Hiding the card within it would leave an empty cell, so a paged-out or searched-out project would show as a gap rather than disappear.""" js = app_js() i = js.index("function _mcCards()") body = js[i:i + 400] assert ".closest('.mc-cx-wrap')" in body, ( "_mcCards must step out to the wrapper before the pager hides it") assert ".mc-cx-wrap[hidden]" in _static("app.css")
# ββ 3. the two actions call the endpoints that already existed ββββββββββββββdef test_rename_patches_the_construct(): js = app_js() i = js.index("async function cxRename") body = js[i:i + 1200] assert "'/api/constructs/'" in body assert "'PATCH'" in body assert "JSON.stringify({ name: next })" in body assert "load(true)" in body, "the grid has to redraw or the old name stays"
def test_delete_deletes_and_is_confirmed_first(): js = app_js() i = js.index("async function cxDelete") body = js[i:i + 1400] assert "cxDialog(" in body assert "danger: true" in body assert "Delete forever" in body
def test_a_dismissed_dialog_stops_the_request_reaching_the_server(): """The guard, not the ordering.
An earlier version of this test only checked that cxDialog appeared above the fetch in the source, which stays true when the early return is deleted β and that mutation is a delete that fires whether or not anybody confirmed it, which is the worst thing in this change. What has to hold is that the dialog's ANSWER gates the request. """ js = app_js() for fn, guard in (("cxDelete", "if (!go) return;"), ("cxRename", "if (!next || next === name) return;")): i = js.index("async function " + fn) body = js[i:i + 1600] assert guard in body, f"{fn} does not act on what the dialog returned" assert body.index("await cxDialog") < body.index(guard) < body.index("await fetch"), ( f"{fn} must ask, then check the answer, then call the server")
def test_the_delete_copy_is_accurate_about_what_survives(): """auth.delete_construct removes the grouping and deliberately leaves the artifacts alone β deleting a project must never destroy a plasmid the user still has open in another tab. A warning that overstates what it destroys trains people to ignore the next one, so the dialog says both halves.""" js = app_js() i = js.index("async function cxDelete") body = js[i:i + 1400] assert "permanently deletes the project" in body assert "cannot be undone" in body assert "are kept" in body, "it must say the plasmids and libraries survive"
auth = open("dee/auth.py", encoding="utf-8").read() j = auth.index("def delete_construct") assert "artifacts it referenced are NOT touched" in auth[j:j + 500], ( "the dialog's promise is only true while this stays true")
def test_both_endpoints_exist_and_require_a_signed_in_user(): src = open("dee/server.py", encoding="utf-8").read() for verb, name in (("patch", "constructs_patch"), ("delete", "constructs_delete")): i = src.index(f'@app.{verb}("/api/constructs/<construct_id>")') body = src[i:i + 700] assert f"def {name}" in body assert "auth.anonymous" in body and "signin_required" in body
# ββ 4. the rail is gone βββββββββββββββββββββββββββββββββββββββββββββββββββββdef test_the_run_feed_no_longer_draws_a_spine_or_a_node(): css = _static("workbench.css") assert "var(--tl-node)" not in css, "nothing may still read the node column" assert not re.search(r"^\s*--tl-node\s*:", css, re.M), ( "the node column variable is still declared") assert "#mcResume .mc-recent-node { display: none; }" in css # The spine was a ::before on every non-featured entry. assert not re.search(r"#mcResume \.mc-recent:not\(\.mc-recent--featured\)::before\s*\{", css) assert "var(--tl-date) minmax(0, 1fr) auto" in css, ( "three columns now: date, body, state")
def test_the_hover_signal_survived_the_node_going_away(): """The node lighting amber was half the hover feedback. With it gone the underline on the title has to carry it alone.""" css = _static("workbench.css") i = css.index("#mcResume .mc-recent:hover .mc-recent-nm") assert "var(--amber)" in css[i:i + 240]178 unmodified lines179180181182183184185186187188189190191192193194195178 unmodified linesf"{sel}: amber fill without --amber-ink text")def test_the_log_hangs_off_one_spine():spine = _rule("#mcResume .mc-recent:not(.mc-recent--featured)::before")assert "var(--line-strong)" in spine and "width: 1px" in spineassert "#mcResume .mc-recent:not(.mc-recent--featured):last-child::before" in _section_css(), ("the spine runs on past the last entry")def test_the_pointer_lights_the_node_not_the_row():"""A log entry is a line, not a card: it does not fill or lift. The nodetakes the sidebar's amber and the title an amber underline."""assert "var(--amber)" in _rule("#mcResume .mc-recent:hover .mc-recent-node")assert "text-decoration-color: var(--amber)" in _rule("#mcResume .mc-recent:hover .mc-recent-nm")hover = _rule("#mcResume .mc-recent:hover")assert "transform: none" in hover and "box-shadow: none" in hover178 unmodified lines179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209178 unmodified linesf"{sel}: amber fill without --amber-ink text")def test_the_log_hangs_off_nothing():"""The spine and its node are GONE, by request (2026-12-01).This test used to assert the opposite β a 1px --line-strong rule drawnper entry, stopping at the last node. The feed was reviewed and the railread as furniture: the dates already carry the sequence, and the columnit needed pushed every title 46px right for a circle. Inverted ratherthan deleted, so the next person to look at this file learns the rail wasremoved on purpose instead of re-adding it.tests/test_a_project_can_be_renamed_and_deleted.py has the full guard,including that nothing still reads --tl-node."""css = _section_css()assert "#mcResume .mc-recent:not(.mc-recent--featured)::before" not in cssassert "#mcResume .mc-recent-node { display: none; }" in cssdef test_the_pointer_still_marks_the_row_without_filling_it():"""A log entry is a line, not a card: it does not fill or lift.The node lighting amber used to be half of that signal and is gone withthe rail, so the title's amber underline now carries it alone β which iswhy this still has to be asserted rather than assumed."""assert "text-decoration-color: var(--amber)" in _rule("#mcResume .mc-recent:hover .mc-recent-nm")hover = _rule("#mcResume .mc-recent:hover")assert "transform: none" in hover and "box-shadow: none" in hover
dee/server.py+10
dee/static/app.css+67
dee/static/app.js+213-5
dee/static/workbench.css+16-32
tests/test_a_project_can_be_renamed_and_deleted.pyAdded+191
tests/test_research_notebook.py+23-9