Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat: support high-density sprite publishing

[._.]/ Adam Eivy9eec1f0a918e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index ee952d2404..b2d394d9b2 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -41,6 +41,7 @@
- **Agy's model field is now labeled for what it actually selects, and can be overridden per render.** The Image Gen settings field was labeled "Image model" while listing Gemini agent models, which read as the wrong list being loaded. It isn't: `agy models` is the catalog of *agent* models the CLI's `--model` flag accepts, and that agent is what drives the built-in `generate_image` tool. Agy exposes no knob for the underlying image model — its `generate_image` takes prompt, image name, aspect ratio, and reference paths and nothing else — so there is no `imagen-*` option to offer, and passing one makes agy exit before it generates. The field is now "Default agent model" with that explanation, and the Image Gen page adds an **Agent model** picker so a single queue item can run on a different agent model than the saved default without a settings round-trip. Leaving it blank inherits the Settings value; a pinned model that Google later drops from the catalog falls back to the default instead of failing the render. The retry editor on a failed Agy job now edits that same model field (it was bound to the local model-id field, which Agy never reads).
## Game
+- **Sprite atlases can now be compiled at presentation-grade source density without changing a game's character scale.** Set a bound runtime contract to 192px cells and Compile now scales the pivot and silhouette bounds with it, producing genuine 2× art from the approved source frames instead of enlarging a 96px atlas after the fact. The compiler's pose-consistency tolerance scales with source density too, while retaining the existing floor for smaller custom grids. This lets a game sample a 192px cell into its established 96px gameplay footprint for sharper characters and props.
- **Sprite publishing now gives games the right asset for both play and presentation.** A Sprite Manager binding can publish a dedicated 512px transparent selector portrait and a presentation-resolution idle strip from approved source frames alongside its compact runtime atlas. The idle strip carries a consumer sidecar with frame geometry, playback speed, image hash, and source-frame provenance; both presentation outputs retain the same repo anchoring, occupied-file consent, and outside-edit divergence guards as atlas publishing. User-authored animation tracks can also be deliberately reopened from their finalized state and replaced without discarding the superseded render evidence, so a game can evolve a menu idle into a character-specific field vignette without revising the character's identity art. Game artwork can now be assigned a first-class logo role, generated with a role-specific creative brief, and published into managed game UI assets with the existing provenance and drift guards.
- **Game workspaces now manage launch art, biome cards, and other game-facing artwork alongside sprites and music.** Choose any image from the PortOS gallery, assign its design role and game destination, generate a role-specific replacement in Image Gen, preview and edit the binding in place, then publish hash-verified bytes into the managed game with protection against overwriting outside changes; artwork also participates in bundle readiness and AI asset reviews.
- **[issue-3228] Game detail workspaces keep asset blockers and controls in reach.** The compact header and section tabs stay pinned while each panel scrolls independently, blocked rows explain how to recover and link directly to surviving Sprite or Music records, and missing, malformed, and deleted music audio now report distinct causes.
diff --git a/client/src/components/sprites/PublishWorkflow.jsx b/client/src/components/sprites/PublishWorkflow.jsx
index c15d68f40b..2e87b0ddde 100644
--- a/client/src/components/sprites/PublishWorkflow.jsx
+++ b/client/src/components/sprites/PublishWorkflow.jsx
@@ -21,6 +21,33 @@ import { timeAgo } from '../../utils/formatters.js';
const inputClass = 'w-full px-2 py-1 text-xs bg-port-bg border border-port-border rounded text-gray-200 focus:border-port-accent focus:outline-none';
const fieldLabelClass = 'block text-xs text-gray-400 mb-1';
const EMPTY_TRACK_DEFINITIONS = Object.freeze([]);
+const DEFAULT_COMPILE_GEOMETRY = Object.freeze({
+ cellSize: 96,
+ pivot: [48, 88],
+ targetMaxHeight: 74,
+ targetMaxWidth: 86,
+});
+
+export function geometryForCellSize(currentGeometry, requestedCellSize) {
+ if (!Number.isInteger(requestedCellSize)) return {};
+ const base = Number.isInteger(currentGeometry?.cellSize)
+ ? currentGeometry
+ : DEFAULT_COMPILE_GEOMETRY;
+ const scale = requestedCellSize / base.cellSize;
+ const pivot = Array.isArray(base.pivot) && base.pivot.length === 2
+ ? base.pivot
+ : DEFAULT_COMPILE_GEOMETRY.pivot;
+ return {
+ cellSize: requestedCellSize,
+ pivot: pivot.map((value) => Math.round(value * scale)),
+ targetMaxHeight: Math.round(
+ (base.targetMaxHeight ?? DEFAULT_COMPILE_GEOMETRY.targetMaxHeight) * scale,
+ ),
+ targetMaxWidth: Math.round(
+ (base.targetMaxWidth ?? DEFAULT_COMPILE_GEOMETRY.targetMaxWidth) * scale,
+ ),
+ };
+}
function contractSeedOf(definitions, contract) {
return Object.fromEntries(definitions.map((definition) => {
@@ -165,7 +192,8 @@ export default function PublishWorkflow({
};
const [compile, compiling] = useAsyncAction(async () => {
- const result = await compileSpriteAtlas(record.id, {}, { silent: true });
+ const geometry = geometryForCellSize(current?.geometry, cellNum);
+ const result = await compileSpriteAtlas(record.id, { geometry }, { silent: true });
onChanged?.();
return result;
}, { errorMessage: 'Atlas compile failed' });
@@ -350,7 +378,10 @@ export default function PublishWorkflow({
)}
<button
onClick={compile}
- disabled={compiling}
+ disabled={compiling || Boolean(contractError)}
+ title={contractError || (cellNum
+ ? `Compile source art at ${cellNum}px per cell`
+ : 'Compile with the standard source density')}
className="flex items-center gap-1 px-2 py-1 text-xs bg-port-bg border border-port-border rounded text-gray-300 hover:border-port-accent disabled:opacity-50"
>
<RefreshCw size={12} className={compiling ? 'animate-spin' : ''} />
@@ -411,7 +442,9 @@ export default function PublishWorkflow({
</div>
<p className="text-[11px] text-gray-500">
The grid a consuming app was built against. A publish whose compiled atlas disagrees is
- refused. Leave blank to publish unchecked; clearing removes a stored contract.
+ refused. Cell size also controls compile density: use 192px for a 2× source that the
+ game draws into a 96px footprint. Leave blank to use standard density; clearing removes
+ a stored contract.
</p>
<div className="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-5 gap-2">
{trackInputs.map(({ definition, raw }) => (
diff --git a/client/src/components/sprites/PublishWorkflow.test.jsx b/client/src/components/sprites/PublishWorkflow.test.jsx
index b25e43e5f8..9272318e00 100644
--- a/client/src/components/sprites/PublishWorkflow.test.jsx
+++ b/client/src/components/sprites/PublishWorkflow.test.jsx
@@ -20,7 +20,7 @@ vi.mock('../../hooks/useSidebarApps.js', () => ({
}));
import PublishWorkflow from './PublishWorkflow';
-import { setSpritePublishBinding } from '../../services/apiSprites.js';
+import { compileSpriteAtlas, setSpritePublishBinding } from '../../services/apiSprites.js';
const GEOMETRY = {
columns: ['idle', 'frame-00', 'frame-01', 'frame-02', 'frame-03', 'frame-04',
@@ -100,7 +100,30 @@ const savedContractBinding = {
const lastBindingArg = () => setSpritePublishBinding.mock.calls.at(-1)[1];
describe('PublishWorkflow runtime contract', () => {
- beforeEach(() => setSpritePublishBinding.mockClear());
+ beforeEach(() => {
+ compileSpriteAtlas.mockClear();
+ setSpritePublishBinding.mockClear();
+ });
+
+ it('compiles a 2x atlas from the runtime cell size without changing sprite proportions', async () => {
+ renderWorkflow(savedContractBinding);
+
+ fireEvent.change(screen.getByLabelText(/Cell size/), { target: { value: '192' } });
+ await act(async () => { fireEvent.click(screen.getByText('Recompile atlas')); });
+
+ expect(compileSpriteAtlas).toHaveBeenCalledWith(
+ 'example-walker',
+ {
+ geometry: {
+ cellSize: 192,
+ pivot: [96, 176],
+ targetMaxHeight: 148,
+ targetMaxWidth: 172,
+ },
+ },
+ { silent: true },
+ );
+ });
it('saves the player-facing picker animation destination', async () => {
renderWorkflow({ appId: 'app-1', atlasDestPath: 'assets/hero.png', codeBinding: null });
diff --git a/server/services/sprites/atlas.js b/server/services/sprites/atlas.js
index 581151f495..3adbf76fea 100644
--- a/server/services/sprites/atlas.js
+++ b/server/services/sprites/atlas.js
@@ -116,7 +116,9 @@ const ALPHA_THRESHOLD = 8;
const SILHOUETTE_ALPHA_THRESHOLD = 64;
// Post-resize alpha snap (Python premultiplied_resize's ALPHA_NOISE_FLOOR).
const ALPHA_NOISE_FLOOR = 2;
-// Compiled idle height must match the walk row's median height within 2px.
+// Compiled idle height must match the walk row's median height within two
+// logical (96px-contract) pixels. Scale the rounding tolerance with source
+// density so a 2×/3× compile applies the same visual standard.
const IDLE_HEIGHT_TOLERANCE = 2;
const RUNTIME_DIR = 'runtime';
@@ -553,8 +555,12 @@ async function compileTrackRow(direction, validated, geometry) {
geometry,
idleScale,
);
+ const idleHeightTolerance = Math.max(
+ IDLE_HEIGHT_TOLERANCE,
+ IDLE_HEIGHT_TOLERANCE * (geometry.cellSize / DEFAULT_ATLAS_GEOMETRY.cellSize),
+ );
if (validated.anchors[direction]
- && Math.abs(idle.meta.occupiedBounds.height - desiredIdleHeight) > IDLE_HEIGHT_TOLERANCE) {
+ && Math.abs(idle.meta.occupiedBounds.height - desiredIdleHeight) > idleHeightTolerance) {
throw compileError(
`${direction} idle height ${idle.meta.occupiedBounds.height} misses the animation median ${pyRoundTo(desiredIdleHeight, 2)}`,
);
diff --git a/server/services/sprites/atlas.test.js b/server/services/sprites/atlas.test.js
index 3256037805..d3692d4ff5 100644
--- a/server/services/sprites/atlas.test.js
+++ b/server/services/sprites/atlas.test.js
@@ -825,6 +825,21 @@ describe('compileAtlas', () => {
expect(meta.height).toBe(64 * 8);
});
+ it('scales the visual tolerance with a 2x source-density compile', async () => {
+ const id = await finalizedCharacter();
+ const result = await compileAtlas(id, {
+ geometry: {
+ cellSize: 192,
+ pivot: [96, 176],
+ targetMaxHeight: 148,
+ targetMaxWidth: 172,
+ },
+ });
+ const meta = await sharp(join(TEST_ROOT, 'sprites', id, result.atlasPath)).metadata();
+ expect(meta.width).toBe(192 * 9);
+ expect(meta.height).toBe(192 * 8);
+ });
+
it('refuses an imported legacy walk set with an explicit code (not a tamper error)', async () => {
const id = await finalizedCharacter();
const setAbs = join(TEST_ROOT, 'sprites', id, `walk/${id}-walk-set-v1.json`);