Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(character): a narrow window keeps the character's head, and the line about Local and Cloud is back

purple433407d59e30
diff --git a/e2e/character-hub.spec.ts b/e2e/character-hub.spec.ts
index 8c2b5835..6dd0a118 100644
--- a/e2e/character-hub.spec.ts
+++ b/e2e/character-hub.spec.ts
@@ -374,7 +374,7 @@ test('the training is a page of the area, with the way back to the stage', async
await expect(characterPill(page)).toHaveAttribute('aria-checked', 'true')
})
-test('phone width: the same stage without the left column, the bar in its short form', async ({ page }) => {
+test('phone width: the same stage, the character as a head over it, the bar in its short form', async ({ page }) => {
await boot(page, { hub: true, width: 375, height: 812 })
await openCharacterHub(page)
await shoot(page, 'handy-a-wer')
@@ -427,4 +427,36 @@ test('no character yet: the three steps, one button, four examples and nothing e
await page.locator('[data-hub-rename-save]').click()
await expect(page.locator('[data-hub-card-name]')).toHaveText('Greta')
await expect(page.locator('[data-hub-character^="saved:"]')).toContainText('Greta')
+ // A narrow window: the character stands as a head over its photos, with
+ // everything it can do. Nothing is missing at any width.
+ for (const width of [700, 520, 380]) {
+ await page.setViewportSize({ width, height: 800 })
+ const card = page.locator('[data-hub-card]')
+ await expect(card).toBeVisible()
+ await expect(page.locator('[data-hub-card-name]')).toBeVisible()
+ for (const sel of ['[data-hub-rename]', '[data-hub-train]', '[data-hub-delete]']) await expect(page.locator(sel)).toBeVisible()
+ const head = (await card.boundingBox())!
+ const photos = (await page.locator('.hub-photos').boundingBox())!
+ expect(head.y + head.height).toBeLessThanOrEqual(photos.y + 1)
+ expect(head.x + head.width).toBeLessThanOrEqual(width)
+ // Not cut off: the name and the links lie inside the head, below one another.
+ const name = (await page.locator('[data-hub-card-name]').boundingBox())!
+ const links = (await page.locator('[data-hub-card-links]').boundingBox())!
+ expect(name.y).toBeGreaterThanOrEqual(head.y)
+ expect(name.height).toBeGreaterThan(15)
+ expect(links.y).toBeGreaterThanOrEqual(name.y + name.height)
+ expect(links.y + links.height).toBeLessThanOrEqual(head.y + head.height + 1)
+ }
+ await shoot(page, 'schmal-kopf')
+ await page.locator('[data-hub-rename]').click()
+ await page.getByRole('textbox', { name: 'New name for Greta' }).fill('Oma')
+ await page.locator('[data-hub-rename-save]').click()
+ await expect(page.locator('[data-hub-card-name]')).toHaveText('Oma')
+ // The line about Local and Cloud stands where the picked action shows its price.
+ await page.setViewportSize({ width: 1280, height: 800 })
+ await expect(page.locator('[data-hub-local-line]')).toHaveCount(0)
+ await page.locator('[data-hub-action="motion"]').click()
+ await expect(page.locator('[data-hub-local-line]')).toHaveText('Local runs on your own machine and costs nothing. Cloud prices in credits.')
+ await page.setViewportSize({ width: 380, height: 800 })
+ await expect(page.locator('[data-hub-local-line]')).toBeVisible()
})
diff --git a/src/components/create/experimental/__tests__/character-stage.test.tsx b/src/components/create/experimental/__tests__/character-stage.test.tsx
index 644200fe..fcf72c66 100644
--- a/src/components/create/experimental/__tests__/character-stage.test.tsx
+++ b/src/components/create/experimental/__tests__/character-stage.test.tsx
@@ -27,11 +27,11 @@ vi.mock('../SpecialIntentControls', () => ({ CharacterMore: () => <span data-tes
import { HubEmpty } from '../hub/HubEmpty'
import { HubNewCharacter } from '../hub/HubNewCharacter'
-import { HubCard, HubPhotos } from '../hub/HubStage'
+import { HubActions, HubCard, HubPhotos, type HubActionState } from '../hub/HubStage'
import { useCreateStore } from '../../../../stores/createStore'
import { useCharacterNames } from '../../../../lib/create/character-names'
import { __resetSavedCharacters, listSavedCharacters, saveCharacter } from '../../../../lib/saved-characters'
-import { hubFromSaved, type HubCharacter } from '../../../../lib/create/character-hub'
+import { HUB_LOCAL_LINE, hubFromSaved, type HubCharacter } from '../../../../lib/create/character-hub'
const png = (name: string) => new File([`png-${name}`], name, { type: 'image/png' })
const hub = (ui: React.ReactElement) => render(<div className="lu-hub">{ui}</div>)
@@ -180,6 +180,49 @@ describe('the stage', () => {
})
})
+describe('nothing is lost', () => {
+ it('a narrow window keeps the character and all it can do: as a head over the photos, never hidden', () => {
+ const css = readFileSync(resolve(__dirname, '../../../../index.css'), 'utf8')
+ const from = css.indexOf('@media (max-width: 700px) {\n .lu-hub .hub-stage')
+ expect(from).toBeGreaterThan(0)
+ const narrow = css.slice(from, css.indexOf('\n}', from))
+ // The card is laid out, not taken away, and nothing in it but the file
+ // actions (which stand under More options there) is switched off.
+ expect(narrow).toMatch(/\.lu-hub \.hub-card \{[^}]*overflow: visible/)
+ expect(narrow).toMatch(/\.hub-portrait \{[^}]*width: 56px/)
+ const off = [...narrow.matchAll(/([^{}\n]+)\{[^}]*display: none/g)].map((m) => m[1].trim())
+ expect(off).toEqual(['.lu-hub .hub-card .hub-card-file'])
+ // Head above the photos, the photos above the bar.
+ expect(narrow).toMatch(/\.hub-card \{[^}]*grid-row: 2/)
+ expect(narrow).toMatch(/\.hub-body \{[^}]*grid-row: 3/)
+ expect(narrow).toMatch(/\.hub-foot \{[^}]*grid-row: 4/)
+ // Rename, Train a model and Delete are plain children of the card.
+ const c: HubCharacter = { key: 'saved:1', kind: 'saved', name: 'Oma', meta: 'Photos · 2', image: null, photos: [new Blob(['a']), new Blob(['b'])] }
+ const { container } = hub(<HubCard c={c} photo={null} />)
+ const links = container.querySelector('.hub-card [data-hub-card-links]')!
+ for (const sel of ['[data-hub-rename]', '[data-hub-train]', '[data-hub-delete]']) expect(links.querySelector(sel)).not.toBeNull()
+ expect(links.closest('.hub-card-file')).toBeNull()
+ })
+
+ it('says once what the price of the picked action means, and only then', () => {
+ const actions: HubActionState[] = [
+ { action: 'image', label: 'Character', locked: false, meta: 'Local · free' },
+ { action: 'swap', label: 'Swap Character', locked: true, meta: 'Runs on LU Cloud' },
+ ]
+ const idle = hub(<HubActions actions={actions} active={null} name="Oma" onPick={() => {}} />)
+ expect(idle.container.querySelector('[data-hub-local-line]')).toBeNull()
+ cleanup()
+ const picked = hub(<HubActions actions={actions} active="image" name="Oma" onPick={() => {}} />)
+ const line = picked.container.querySelectorAll('[data-hub-local-line]')
+ expect(line).toHaveLength(1)
+ expect(line[0].textContent).toBe(HUB_LOCAL_LINE)
+ expect(HUB_LOCAL_LINE).toBe('Local runs on your own machine and costs nothing. Cloud prices in credits.')
+ // The line is not one of those that step aside on a narrow window.
+ expect(line[0].className).not.toMatch(/hidden/)
+ expect(picked.container.querySelector('[data-hub-action-meta]')!.textContent).toBe('Local · free')
+ })
+})
+
describe('nothing moves by itself', () => {
it('only the four examples of the first page are animated, and they stand still with reduced motion', () => {
const css = readFileSync(resolve(__dirname, '../../../../index.css'), 'utf8')
diff --git a/src/components/create/experimental/hub/HubStage.tsx b/src/components/create/experimental/hub/HubStage.tsx
index b7d36675..295b752b 100644
--- a/src/components/create/experimental/hub/HubStage.tsx
+++ b/src/components/create/experimental/hub/HubStage.tsx
@@ -10,7 +10,7 @@ import { useEffect, useRef, useState, type ReactNode } from 'react'
import { Image as ImageIcon, ImagePlus, Mic, PersonStanding, Plus, Replace } from 'lucide-react'
import { useCreateStore } from '../../../../stores/createStore'
import {
- ACTION_LABEL, ACTION_LINE, HUB_JUST_PHOTO, HUB_JUST_PHOTO_LINE, hubInitial,
+ ACTION_LABEL, ACTION_LINE, HUB_JUST_PHOTO, HUB_JUST_PHOTO_LINE, HUB_LOCAL_LINE, hubInitial,
type HubAction, type HubCharacter,
} from '../../../../lib/create/character-hub'
import { useCharacterNames, cleanCharacterName, MAX_CHARACTER_LABEL } from '../../../../lib/create/character-names'
@@ -157,7 +157,7 @@ function Card({ c, photo }: { c: HubCharacter | null; photo: string | null }) {
)}
</div>
{/* The file of a LoRA character: download, use on this computer, delete. */}
- {!saved && <div className="-ml-1 mt-1.5"><CharacterMore bare /></div>}
+ {!saved && <div className="hub-card-file -ml-1 mt-1.5"><CharacterMore bare /></div>}
{error && <p role="alert" className="mt-1.5 text-red-500 hub-fs-125 dark:text-red-400">{error}</p>}
{c.kind === 'local' && (
<p className="hub-dim hub-line mt-4 border-t pt-3 hub-fs-125">In Chat, name it: “a picture of {c.ref?.name ?? c.name} at the beach”.</p>
@@ -265,7 +265,8 @@ export function HubActions({ actions, active, name, onPick, right }: {
? ACTION_LINE[on.action].replace('your character', name ?? 'your character').replace('Your character', name ?? 'Your character')
: name ? `What should ${name} do?` : 'What should your character do?'
return (
- <div className="flex min-h-[42px] items-center gap-3 py-1 pl-1.5 pr-3" data-hub-actions>
+ <div data-hub-actions>
+ <div className="flex min-h-[42px] items-center gap-3 py-1 pl-1.5 pr-3">
<div role="radiogroup" aria-label="Character action" className="hub-act">
{actions.map((a) => (
<button
@@ -287,5 +288,9 @@ export function HubActions({ actions, active, name, onPick, right }: {
{right}
{on?.meta && <span className="hub-dim shrink-0 whitespace-nowrap hub-fs-125 tabular-nums max-[520px]:hidden" data-hub-action-meta>{on.meta}</span>}
</div>
+ {/* What the price beside it means, once an action is picked. One quiet
+ line, at every width. */}
+ {on && <p className="hub-dim px-3 pb-1.5 hub-fs-125" data-hub-local-line>{HUB_LOCAL_LINE}</p>}
+ </div>
)
}
diff --git a/src/index.css b/src/index.css
index d82c35b6..982318e0 100644
--- a/src/index.css
+++ b/src/index.css
@@ -3243,10 +3243,19 @@ input[type="range"].neuron-range:disabled { cursor: not-allowed; opacity: 0.5; }
.lu-hub .hub-act-item { padding: 0 8px; }
.lu-hub .hub-act-item svg { display: none; }
}
+/* A narrow window has no room for the column on the left. The character
+ then stands as a head over its photos: the picture small, beside it the
+ name and every action it has. Nothing is hidden at any width. The file
+ actions of a LoRA character alone stay where they are on a narrow
+ window, under More options (SpecialMore), so they stand once. */
@media (max-width: 700px) {
- .lu-hub .hub-stage { grid-template-columns: minmax(0, 1fr); }
- .lu-hub .hub-card { display: none; }
- .lu-hub .hub-body { grid-column: 1; }
+ .lu-hub .hub-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; }
+ .lu-hub .hub-card { grid-column: 1; grid-row: 2; position: relative; overflow: visible; min-height: 90px; padding: 10px 0 10px 68px; }
+ .lu-hub .hub-card > .hub-portrait { position: absolute; left: 0; top: 10px; width: 56px; margin-bottom: 0; }
+ .lu-hub .hub-card .hub-initial { font-size: calc(24px / var(--ui-scale, 1.15)); }
+ .lu-hub .hub-card .hub-card-file { display: none; }
+ .lu-hub .hub-body { grid-column: 1; grid-row: 3; }
+ .lu-hub .hub-foot { grid-row: 4; }
}
/* The pages of the area: "New character" and the training. */