diff --git a/package.json b/package.json index c899bd9..7f15e30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hanzo/build", - "version": "0.2.129", + "version": "0.2.130", "type": "module", "license": "Apache-2.0 OR MIT", "description": "Hanzo Build — say what you want, watch it built, deployed and running. The builder as a component, mounted by the Hanzo app at hanzo.ai.", diff --git a/src/e2e/cov-forge-project.spec.ts b/src/e2e/cov-forge-project.spec.ts index d8eab16..c0ac98a 100644 --- a/src/e2e/cov-forge-project.spec.ts +++ b/src/e2e/cov-forge-project.spec.ts @@ -563,6 +563,42 @@ test.describe('the workspace', () => { await page.getByRole('tab', { name: 'Chat' }).click() await expect(box(page)).toBeVisible() }) + + // hanzo-inc/app#305: at 375 beside a project named "Instrument" the views were + // a 49px scroller in the bar, part of Chat and none of Code in sight. + for (const width of [360, 375, 390]) { + test(`on a phone ${width} wide every view is whole on screen beside a long project name, and Code opens a file`, async ({ page }, info) => { + await page.setViewportSize({ width, height: 844 }) + const projects = PROJECTS().map((p) => (p.slug === 'shop' ? { ...p, name: 'Instrument Portfolio Studio' } : p)) + await studio(page, { projects }) + await page.goto('/shop') + await expect(box(page)).toBeVisible() + const tabs = page.getByRole('tablist', { name: 'View' }) + await expect(tabs).toHaveCount(1) + const whole = await tabs.evaluate((list) => + [...list.querySelectorAll('[role="tab"]')].map((el) => { + const b = el.getBoundingClientRect() + // What is drawn at the tab's middle is the tab, not something over it. + const top = document.elementFromPoint(b.left + b.width / 2, b.top + b.height / 2) + return { name: el.getAttribute('aria-label'), l: b.left, r: b.right, on: Boolean(top && el.contains(top)) } + }), + ) + expect(whole.map((w) => w.name)).toEqual(['Chat', 'Preview', 'Files', 'Code', 'Layers']) + for (const w of whole) { + expect(w.l, `${w.name} starts on screen`).toBeGreaterThanOrEqual(0) + expect(w.r, `${w.name} ends on screen`).toBeLessThanOrEqual(width) + expect(w.on, `${w.name} is not covered`).toBe(true) + } + await expect(page.getByRole('button', { name: 'Publish' })).toBeVisible() + expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBe(width) + + await page.getByRole('tab', { name: 'Files' }).click() + await page.getByLabel('shop at agent/cart').getByText('index.html').click() + await expect(page.getByRole('tab', { name: 'Code' })).toHaveAttribute('aria-selected', 'true') + await expect(page.getByRole('tabpanel', { name: 'index.html' })).toContainText('

Shop

') + await page.screenshot({ path: info.outputPath(`phone-${width}.png`) }) + }) + } }) test.describe('a repository’s workspace', () => { diff --git a/src/project.tsx b/src/project.tsx index 576fb2f..81af59a 100644 --- a/src/project.tsx +++ b/src/project.tsx @@ -8,7 +8,7 @@ * opened by its slug (Artifacts), and works the same way. * * bar mark · project · history · chat toggle | Preview Files Code Layers | - * Share · Publish + * Share · Publish; on a phone the views (with Chat) are a row under it * left the project's runs as a conversation, suggestions, and the ask * right the deployed page, framed under its own bar (reload · page · device * · open), and kept loaded while another view is open; the repository @@ -814,6 +814,29 @@ export function Project({ at }: { at: Where }) { ) + const views = ( + { + if (v === 'chat') return setPane('chat') + setView(v as ViewId) + setPane('view') + }} + label={t('View')} + /> + ) + // On a phone the bar has no room for the views beside the project: there + // they were a scroller of the bar's leftovers, 49px at 375 beside a project + // named "Instrument", showing part of Chat and none of Code (hanzo-inc/app#305). + // So below md they take a row of their own under the bar, in whichever pane + // shows (one pane at a time there, so one row). + const row = wide ? null : ( + + {views} + + ) + return ( <> } - middle={ - { - if (v === 'chat') return setPane('chat') - setView(v as ViewId) - setPane('view') - }} - label={t('View')} - /> - } + middle={wide ? views : undefined} end={ {/* Share gives way on a phone, where Publish is the one that matters. */} @@ -883,7 +895,12 @@ export function Project({ at }: { at: Where }) { } - chat={chat} + chat={ + <> + {row} + {chat} + + } dock={ setRoom(e.nativeEvent.layout.width)} > + {row} {preview} {body}