Skip to content

The agent that grows with you

fix(desktop): explain missing remote profiles

Yuan Li071842a869d3
diff --git a/apps/desktop/electron/remote-lifecycle.test.ts b/apps/desktop/electron/remote-lifecycle.test.ts
index bdd76274b0e..f97c0a64516 100644
--- a/apps/desktop/electron/remote-lifecycle.test.ts
+++ b/apps/desktop/electron/remote-lifecycle.test.ts
@@ -1088,6 +1088,23 @@ test('scrapeReadyPort reads only the named spawn log', async () => {
assert.ok(ssh.calls.every(call => !call.includes('desktop-ssh.log')))
})
+test('scrapeReadyPort explains a missing remote profile', async () => {
+ const ssh = fakeSsh([[/cat/, "Error: Profile 'operator' does not exist. Create it with: hermes profile create operator\n"]])
+
+ await assert.rejects(
+ () => scrapeReadyPort(ssh, spawnLogPath(OWNERSHIP_ID, SPAWN_NONCE), {
+ timeoutMs: 1000,
+ isAlive: async () => false
+ }),
+ (err: any) => {
+ assert.equal(err.kind, 'remote-profile-missing')
+ assert.match(err.message, /remote Hermes profile 'operator' does not exist/)
+ assert.match(err.message, /hermes profile create operator/)
+ return true
+ }
+ )
+})
+
test('scrapeReadyPort times out and reports a dead spawn', async () => {
// never emits a READY line
const ssh = fakeSsh([[/cat .*\.log/, 'still starting...']])
diff --git a/apps/desktop/electron/remote-lifecycle.ts b/apps/desktop/electron/remote-lifecycle.ts
index b9fdae38823..ff773eee784 100644
--- a/apps/desktop/electron/remote-lifecycle.ts
+++ b/apps/desktop/electron/remote-lifecycle.ts
@@ -1217,6 +1217,22 @@ async function remoteSupportsSshOwnership(ssh, hermesPath) {
.endsWith('YES')
}
+function remoteProfileMissingError(output) {
+ const match = String(output || '').match(/Error: Profile ['\"]([^'\"]+)['\"] does not exist\.?(?: Create it with: ([^\n]+))?/i)
+
+ if (!match) return null
+
+ const profile = match[1]
+ const createCommand = match[2]?.trim()
+ const err: any = new Error(
+ `The remote Hermes profile '${profile}' does not exist. ` +
+ `Select an existing remote profile${createCommand ? ` or create it with: ${createCommand}` : '.'}`
+ )
+ err.kind = 'remote-profile-missing'
+ err.profile = profile
+ return err
+}
+
async function scrapeReadyPort(ssh, logPath, { timeoutMs = resolveReadyTimeoutMs(), isAlive, signal }: any = {}) {
const deadline = Date.now() + timeoutMs
const remoteLog = expandRemotePath(logPath)
@@ -1224,12 +1240,6 @@ async function scrapeReadyPort(ssh, logPath, { timeoutMs = resolveReadyTimeoutMs
while (Date.now() < deadline) {
assertBootstrapNotSuperseded(signal)
- if (isAlive && !(await isAlive())) {
- const err: any = new Error('Remote dashboard process exited before announcing its port.')
- err.kind = 'spawn-failed'
- throw err
- }
-
let tail
try {
@@ -1238,6 +1248,14 @@ async function scrapeReadyPort(ssh, logPath, { timeoutMs = resolveReadyTimeoutMs
tail = ''
}
+ if (isAlive && !(await isAlive())) {
+ const cause = remoteProfileMissingError(tail)
+ if (cause) throw cause
+ const err: any = new Error('Remote dashboard process exited before announcing its port.')
+ err.kind = 'spawn-failed'
+ throw err
+ }
+
const m = READY_RE.exec(String(tail || ''))
if (m) {