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

make the re-aim tag the run's identity, not just a label

Adam Eivy4337360e39a3
diff --git a/client/src/components/apps/tabs/AutomationTab.test.jsx b/client/src/components/apps/tabs/AutomationTab.test.jsx
index 9824c7704d..76d1cca0d2 100644
--- a/client/src/components/apps/tabs/AutomationTab.test.jsx
+++ b/client/src/components/apps/tabs/AutomationTab.test.jsx
@@ -119,10 +119,12 @@ describe('AutomationTab per-app options', () => {
await screen.findByText('layered-intelligence');
await act(async () => {});
+ // The tab used to cap itself well below the window, leaving the right of a
+ // desktop screen empty. Only the cap is asserted — which breakpoints the
+ // card grid uses is a retune anyone should be free to make.
expect(container.querySelector('.max-w-5xl')).toBeNull();
- // Cards widen with the viewport rather than stopping at two columns.
const grid = screen.getByText('layered-intelligence').closest('.grid');
- expect(grid).toHaveClass('grid-cols-1', 'lg:grid-cols-2', '2xl:grid-cols-3');
+ expect(grid.className).toMatch(/grid-cols-1/);
});
it('puts custom automations before the shared schedule cards and shows app cadence', async () => {
diff --git a/client/src/components/cos/JobCard.jsx b/client/src/components/cos/JobCard.jsx
index 0f9ab71ea2..d05b13135e 100644
--- a/client/src/components/cos/JobCard.jsx
+++ b/client/src/components/cos/JobCard.jsx
@@ -312,7 +312,19 @@ export default function JobCard({
const savedFormValuesKey = JSON.stringify(savedFormValues);
useEffect(() => { setRunValues(null); }, [savedFormValuesKey]);
const runFormValues = runValues ?? savedFormValues;
- const runValuesDirty = runValues !== null && JSON.stringify(runValues) !== savedFormValuesKey;
+ // Compare the way the server's `isSupplied` does: absent, null and blank are
+ // the same answer, and a checkbox is its truthiness. An input the job has no
+ // stored value for is seeded with a blank, so a raw `!==` would read toggling
+ // one on and back off as a real change — shipping a value that adds a prompt
+ // line the run-as-saved prompt does not have, for an edit the user undid.
+ const sameAsSaved = (a, b) => a === b
+ || (typeof a === 'boolean' || typeof b === 'boolean'
+ ? Boolean(a) === Boolean(b)
+ : String(a ?? '').trim() === String(b ?? '').trim());
+ const changedRunKeys = runValues === null
+ ? []
+ : Object.keys(runValues).filter(key => !sameAsSaved(runValues[key], savedFormValues[key]));
+ const runValuesDirty = changedRunKeys.length > 0;
const handleTrigger = () => {
// The API accepts a half-filled configuration on purpose (a job is saved
@@ -330,10 +342,9 @@ export default function JobCard({
// another surface since this card rendered. An empty projection means "run
// as saved". Always an options object, so a caller can forward it to the API
// wrapper unconditionally.
- const changedRunValues = Object.fromEntries(
- Object.keys(runValues || {}).filter(key => runValues[key] !== savedFormValues[key]).map(key => [key, runValues[key]])
- );
- onTrigger(job.id, Object.keys(changedRunValues).length ? { formValues: changedRunValues } : {});
+ onTrigger(job.id, runValuesDirty
+ ? { formValues: Object.fromEntries(changedRunKeys.map(key => [key, runValues[key]])) }
+ : {});
};
const startEditing = () => {
diff --git a/client/src/components/cos/JobCard.test.jsx b/client/src/components/cos/JobCard.test.jsx
index 62767c5eff..359336703e 100644
--- a/client/src/components/cos/JobCard.test.jsx
+++ b/client/src/components/cos/JobCard.test.jsx
@@ -109,6 +109,21 @@ describe('JobCard on-demand cadence', () => {
expect(screen.getByText('On Demand')).toBeTruthy();
});
+ it('hands the configuration form to the editor while editing, never showing two copies', () => {
+ renderCard({
+ ...ON_DEMAND_JOB,
+ formFields: [{ key: 'subject', label: 'Subject', type: 'text' }],
+ formValues: { subject: 'Saved subject' }
+ });
+
+ // The card's ad-hoc panel edits THIS RUN; the editor's copy edits what the
+ // task is saved with. Two live copies of one form is a merge nobody wins, so
+ // exactly one is on screen at a time.
+ expect(screen.getAllByLabelText('Subject')).toHaveLength(1);
+ fireEvent.click(screen.getByRole('button', { name: 'Edit' }));
+ expect(screen.getAllByLabelText('Subject')).toHaveLength(1);
+ });
+
it('offers the cadence and hides the time input once it is selected', () => {
renderCard({ ...ON_DEMAND_JOB, interval: 'daily', intervalMs: 86400000, scheduledTime: '09:00' });
fireEvent.click(screen.getByRole('button', { name: 'Edit' }));
diff --git a/server/lib/jobFormFields.js b/server/lib/jobFormFields.js
index fdc7dbd664..8ac25493af 100644
--- a/server/lib/jobFormFields.js
+++ b/server/lib/jobFormFields.js
@@ -185,37 +185,32 @@ export function describeReaimedValues(fields, savedValues, runValues) {
&& comparableValue(field, runValues?.[field.key]) !== comparableValue(field, savedValues?.[field.key]));
if (changed.length === 0) return '';
- // Whether the readable form below dropped anything — a clipped value, a
- // collapsed newline, or a field past the cap. It decides the digest at the end.
- let lossy = changed.length > REAIM_MAX_FIELDS;
-
const parts = changed.slice(0, REAIM_MAX_FIELDS).map((field) => {
const label = String(field.label || field.key).trim();
const raw = comparableValue(field, runValues?.[field.key]).trim();
// Collapse newlines: this rides on the description's FIRST line, and a
// multi-line value would push the rest out of the dedupe key entirely.
const text = raw.replace(/\s+/g, ' ');
- if (text !== raw) lossy = true;
if (!text) return `${label}: (cleared)`;
- if (text.length > REAIM_VALUE_CHARS) {
- lossy = true;
- return `${label}: ${text.slice(0, REAIM_VALUE_CHARS)}…`;
- }
+ if (text.length > REAIM_VALUE_CHARS) return `${label}: ${text.slice(0, REAIM_VALUE_CHARS)}…`;
return `${label}: ${text}`;
});
if (changed.length > REAIM_MAX_FIELDS) parts.push(`+${changed.length - REAIM_MAX_FIELDS} more`);
- // A clipped or truncated tag can render two genuinely different aims
- // identically — and an identical first line is precisely what gets deduped
- // away, which is the silent drop this whole function exists to prevent. When
- // the readable form lost information, carry a digest of the FULL changed set
- // so the identity stays distinct even though the label no longer shows why.
- if (lossy) {
- // JSON rather than a joined string: any separator character can itself occur
- // inside a value, which would let two different changed sets encode alike.
- const full = JSON.stringify(changed.map((field) => [field.key, comparableValue(field, runValues?.[field.key])]));
- parts.push(createHash('sha1').update(full).digest('hex').slice(0, 8));
- }
+ // ALWAYS carry a digest of the full changed set — the readable part above is
+ // for the human, this is the identity. The dedupe key is
+ // `firstLine(description).toLowerCase()`, and the readable form is a
+ // case-folded, separator-ambiguous, clipped encoding: `Subject: acme` and
+ // `Subject: Acme` collide, as do one value containing `, ` and two fields that
+ // reassemble the same string, as do two long values sharing a clipped prefix.
+ // Any of those is a run silently rejected as a duplicate while the caller is
+ // told it was queued — the exact failure this function exists to prevent — so
+ // the digest is unconditional rather than gated on a guess about which
+ // renderings happened to lose information.
+ // JSON rather than a joined string: any separator character can itself occur
+ // inside a value, which would let two different changed sets encode alike.
+ const full = JSON.stringify(changed.map((field) => [field.key, comparableValue(field, runValues?.[field.key])]));
+ parts.push(createHash('sha1').update(full).digest('hex').slice(0, 8));
return parts.join(', ');
}
diff --git a/server/lib/jobFormFields.test.js b/server/lib/jobFormFields.test.js
index f6078307fc..8107f09c4a 100644
--- a/server/lib/jobFormFields.test.js
+++ b/server/lib/jobFormFields.test.js
@@ -128,12 +128,12 @@ describe('describeReaimedValues', () => {
});
it('names a changed value by its label, and a cleared one as cleared', () => {
- expect(describeReaimedValues([subject], { subject: 'old' }, { subject: 'new' })).toBe('Subject: new');
- expect(describeReaimedValues([subject], { subject: 'old' }, { subject: '' })).toBe('Subject: (cleared)');
+ expect(describeReaimedValues([subject], { subject: 'old' }, { subject: 'new' })).toContain('Subject: new');
+ expect(describeReaimedValues([subject], { subject: 'old' }, { subject: '' })).toContain('Subject: (cleared)');
});
it('renders a select by its option label, not its stored value', () => {
- expect(describeReaimedValues([depth], { depth: '' }, { depth: 'deep' })).toBe('Depth: Deep dive');
+ expect(describeReaimedValues([depth], { depth: '' }, { depth: 'deep' })).toContain('Depth: Deep dive');
});
it('never emits a newline, so the whole tag stays inside the deduped first line', () => {
@@ -150,6 +150,21 @@ describe('describeReaimedValues', () => {
// The point of the tag: two different aims must never render identically, or
// the second is rejected as a duplicate and silently never runs.
+ // The dedupe key is lowercased, so a tag that differs only by case is not a
+ // difference at all by the time addTask compares it.
+ it('stays distinct when two aims differ only in letter case', () => {
+ const first = describeReaimedValues([subject], { subject: 'x' }, { subject: 'ACME' });
+ const second = describeReaimedValues([subject], { subject: 'x' }, { subject: 'acme' });
+ expect(first.toLowerCase()).not.toBe(second.toLowerCase());
+ });
+
+ it('stays distinct when one value reassembles the separator of two fields', () => {
+ const two = [subject, { key: 'note', label: 'C', type: 'text' }];
+ const first = describeReaimedValues(two, {}, { subject: 'B', note: 'D' });
+ const second = describeReaimedValues(two, {}, { subject: 'B, C: D' });
+ expect(first.toLowerCase()).not.toBe(second.toLowerCase());
+ });
+
it('stays distinct when the readable form clips a long value', () => {
const shared = 'x'.repeat(60);
const first = describeReaimedValues([brief], { brief: '' }, { brief: `${shared}AAA` });
diff --git a/server/routes/cosJobRoutes.test.js b/server/routes/cosJobRoutes.test.js
index 6f8a19c80b..e2bf3e7ebc 100644
--- a/server/routes/cosJobRoutes.test.js
+++ b/server/routes/cosJobRoutes.test.js
@@ -590,7 +590,7 @@ describe('CoS Job Routes', () => {
// reaches it — so without the changed value named here, aiming this job
// somewhere else while the first run is still queued is silently dropped.
expect(cos.addTask).toHaveBeenCalledWith(
- expect.objectContaining({ description: 'Review — Subject: One-off subject' }),
+ expect.objectContaining({ description: expect.stringContaining('Review — Subject: One-off subject') }),
'internal',
expect.anything()
);