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

chore: release v2.55.0

[._.]/ Adam Eivyc8622bcf17ce
diff --git a/.changelog/v2.55.0.md b/.changelog/v2.55.0.md
new file mode 100644
index 0000000000..f1a4319177
--- /dev/null
+++ b/.changelog/v2.55.0.md
@@ -0,0 +1,49 @@
+# Release v2.55.0
+
+Released: 2026-09-01
+
+## Highlights
+
+- Brain is more useful at a glance with On This Day and Today's Agenda dashboard views, indexed daily projections, searchable album tracks, and notes on saved links.
+- PortOS makes local AI operations easier to understand with refreshed model catalogs, focused LLM views, Codex account readiness, and clearer runtime bootstrap diagnostics.
+- Managed app workflows are safer across forks and Git hosts, with GitLab-aware links, recoverable clone operations, merged-branch cleanup, and on-demand update and restudy.
+- Media creation gains hardware-aware render lanes, universe style application, FableLoom rendering preferences, and automated fal scene-video production with clearer privacy and allowance guidance.
+- Eidoverse source management now tracks world stack versions while keeping the world experience unobstructed and upgradeable.
+- Everyday work is more comfortable on small screens and long-running sessions, with auto-sizing textareas, improved music controls, resilient media queues, and safer browser preferences.
+- Synchronization, CI, and operator automation become more dependable through batched tombstone maintenance, indexed sync tails, fail-closed review and cancellation paths, and stronger recovery after interruptions.
+
+## Added
+
+- Added On This Day and Today's Agenda dashboard widgets backed by Brain projections.
+- Added an operator-action ledger, notes for saved Brain links, and a searchable album track picker.
+- Added Codex ChatGPT account readiness reporting and sign-in from PortOS.
+ - Added a refreshed curated local-model catalog and separated model-management views for runtimes and libraries.
+ - Added clearer cron schedule editing with validation and an explicit discard confirmation for unsaved changes.
+ - Added fork-aware managed-app workflows, GitLab support for Brain links, merged-branch cleanup, and on-demand update-and-restudy.
+- Added universe-style conditioning to media generation, FableLoom story rendering preferences, and automated fal scene-video production.
+- Added Eidoverse source-stack version management and independent video-render lanes.
+
+## Changed
+
+- Text inputs for task descriptions and media prompts now grow with their contents instead of forcing users to work in a fixed-height field.
+- Brain daily views read from indexed projections, while local-date calculations share one DST-safe implementation.
+- Provider and model surfaces now hide incompatible choices, keep LLM navigation focused, and expose the best available FableLoom scene media.
+- Browser downloads use profile preferences, media prompts update immediately after saves, and long-running video work keeps live frames out of the final render surface.
+- CI cancellation and review automation now fail closed around required checks, while clone, submodule, lockfile, and application-port recovery preserve more of the user's work.
+- Eidoverse, FableLoom, and music workflows receive clearer setup, privacy, accessibility, and mobile guidance.
+
+## Fixed
+
+- Fixed GitLab asset-link parsing so excessive namespace depth cannot turn an asset URL into an unintended repository path.
+ - Fixed interrupted repository clones, MTPLX diagnostics, media-job retry behavior, and browser preference writes so failures remain recoverable and diagnosable.
+ - Fixed browser preference setup to preserve malformed or unreadable Chrome settings instead of replacing them with an empty profile.
+ - Fixed Codex app-server handshake timeouts and shutdowns so failed launches terminate their child process instead of leaving it orphaned.
+ - Fixed legacy Brain link filters, scalar action-type queries, DST-sensitive day windows, and repository URL parsing for route-named GitHub projects and deep links.
+ - Fixed MLX video watchdog pressure, tombstone base-hash flushing, artist and album eviction batching, and sync-log indexing across crash fragments and stale operations.
+- Fixed media generation to preserve universe styles, render privacy choices before handoff, honor provider lanes, and avoid claiming failed template-usage writes succeeded.
+- Fixed FableLoom imports, scene previews, hosted controls, and mobile layouts, along with SongBook navigation, zoom, transpose announcements, and fretbox descriptions.
+- Fixed fork comparisons, generated route catalogs, incompatible-provider warnings, and managed-install behavior so updates preserve the correct source and local dependencies.
+
+## Full Changelog
+
+**Full Diff**: https://github.com/atomantic/PortOS/compare/v2.54.0...v2.55.0
diff --git a/browser/server.js b/browser/server.js
index c09ec86e18..724b7b3e50 100644
--- a/browser/server.js
+++ b/browser/server.js
@@ -26,6 +26,9 @@ let downloadWs = null;
let downloadWsReconnectTimer = null;
let shuttingDown = false;
+const PREFS_MISSING = Symbol('prefs-missing');
+const PREFS_UNREADABLE = Symbol('prefs-unreadable');
+
const DEFAULT_MAC_CHROME_APP = '/Applications/Google Chrome.app';
function defaultChromeBinary() {
@@ -106,13 +109,12 @@ async function applyDownloadDirPreference(profileDir, downloadDir) {
const prefsPath = join(profileDir, 'Default', 'Preferences');
const raw = await tryReadJson(prefsPath);
// A profile that has never launched has no Preferences file yet; Chrome
- // merges our partial object with its defaults on first run. A hand-edited or
- // truncated file can also parse into a non-object root (a string, an array),
- // and assigning a property to a string primitive throws under ESM's strict
- // mode — uncaught out of launchBrowser()→main() into a PM2 restart-loop. So
- // normalize the root and every branch we spread, the same way loadConfig
- // above refuses to trust the config file.
- const prefs = asObject(raw);
+ // merges our partial object with its defaults on first run. Do not treat a
+ // corrupt or unreadable existing file as an empty profile: rewriting it
+ // would discard unrelated Chrome settings. Let Chrome repair it on launch
+ // while preserving the user's original bytes.
+ if (raw === PREFS_UNREADABLE) return false;
+ const prefs = raw === PREFS_MISSING ? {} : raw;
if (prefs.download?.default_directory === downloadDir
&& prefs.savefile?.default_directory === downloadDir) {
return false;
@@ -135,13 +137,22 @@ function asObject(value) {
}
async function tryReadJson(path) {
- const raw = await readFile(path, 'utf-8').catch(() => null);
- if (!raw) return null;
+ const raw = await readFile(path, 'utf-8').catch(err => {
+ if (err.code === 'ENOENT') return PREFS_MISSING;
+ console.error(`⚠️ Unable to read Chrome Preferences, preserving file: ${err.message}`);
+ return PREFS_UNREADABLE;
+ });
+ if (raw === PREFS_MISSING || raw === PREFS_UNREADABLE) return raw;
try {
- return JSON.parse(raw);
+ const value = JSON.parse(raw);
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
+ console.error('⚠️ Chrome Preferences root is not an object, preserving file');
+ return PREFS_UNREADABLE;
+ }
+ return value;
} catch (err) {
- console.error(`⚠️ Corrupt Chrome Preferences, rewriting: ${err.message}`);
- return null;
+ console.error(`⚠️ Corrupt Chrome Preferences, preserving file: ${err.message}`);
+ return PREFS_UNREADABLE;
}
}
diff --git a/client/src/lib/repoUrl.js b/client/src/lib/repoUrl.js
index 9a16310f45..ba62772556 100644
--- a/client/src/lib/repoUrl.js
+++ b/client/src/lib/repoUrl.js
@@ -122,21 +122,26 @@ export function parseRepoUrl(url) {
const hostConfig = REPO_HOSTS[host];
if (!hostConfig) return null;
- // Drop the query/hash, then GitLab's `/-/` deep-link separator, then walk the
- // remaining segments until a host UI route word.
+ // Drop the query/hash, then GitLab's `/-/` deep-link separator. GitHub has a
+ // fixed owner/repo pair, so identify those two operands before looking at any
+ // later route words — a repository itself may be named `issues`, `settings`,
+ // or `tree`, and arbitrary GitHub deep links are still valid repo URLs.
let path = (match[2] || '').split(/[?#]/)[0].replace(/^\//, '');
const dashIndex = path.indexOf('/-/');
if (dashIndex !== -1) path = path.slice(0, dashIndex);
- const segments = [];
- for (const segment of path.split('/')) {
- if (!segment) continue;
- if (RESERVED_PATH_SEGMENTS.has(segment.toLowerCase())) break;
- segments.push(segment);
+ const pathSegments = path.split('/').filter(Boolean);
+ const { maxDepth, allowDots } = hostConfig.namespace;
+ let segments = pathSegments;
+ if (hostConfig.flatClonePath) {
+ segments = pathSegments.slice(0, maxDepth + 1);
+ } else {
+ const routeIndex = pathSegments.findIndex((segment, index) =>
+ index >= 2 && RESERVED_PATH_SEGMENTS.has(segment.toLowerCase()));
+ if (routeIndex !== -1) segments = pathSegments.slice(0, routeIndex);
}
if (segments.length < 2) return null;
- const { maxDepth, allowDots } = hostConfig.namespace;
// Past the cap the path is a deep link into the project, not a deeper
// namespace — reading it as one would clone into (and create directories
// inside) an existing checkout.
diff --git a/package-lock.json b/package-lock.json
index 566c379d04..58a183fd19 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "portos",
- "version": "2.54.0",
+ "version": "2.55.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "portos",
- "version": "2.54.0",
+ "version": "2.55.0",
"license": "MIT",
"dependencies": {
"pm2": "7.0.4"
diff --git a/package.json b/package.json
index 97411fa1bc..8a42e8deb9 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portos",
- "version": "2.54.0",
+ "version": "2.55.0",
"private": true,
"description": "Local dev machine App OS portal",
"author": "Adam Eivy (@antic|@atomantic)",
diff --git a/server/lib/apiRouteCatalog.generated.json b/server/lib/apiRouteCatalog.generated.json
index 69678d248b..1c7338bb89 100644
--- a/server/lib/apiRouteCatalog.generated.json
+++ b/server/lib/apiRouteCatalog.generated.json
@@ -2148,7 +2148,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 340
+ "line": 341
}
]
},
@@ -2159,7 +2159,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 350
+ "line": 351
}
]
},
@@ -2170,7 +2170,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 389
+ "line": 390
}
]
},
@@ -2181,7 +2181,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 374
+ "line": 375
}
]
},
@@ -2192,7 +2192,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 362
+ "line": 363
}
]
},
@@ -2709,7 +2709,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 119
+ "line": 120
}
]
},
@@ -2720,7 +2720,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 180
+ "line": 181
}
]
},
@@ -2731,7 +2731,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 107
+ "line": 108
}
]
},
@@ -2742,7 +2742,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 143
+ "line": 144
}
]
},
@@ -2753,7 +2753,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 192
+ "line": 193
}
]
},
@@ -2764,7 +2764,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 248
+ "line": 249
}
]
},
@@ -2775,7 +2775,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 227
+ "line": 228
}
]
},
@@ -2786,7 +2786,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 278
+ "line": 279
}
]
},
@@ -2797,7 +2797,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 320
+ "line": 321
}
]
},
@@ -2808,7 +2808,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 301
+ "line": 302
}
]
},
@@ -2819,7 +2819,7 @@
"sources": [
{
"source": "server/routes/brainLinks.js",
- "line": 83
+ "line": 84
}
]
},
diff --git a/server/lib/brainValidation.js b/server/lib/brainValidation.js
index 7a64f97a27..68206d216c 100644
--- a/server/lib/brainValidation.js
+++ b/server/lib/brainValidation.js
@@ -534,6 +534,12 @@ export const linksQuerySchema = z.object({
v => (typeof v === 'string' ? v === 'true' : v),
z.boolean()
).optional(),
+ // Legacy peers and clients still use the GitHub-only name. Keep accepting it
+ // while the route normalizes it to the host-neutral filter above.
+ isGitHubRepo: z.preprocess(
+ v => (typeof v === 'string' ? v === 'true' : v),
+ z.boolean()
+ ).optional(),
// LinksTab does its own filtering, search, and bucket assignment client-side
// over the full set — so the upper cap has to be large enough to return every
// saved link in one round-trip. 5000 is plenty of headroom for a single-user
diff --git a/server/lib/brainValidation.test.js b/server/lib/brainValidation.test.js
index de9b881f0d..eace79e774 100644
--- a/server/lib/brainValidation.test.js
+++ b/server/lib/brainValidation.test.js
@@ -656,6 +656,12 @@ describe('brainValidation.js', () => {
expect(result.data.isRepo).toBe(false);
});
+ it('should accept the legacy GitHub-only filter name', () => {
+ const result = linksQuerySchema.safeParse({ isGitHubRepo: 'true' });
+ expect(result.success).toBe(true);
+ expect(result.data.isGitHubRepo).toBe(true);
+ });
+
it('should filter by linkType', () => {
const result = linksQuerySchema.safeParse({ linkType: 'documentation' });
expect(result.success).toBe(true);
diff --git a/server/lib/repoUrl.js b/server/lib/repoUrl.js
index 25d48ba623..40a8f17a2c 100644
--- a/server/lib/repoUrl.js
+++ b/server/lib/repoUrl.js
@@ -123,21 +123,26 @@ export function parseRepoUrl(url) {
const hostConfig = REPO_HOSTS[host];
if (!hostConfig) return null;
- // Drop the query/hash, then GitLab's `/-/` deep-link separator, then walk the
- // remaining segments until a host UI route word.
+ // Drop the query/hash, then GitLab's `/-/` deep-link separator. GitHub has a
+ // fixed owner/repo pair, so identify those two operands before looking at any
+ // later route words — a repository itself may be named `issues`, `settings`,
+ // or `tree`, and arbitrary GitHub deep links are still valid repo URLs.
let path = (match[2] || '').split(/[?#]/)[0].replace(/^\//, '');
const dashIndex = path.indexOf('/-/');
if (dashIndex !== -1) path = path.slice(0, dashIndex);
- const segments = [];
- for (const segment of path.split('/')) {
- if (!segment) continue;
- if (RESERVED_PATH_SEGMENTS.has(segment.toLowerCase())) break;
- segments.push(segment);
+ const pathSegments = path.split('/').filter(Boolean);
+ const { maxDepth, allowDots } = hostConfig.namespace;
+ let segments = pathSegments;
+ if (hostConfig.flatClonePath) {
+ segments = pathSegments.slice(0, maxDepth + 1);
+ } else {
+ const routeIndex = pathSegments.findIndex((segment, index) =>
+ index >= 2 && RESERVED_PATH_SEGMENTS.has(segment.toLowerCase()));
+ if (routeIndex !== -1) segments = pathSegments.slice(0, routeIndex);
}
if (segments.length < 2) return null;
- const { maxDepth, allowDots } = hostConfig.namespace;
// Past the cap the path is a deep link into the project, not a deeper
// namespace — reading it as one would clone into (and create directories
// inside) an existing checkout.
diff --git a/server/lib/repoUrl.test.js b/server/lib/repoUrl.test.js
index d5c91ba475..386662acae 100644
--- a/server/lib/repoUrl.test.js
+++ b/server/lib/repoUrl.test.js
@@ -137,6 +137,15 @@ describe('parseRepoUrl across hosts', () => {
.toMatchObject({ owner: 'example-owner', repo: 'example-repo' });
});
+ it('identifies GitHub repository names before deep-link route words', () => {
+ for (const repoName of ['issues', 'settings', 'tree']) {
+ expect(parseRepoUrl(`https://github.com/example-owner/${repoName}`), repoName)
+ .toMatchObject({ owner: 'example-owner', repo: repoName });
+ }
+ expect(parseRepoUrl('https://github.com/example-owner/example-repo/discussions/1'))
+ .toMatchObject({ owner: 'example-owner', repo: 'example-repo' });
+ });
+
// Without a depth cap, a project asset URL reads as a DEEPER NAMESPACE, and
// the cloner then manufactures directories inside the existing acme/widgets
// checkout before the clone of "pipeline.svg" fails.
diff --git a/server/lib/timezone.js b/server/lib/timezone.js
index 5f78414f53..743123bbb8 100644
--- a/server/lib/timezone.js
+++ b/server/lib/timezone.js
@@ -193,10 +193,14 @@ export function anchorLocalMidnightUtc(dayStr, tz) {
export function localDayWindowUtc(timezone, atDate = new Date()) {
const date = todayInTimezone(timezone, atDate)
const startMs = anchorLocalMidnightUtc(date, timezone)
+ const range = localDayRangeUtc(date, timezone)
+ const endMs = range?.end?.getTime()
return {
date,
startDate: new Date(startMs).toISOString(),
- endDate: new Date(startMs + 86399999).toISOString(),
+ // The inclusive end is derived from the next local-day boundary, so a
+ // 23-hour or 25-hour DST day cannot leak into or omit the adjacent date.
+ endDate: new Date(Number.isFinite(endMs) ? endMs - 1 : startMs + DAY_MS - 1).toISOString(),
}
}
diff --git a/server/lib/timezone.test.js b/server/lib/timezone.test.js
index f851ebdbc3..36882530c8 100644
--- a/server/lib/timezone.test.js
+++ b/server/lib/timezone.test.js
@@ -246,6 +246,15 @@ describe('timezone', () => {
expect(startDate).toBe('2026-04-16T07:00:00.000Z')
expect(endDate).toBe('2026-04-17T06:59:59.999Z')
})
+
+ it.each([
+ ['2026-03-08T12:00:00Z', '2026-03-08', '2026-03-09T06:59:59.999Z'],
+ ['2026-11-01T12:00:00Z', '2026-11-01', '2026-11-02T07:59:59.999Z'],
+ ])('uses the next local-day boundary on the %s DST date', (at, date, endDate) => {
+ const window = localDayWindowUtc('America/Los_Angeles', new Date(at))
+ expect(window.date).toBe(date)
+ expect(window.endDate).toBe(endDate)
+ })
})
describe('localDayRangeUtc', () => {
diff --git a/server/routes/brainLinks.js b/server/routes/brainLinks.js
index ef2e587c60..489c10ce06 100644
--- a/server/routes/brainLinks.js
+++ b/server/routes/brainLinks.js
@@ -65,11 +65,12 @@ const queueFailure = (reason, what) => (QUEUE_REASON_ERRORS[reason] ?? (() =>
* Get all links with optional filters
*/
router.get('/links', asyncHandler(async (req, res) => {
- const { linkType, isRepo, limit, offset } = validateRequest(linksQuerySchema, req.query);
+ const { linkType, isRepo, isGitHubRepo, limit, offset } = validateRequest(linksQuerySchema, req.query);
+ const repoFilter = isRepo ?? isGitHubRepo;
// Filtering, newest-first ordering, and the total count are answered from
// brainStorage's cached link-summary index, so only THIS page's records are
// read and parsed from disk (issue #3509) — not the whole collection.
- const { links, total } = await brainService.getLinksPage({ linkType, isRepo, limit, offset });
+ const { links, total } = await brainService.getLinksPage({ linkType, isRepo: repoFilter, limit, offset });
res.json({ links, total, limit, offset });
}));
diff --git a/server/routes/brainLinks.test.js b/server/routes/brainLinks.test.js
index 4df35e7081..d748607b52 100644
--- a/server/routes/brainLinks.test.js
+++ b/server/routes/brainLinks.test.js
@@ -126,6 +126,14 @@ describe('GET /api/brain/links', () => {
);
});
+ it('maps the legacy isGitHubRepo query name to the host-neutral filter', async () => {
+ await request(app).get('/api/brain/links?isGitHubRepo=true');
+
+ expect(brainService.getLinksPage).toHaveBeenCalledWith(
+ expect.objectContaining({ isRepo: true }),
+ );
+ });
+
it('rejects an out-of-range limit before touching the service', async () => {
const res = await request(app).get('/api/brain/links?limit=999999');
diff --git a/server/routes/userActions.test.js b/server/routes/userActions.test.js
index 4dd7e11bb9..a3c801f0c9 100644
--- a/server/routes/userActions.test.js
+++ b/server/routes/userActions.test.js
@@ -84,6 +84,11 @@ describe('GET /api/user-actions', () => {
expect(res.body.events.map((e) => e.dedupeKey)).toEqual(['e3', 'e1']);
});
+ it('accepts a single types parameter as one filter value', async () => {
+ const res = await request(buildApp()).get('/api/user-actions?types=cos.task.create');
+ expect(res.body.events.map((e) => e.dedupeKey)).toEqual(['e1']);
+ });
+
it('clamps an oversized limit instead of rejecting it', async () => {
const res = await request(buildApp()).get(`/api/user-actions?limit=${MAX_LIST_LIMIT * 10}`);
expect(res.status).toBe(200);
diff --git a/server/services/codexAppServer.js b/server/services/codexAppServer.js
index 6584cc63f0..9c0f0844a8 100644
--- a/server/services/codexAppServer.js
+++ b/server/services/codexAppServer.js
@@ -73,6 +73,8 @@ const CLIENT_INFO = Object.freeze({ name: 'PortOS', title: 'PortOS', version: '1
let connection = null;
/** Coalesces concurrent connects so one page load cannot spawn two children. */
let connecting = null;
+/** The child being handshaken, before `connect()` can publish it as live. */
+let connectingTarget = null;
/** `{ at, readiness }` — the last successful read. `null` = never probed. */
let readinessCache = null;
/** `{ loginId, startedAt, expiresAt, timer }` for a PortOS-initiated login. */
@@ -108,6 +110,18 @@ const teardown = (target, error) => {
if (connection === target) connection = null;
};
+/** Reject the target and terminate its child unless it already stopped. */
+const stopTarget = (target, error) => {
+ if (!target || target.closed) return;
+ teardown(target, error);
+ if (target.child.killed) return;
+ try {
+ target.child.kill('SIGTERM');
+ } catch (err) {
+ console.error(`❌ Failed to stop Codex app-server: ${err.message}`);
+ }
+};
+
/** Settle a pending login once, clearing its deadline. */
const settleLogin = (reason) => {
if (!pendingLogin) return;
@@ -255,10 +269,19 @@ const openConnection = async () => {
settleLogin('ended because the Codex app-server stopped');
});
- await sendRequest(target, CODEX_RPC.initialize, { clientInfo: CLIENT_INFO }, HANDSHAKE_TIMEOUT_MS);
- await sendNotification(target, CODEX_RPC.initialized, {});
- console.log('🔌 Codex app-server connected');
- return target;
+ connectingTarget = target;
+ try {
+ await sendRequest(target, CODEX_RPC.initialize, { clientInfo: CLIENT_INFO }, HANDSHAKE_TIMEOUT_MS);
+ await sendNotification(target, CODEX_RPC.initialized, {});
+ console.log('🔌 Codex app-server connected');
+ return target;
+ } catch (err) {
+ // A handshake timeout/rejection happens before `connect()` can publish the
+ // target in `connection`; clean up here so the child cannot become an
+ // orphan that later account checks cannot see or stop.
+ stopTarget(target, err);
+ throw err;
+ }
};
/** The live connection, opening one if needed. One connect in flight at a time. */
@@ -267,7 +290,7 @@ const connect = async () => {
if (!connecting) {
connecting = openConnection()
.then((target) => { connection = target; return target; })
- .finally(() => { connecting = null; });
+ .finally(() => { connecting = null; connectingTarget = null; });
}
return connecting;
};
@@ -446,11 +469,10 @@ export async function codexLogout() {
export async function stopCodexAppServer() {
settleLogin(null);
readinessCache = null;
- const target = connection;
+ const target = connection || connectingTarget;
connection = null;
if (!target || target.closed) return;
- teardown(target, codexError(CODEX_ERROR_CODES.exited, 'PortOS is shutting down the Codex app-server.'));
- target.child.kill('SIGTERM');
+ stopTarget(target, codexError(CODEX_ERROR_CODES.exited, 'PortOS is shutting down the Codex app-server.'));
console.log('🔌 Codex app-server stopped');
}
@@ -461,4 +483,5 @@ export function __resetCodexAppServer() {
readinessCache = null;
connection = null;
connecting = null;
+ connectingTarget = null;
}
diff --git a/server/services/codexAppServer.test.js b/server/services/codexAppServer.test.js
index 74ecce88ac..75f615d088 100644
--- a/server/services/codexAppServer.test.js
+++ b/server/services/codexAppServer.test.js
@@ -356,6 +356,7 @@ describe('failure paths settle exactly once', () => {
expect(readiness.status).toBe(CODEX_ACCOUNT_STATUS.unknown);
expect(readiness.error.code).toBe(CODEX_ERROR_CODES.timeout);
+ expect(child.kill).toHaveBeenCalledWith('SIGTERM');
} finally {
vi.useRealTimers();
}
@@ -386,6 +387,18 @@ describe('failure paths settle exactly once', () => {
expect(peekCodexAccountReadiness()).toBeNull();
});
+ it('terminates a child that is still handshaking when shutdown begins', async () => {
+ const promise = getCodexAccountReadiness();
+ await vi.waitFor(() => expect(child.lastRequest('initialize')).toBeTruthy());
+
+ await stopCodexAppServer();
+
+ const readiness = await promise;
+ expect(readiness.status).toBe(CODEX_ACCOUNT_STATUS.unknown);
+ expect(readiness.error.code).toBe(CODEX_ERROR_CODES.exited);
+ expect(child.kill).toHaveBeenCalledWith('SIGTERM');
+ });
+
it('is a no-op on shutdown when nothing was ever spawned', async () => {
await expect(stopCodexAppServer()).resolves.toBeUndefined();
expect(spawn).not.toHaveBeenCalled();
diff --git a/server/services/userActions.js b/server/services/userActions.js
index 4f5f772113..d9542157d1 100644
--- a/server/services/userActions.js
+++ b/server/services/userActions.js
@@ -207,9 +207,12 @@ export function normalizeUserAction(input = {}) {
/** Clamp list options to the documented bounds. Exported for the route test. */
export function normalizeListOptions(options = {}) {
+ const types = Array.isArray(options.types)
+ ? options.types
+ : (options.types ? [options.types] : []);
const rawTypes = [
...(options.type ? [options.type] : []),
- ...(Array.isArray(options.types) ? options.types : []),
+ ...types,
].filter((value) => typeof value === 'string' && value);
const limit = Number.isFinite(Number(options.limit))
? Math.min(MAX_LIST_LIMIT, Math.max(1, Math.floor(Number(options.limit))))
diff --git a/server/services/userActions.test.js b/server/services/userActions.test.js
index 0dab923a7e..dfea66bf63 100644
--- a/server/services/userActions.test.js
+++ b/server/services/userActions.test.js
@@ -184,6 +184,7 @@ describe('listUserActions', () => {
it('pages with offset and clamps the limit', async () => {
expect((await listUserActions({ limit: 1, offset: 1 })).map((e) => e.dedupeKey)).toEqual(['l2']);
+ expect(normalizeListOptions({ types: 'cos.task.create' }).types).toEqual(['cos.task.create']);
expect(normalizeListOptions({}).limit).toBe(DEFAULT_LIST_LIMIT);
expect(normalizeListOptions({ limit: 5000 }).limit).toBe(MAX_LIST_LIMIT);
expect(normalizeListOptions({ limit: 0 }).limit).toBe(1);