Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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.",
Expand Down
36 changes: 36 additions & 0 deletions src/e2e/cov-forge-project.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('<h1>Shop</h1>')
await page.screenshot({ path: info.outputPath(`phone-${width}.png`) })
})
}
})

test.describe('a repository’s workspace', () => {
Expand Down
46 changes: 32 additions & 14 deletions src/project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -814,6 +814,29 @@ export function Project({ at }: { at: Where }) {
</YStack>
)

const views = (
<Views
views={[CHAT, ...VIEWS]}
value={pane === 'chat' && !wide ? 'chat' : view}
onChange={(v) => {
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 : (
<XStack data-slot="views-row" justify="center" px="$3" pb="$2" shrink={0}>
{views}
</XStack>
)

return (
<>
<Workspace
Expand Down Expand Up @@ -848,18 +871,7 @@ export function Project({ at }: { at: Where }) {
</XStack>
</XStack>
}
middle={
<Views
views={[CHAT, ...VIEWS]}
value={pane === 'chat' && !wide ? 'chat' : view}
onChange={(v) => {
if (v === 'chat') return setPane('chat')
setView(v as ViewId)
setPane('view')
}}
label={t('View')}
/>
}
middle={wide ? views : undefined}
end={
<XStack items="center" gap="$2">
{/* Share gives way on a phone, where Publish is the one that matters. */}
Expand All @@ -883,7 +895,12 @@ export function Project({ at }: { at: Where }) {
</Button>
</XStack>
}
chat={chat}
chat={
<>
{row}
{chat}
</>
}
dock={
<Console
lines={lines}
Expand All @@ -899,6 +916,7 @@ export function Project({ at }: { at: Where }) {
width={across}
onLayout={(e) => setRoom(e.nativeEvent.layout.width)}
>
{row}
{preview}
{body}
</Workspace>
Expand Down
Loading