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

fix(#2992): send contract explicitly on app re-point, block contract with no binding, guard mismatch display

[._.]/ Adam Eivy093c2baf1660
diff --git a/client/src/components/sprites/PublishWorkflow.jsx b/client/src/components/sprites/PublishWorkflow.jsx
index b7cccc8b79..918f15b2d9 100644
--- a/client/src/components/sprites/PublishWorkflow.jsx
+++ b/client/src/components/sprites/PublishWorkflow.jsx
@@ -98,7 +98,9 @@ export default function PublishWorkflow({ record, walk, atlas, onChanged }) {
const intInRange = (n, lo, hi) => Number.isInteger(n) && n >= lo && n <= hi;
// Validate only what's populated; walkFrameCount is required whenever any
- // contract field is set (the server rejects a contract without it).
+ // contract field is set (the server rejects a contract without it). A contract
+ // is also meaningless without an app + destination — the binding it would ride
+ // on is null, so the value would be silently discarded; block that instead.
let contractError = null;
if (!hasContract && (cellRaw !== '' || colsRaw !== '')) {
contractError = 'Walk frame count is required for a runtime contract.';
@@ -108,11 +110,17 @@ export default function PublishWorkflow({ record, walk, atlas, onChanged }) {
contractError = 'Cell size must be a whole number 16–1024.';
} else if (colsNum !== null && !intInRange(colsNum, 1, 256)) {
contractError = 'Column count must be a whole number 1–256.';
+ } else if (hasContract && !(appId && destPath.trim())) {
+ contractError = 'Bind an app and destination before declaring a contract.';
}
// Dirty relative to the SAVED contract, comparing the seeded string forms so
- // "opened but untouched" never counts as a change.
- const contractDirty = seedFrames !== framesRaw || seedCell !== cellRaw || seedCols !== colsRaw;
+ // "opened but untouched" never counts as a change. A re-point (appId change)
+ // with a populated contract also counts as dirty so the displayed values are
+ // sent explicitly against the new app — otherwise the omitted-key path drops
+ // them (server inheritance is app-scoped) while the fields still show them.
+ const contractDirty = seedFrames !== framesRaw || seedCell !== cellRaw || seedCols !== colsRaw
+ || (hasContract && appId !== (saved?.appId || ''));
const fillFromAtlas = () => {
const geometry = current?.geometry;
@@ -242,10 +250,10 @@ export default function PublishWorkflow({ record, walk, atlas, onChanged }) {
const savedContractMismatch = (() => {
if (!savedContract || !atlasGeom) return null;
if (Number.isInteger(savedContract.walkFrameCount) && savedContract.walkFrameCount !== atlasFrames) {
- return `contract expects ${savedContract.walkFrameCount} walk frames, atlas has ${atlasFrames}`;
+ return `contract expects ${savedContract.walkFrameCount} walk frames, atlas has ${atlasFrames ?? '?'}`;
}
if (Number.isInteger(savedContract.columnCount) && savedContract.columnCount !== atlasCols) {
- return `contract expects ${savedContract.columnCount} cols, atlas has ${atlasCols}`;
+ return `contract expects ${savedContract.columnCount} cols, atlas has ${atlasCols ?? '?'}`;
}
if (Number.isInteger(savedContract.cellSize) && savedContract.cellSize !== atlasCell) {
return `contract expects ${savedContract.cellSize}px cells, atlas has ${atlasCell ?? '?'}px`;
diff --git a/client/src/components/sprites/PublishWorkflow.test.jsx b/client/src/components/sprites/PublishWorkflow.test.jsx
index 0ad9421055..02794bfc70 100644
--- a/client/src/components/sprites/PublishWorkflow.test.jsx
+++ b/client/src/components/sprites/PublishWorkflow.test.jsx
@@ -16,7 +16,7 @@ vi.mock('../../services/apiSprites.js', () => ({
}));
vi.mock('../../hooks/useSidebarApps.js', () => ({
- useSidebarApps: () => [{ id: 'app-1', name: 'Example App' }],
+ useSidebarApps: () => [{ id: 'app-1', name: 'Example App' }, { id: 'app-2', name: 'Other App' }],
}));
import PublishWorkflow from './PublishWorkflow';
@@ -93,6 +93,29 @@ describe('PublishWorkflow runtime contract', () => {
expect('runtimeContract' in binding).toBe(false);
});
+ it('SENDS the displayed contract explicitly when the bound app changes', async () => {
+ renderWorkflow(savedContractBinding);
+
+ // Re-pointing to a different app makes server inheritance (app-scoped) drop
+ // the contract; since the fields still show it, the form must send it
+ // explicitly rather than omit the key.
+ fireEvent.change(screen.getByLabelText('Managed app'), { target: { value: 'app-2' } });
+ await act(async () => { fireEvent.click(screen.getByText('Save binding')); });
+
+ const binding = lastBindingArg();
+ expect(binding.appId).toBe('app-2');
+ expect(binding.runtimeContract).toEqual({ walkFrameCount: 12, cellSize: 96, columnCount: 13 });
+ });
+
+ it('blocks a contract with no app/destination and explains why', () => {
+ renderWorkflow(null, atlasWith());
+
+ fireEvent.change(screen.getByLabelText(/Walk frames/), { target: { value: '12' } });
+
+ expect(screen.getByText(/Bind an app and destination/)).toBeInTheDocument();
+ expect(screen.getByText('Save binding')).toBeDisabled();
+ });
+
it('MATCHES the current atlas geometry into the fields', () => {
renderWorkflow({ appId: 'app-1', atlasDestPath: 'assets/hero.png', codeBinding: null });