Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

feat(view): the project list collapses into the tab bar [N26]

Corey Olsonb3b27be43646
diff --git a/src/cockpit.js b/src/cockpit.js
index b05f9ed0..4ae507db 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -57,7 +57,7 @@ export function cockpitPage(key = '', { snapshot = false, readOnly = false, requ
<div class="shell">
<aside class="side" id="side" aria-label="Projects">
<div class="side-top">
- <div class="brand"><svg viewBox="0 0 64 64" aria-hidden="true"><path fill="currentColor" d="M8 7h35a6 6 0 0 1 6 6v7H8a5 5 0 0 1-5-5v-3a5 5 0 0 1 5-5Z"/><rect width="56" height="14" x="3" y="25" fill="var(--accent)" rx="5"/><path fill="currentColor" d="M8 43h35a6 6 0 0 1 6 6v8H8a5 5 0 0 1-5-5v-4a5 5 0 0 1 5-5Z"/></svg><span>Pullboard</span></div>
+ <button class="brand" id="side-toggle" type="button" aria-pressed="false" aria-controls="side-body" aria-label="Collapse the project list" title="Collapse the project list"><svg viewBox="0 0 64 64" aria-hidden="true"><path fill="currentColor" d="M8 7h35a6 6 0 0 1 6 6v7H8a5 5 0 0 1-5-5v-3a5 5 0 0 1 5-5Z"/><rect width="56" height="14" x="3" y="25" fill="var(--accent)" rx="5"/><path fill="currentColor" d="M8 43h35a6 6 0 0 1 6 6v8H8a5 5 0 0 1-5-5v-4a5 5 0 0 1 5-5Z"/></svg><span>Pullboard</span></button>
<button class="switch-btn" id="proj-switch" type="button" aria-expanded="false" aria-controls="side-body"><span id="proj-name">Projects</span><b class="need" id="proj-elsewhere" title="Needs you in other projects" hidden></b><small>▾</small></button>
<button class="theme-btn" id="theme" type="button" title="Theme: system"><svg class="sys" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.5"/><path fill="currentColor" d="M8 2a6 6 0 0 1 0 12Z"/></svg><svg class="sun" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="3" fill="none" stroke="currentColor" stroke-width="1.5"/><path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" d="M8 1.5v1.2M8 13.3v1.2M1.5 8h1.2M13.3 8h1.2M3.4 3.4l.85.85M11.75 11.75l.85.85M3.4 12.6l.85-.85M11.75 4.25l.85-.85"/></svg><svg class="moon" viewBox="0 0 16 16" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round" d="M13.6 9.6A6 6 0 1 1 6.4 2.4a5.2 5.2 0 0 0 7.2 7.2Z"/></svg></button>
</div>
@@ -190,6 +190,15 @@ function theme(pick) {
$('theme').title = 'Theme: ' + (document.documentElement.dataset.theme || 'system');
}
theme(keep('pb.theme'));
+/** Collapse the sidebar into the tab bar on a wide screen, or bring it back, as the person last chose. */
+function collapseSide(collapsed) {
+ if (collapsed) document.documentElement.dataset.side = 'collapsed';
+ else delete document.documentElement.dataset.side;
+ $('side-toggle').setAttribute('aria-pressed', String(collapsed));
+ $('side-toggle').title = collapsed ? 'Show the project list' : 'Collapse the project list';
+ $('side-toggle').setAttribute('aria-label', $('side-toggle').title);
+}
+collapseSide(keep('pb.side') === 'collapsed');
const esc = (text) => String(text ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
const ago = (iso) => { const m = Math.round((Date.now() - Date.parse(iso)) / 60000); return m < 1 ? 'now' : m < 60 ? m + 'm' : m < 2880 ? Math.round(m / 60) + 'h' : Math.round(m / 1440) + 'd'; };
// An age as the page shows it: the moment it counts from stays on it, so tickAges can move it on.
@@ -1516,6 +1525,14 @@ $('flow-show').addEventListener('click', () => showFlow(true));
$('flow-panel').hidden = keep('pb.flow') === 'hidden';
$('flow-show').hidden = !$('flow-panel').hidden;
// Each press moves on one, from the system's theme to light, then dark, and back; this browser keeps it.
+$('side-toggle').addEventListener('click', () => {
+ // A phone always shows the switcher, so there the logo is only the logo.
+ if (!matchMedia('(width > 900px)').matches) return;
+ const collapsed = !document.documentElement.dataset.side;
+ collapseSide(collapsed);
+ fold(false);
+ keep('pb.side', collapsed ? 'collapsed' : 'open');
+});
$('theme').addEventListener('click', () => {
const next = { light: 'dark', dark: 'system' }[document.documentElement.dataset.theme] || 'light';
keep('pb.theme', next);
diff --git a/src/view.css b/src/view.css
index 0ad59721..2ca9324d 100644
--- a/src/view.css
+++ b/src/view.css
@@ -27,7 +27,8 @@ button, input, select, textarea { font: inherit; color: inherit; }
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 0 10px 16px; background: var(--surface); border-right: 1px solid var(--line); }
.side-top { display: flex; align-items: center; gap: 10px; height: var(--top); margin: 0 -10px 6px; padding: 0 16px; border-bottom: 1px solid var(--line); }
-.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; white-space: nowrap; }
+.brand { display: flex; align-items: center; gap: 8px; margin-left: -6px; padding: 0 6px; border: 0; border-radius: 8px; background: none; font-weight: 700; font-size: 15px; white-space: nowrap; cursor: pointer; }
+.brand:hover { background: var(--surface-2); }
.brand svg { width: 22px; height: 22px; flex: none; }
.switch-btn { display: none; align-items: center; gap: 8px; min-width: 0; border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-weight: 600; }
.switch-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@@ -37,6 +38,25 @@ button, input, select, textarea { font: inherit; color: inherit; }
.theme-btn svg { display: none; width: 16px; height: 16px; }
:root:not([data-theme]) .theme-btn .sys, :root[data-theme="light"] .theme-btn .sun, :root[data-theme="dark"] .theme-btn .moon { display: block; }
.side-body { display: grid; gap: 2px; align-content: start; }
+/* Collapsed, as the person chose: the sidebar shrinks to the project switcher at the left of the tab bar,
+ * the board below takes the whole width, and the project list opens as a dropdown. The logo collapses and
+ * restores it; phones always show the switcher, so there the logo is only the logo. The theme button sits at the
+ * right end of the tab bar on a wide screen, sidebar or not. */
+@media (width > 900px) {
+ .theme-btn { position: fixed; top: 6px; right: 10px; z-index: 12; }
+ header.top { padding-right: 62px; }
+ :root[data-side="collapsed"] .shell { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto 1fr; }
+ :root[data-side="collapsed"] .body { display: contents; }
+ :root[data-side="collapsed"] .side { grid-area: 1 / 1; z-index: 11; height: var(--top); overflow: visible; padding: 0 6px; border-right: 0; border-bottom: 1px solid var(--line); }
+ :root[data-side="collapsed"] .top { grid-area: 1 / 2; }
+ :root[data-side="collapsed"] main { grid-area: 2 / 1 / 3 / 3; }
+ :root[data-side="collapsed"] .side-top { margin: 0; padding: 0; gap: 6px; border: 0; }
+ :root[data-side="collapsed"] .brand span { display: none; }
+ :root[data-side="collapsed"] .brand { justify-content: center; width: 44px; height: 44px; margin: 0; padding: 0; }
+ :root[data-side="collapsed"] .switch-btn { display: flex; max-width: 16rem; }
+ :root[data-side="collapsed"] .side-body { display: none; }
+ :root[data-side="collapsed"] .side.open .side-body { display: grid; position: absolute; top: calc(var(--top) + 4px); left: 8px; width: 300px; max-height: calc(100vh - var(--top) - 16px); overflow-y: auto; padding: 8px 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
+}
.label { font: 600 11px/1 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); padding: 8px 8px 6px; }
.proj { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 8px; align-items: center; width: 100%; text-align: left; border: 1px solid transparent; background: none; border-radius: 8px; padding: 7px 8px; cursor: pointer; }
.proj:hover { background: var(--surface-2); }
@@ -111,6 +131,8 @@ main { padding: 16px 18px 28px; }
.side-top { height: auto; margin: 0; padding: 0; border: 0; }
.brand span { display: none; }
.switch-btn { display: flex; }
+ .brand { cursor: default; }
+ .brand:hover { background: none; }
.side-body { display: none; padding-top: 6px; }
.side.open .side-body { display: grid; }
.top { padding: 0 6px; }
diff --git a/test/cockpit.test.js b/test/cockpit.test.js
index 1f36b12a..e46c7257 100644
--- a/test/cockpit.test.js
+++ b/test/cockpit.test.js
@@ -608,6 +608,80 @@ test('projects group repos with combined needs and activity, while ungrouped and
}
});
+test('the project list collapses into the tab bar and stays collapsed [N26]', { timeout: 90_000 }, async (t) => {
+ const executable = chromeExecutable();
+ if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for sidebar checks.');
+
+ const box = machine();
+ const demo = project(box, 'collapse-demo');
+ const other = project(box, 'collapse-other');
+ box.run(demo.repo, 'add', 'web', 'An item to show', '--specs', 'G1', '--criterion', 'shown');
+ const view = await startView(box);
+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-collapse-chrome-'));
+ let chrome;
+ /** Read the sidebar, the tab bar and the board's columns as the person sees them. */
+ const read = async () => JSON.parse(await chrome.evaluate(`JSON.stringify((() => {
+ const box = (s) => { const e = document.querySelector(s); const r = e.getBoundingClientRect(); return { left: r.left, top: r.top, right: r.right, bottom: r.bottom, width: r.width, height: r.height, shown: getComputedStyle(e).display !== 'none' && r.width > 0 }; };
+ const logo = document.querySelector('#side-toggle');
+ return { width: innerWidth, logo: box('#side-toggle'), side: box('.side'), top: box('.top'), main: box('main'), switcher: box('#proj-switch'), list: box('#side-body'), theme: box('#theme'), live: box('#live'),
+ columns: box('.two > :first-child').width + box('#detail').width, collapsed: document.documentElement.dataset.side || '', pressed: logo.getAttribute('aria-pressed'), title: logo.title,
+ listPosition: getComputedStyle(document.querySelector('#side-body')).position, overflow: document.documentElement.scrollWidth > document.documentElement.clientWidth };
+ })())`));
+ try {
+ chrome = await openSnapshotChrome(executable, view.link.href, profile);
+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false });
+ await chrome.waitFor('innerWidth === 1280 && !!document.querySelector("#chain .row") && !!document.querySelector("#detail h2")');
+ const open = await read();
+ assert.ok(open.side.width >= 200 && open.side.height >= 800 && !open.collapsed && open.pressed === 'false', `the sidebar starts open: ${JSON.stringify(open)}`);
+ assert.ok(open.theme.right >= open.width - 16 && open.theme.top < open.top.bottom && open.live.right <= open.theme.left, `the light/dark button sits at the right end of the tab bar, clear of the live status: ${JSON.stringify(open)}`);
+
+ await chrome.evaluate('document.querySelector("#side-toggle").click()');
+ await chrome.waitFor('document.documentElement.dataset.side === "collapsed"');
+ const collapsed = await read();
+ assert.deepEqual([collapsed.pressed, collapsed.title], ['true', 'Show the project list'], 'the logo says it brings the list back');
+ assert.ok(collapsed.side.height <= collapsed.top.height + 0.5 && collapsed.switcher.shown && Math.abs(collapsed.switcher.top - collapsed.top.top) < collapsed.top.height && collapsed.switcher.right <= collapsed.top.left + 0.5,
+ `the sidebar is one switcher at the left of the tab bar, in its row: ${JSON.stringify(collapsed)}`);
+ assert.ok(!collapsed.list.shown, 'the project list folds away until asked for');
+ assert.ok(Math.abs(collapsed.logo.width - collapsed.logo.height) < 1 && collapsed.logo.height >= 44, `the logo alone is a square control, so its hover is a square: ${JSON.stringify(collapsed.logo)}`);
+ assert.ok(collapsed.main.left <= 0.5 && collapsed.main.width >= collapsed.width - 0.5 && collapsed.columns >= open.columns + 200 && !collapsed.overflow,
+ `the board takes the whole width: the list and detail gain at least 200px: ${JSON.stringify({ open: open.columns, collapsed: collapsed.columns, main: collapsed.main })}`);
+ assert.ok(collapsed.theme.right >= collapsed.width - 16 && collapsed.live.right <= collapsed.theme.left, 'the light/dark button stays at the right end');
+
+ await chrome.evaluate('document.querySelector("#proj-switch").click()');
+ const dropdown = await read();
+ assert.ok(dropdown.list.shown && dropdown.listPosition === 'absolute' && dropdown.list.top >= dropdown.top.bottom - 0.5 && dropdown.list.right <= dropdown.width, `the switcher opens the project list as a dropdown: ${JSON.stringify(dropdown.list)}`);
+ await chrome.evaluate('document.querySelector("main").click()');
+ assert.equal((await read()).list.shown, false, 'a click outside closes it');
+ await chrome.evaluate('document.querySelector("#proj-switch").click()');
+ await chrome.evaluate(`document.querySelector('#proj-list [data-root="${other.repo}"]').click()`);
+ await chrome.waitFor(`document.querySelector('#proj-name').textContent === 'collapse-other'`);
+ assert.equal((await read()).list.shown, false, 'a pick closes it and shows that project');
+
+ await chrome.send('Page.reload');
+ await chrome.waitFor('document.readyState === "complete" && !!document.querySelector("#proj-switch")');
+ assert.equal((await read()).collapsed, 'collapsed', 'the choice is kept in this browser across a reload');
+
+ await chrome.evaluate('document.querySelector("#side-toggle").click()');
+ await chrome.waitFor('!document.documentElement.dataset.side');
+ const back = await read();
+ assert.ok(back.side.width >= 200 && back.list.shown && back.pressed === 'false' && back.title === 'Collapse the project list', `the logo brings the sidebar back as it was: ${JSON.stringify(back)}`);
+
+ await chrome.evaluate('document.querySelector("#side-toggle").click()');
+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 375, height: 900, deviceScaleFactor: 1, mobile: false });
+ await chrome.waitFor('innerWidth === 375');
+ const phone = await read();
+ await chrome.evaluate('document.querySelector("#side-toggle").click()');
+ const tapped = await read();
+ assert.ok(phone.switcher.shown && !phone.list.shown && phone.theme.right >= phone.width - 16 && phone.theme.top < phone.side.bottom, `a phone keeps its switcher, the light/dark button at the right of its top row: ${JSON.stringify(phone)}`);
+ assert.equal(tapped.collapsed, phone.collapsed, 'on a phone the logo is only the logo');
+ assert.ok(!phone.overflow, 'and nothing runs off the phone');
+ } finally {
+ if (chrome) await closeSnapshotChrome(chrome);
+ rmSync(profile, { recursive: true, force: true });
+ await view.stop();
+ }
+});
+
test('the tabs fit one row on a phone [N26]', async () => {
const view = await startView(machine());
try {