Repository navigation
fix(agent-hooks): route reminted pane keys to canonical identity (STA-3993) - #15714
Conversation
…-3993) Spawn was stripping $$<base32>:L$$ ORCA_PANE_KEY values (and the launch token) instead of rewriting them to the metadata-proven tab:leaf key, so OMP hooks never entered last-status.json and sleeping rows stayed working. Alias that exact remint form onto the canonical pane so later posts still route, and keep unmatched tokens from stamping another pane.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change adds bounded validation for opaque reminted pane keys and applies it to persisted alias normalization. PTY spawning now selects metadata-derived stable keys, preserves launch tokens, restricts pane metadata forwarding for SSH environments, and registers reminted aliases. Agent-hook routing rejects conflicting alias rebinding and preserves canonical completion state. Tests cover validation, persistence, PTY spawning, hook routing, and renderer status settlement. One Codex test receives formatting-only changes. Merge Risk: 🔵 Low · up to This PR routes reminted pane keys to canonical pane identities and preserves those mappings across restart, improving completion-state updates. Mergeability is otherwise good, but unsupported or rejected aliases can remain silent, malformed spawn input can fail during normalization, and conflicting persisted mappings need explicit owner follow-up. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description includes the required sections, explains the problem and solution, links issue Full details: Linked Issues checkExplanation The changes satisfy issue
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Remint tokens have no embedded tab identity, so a later spawn that reused the same $$ token with a different tab/leaf was overwriting the alias and routing leftover hook posts onto the new pane. Refuse destination changes for that form while still allowing same-pane pty id updates.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/renderer/src/store/slices/agent-status-reminted-pane-key.test.ts (1)
60-63: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winState the expected settlement directly.
The compound boolean passes for several different outcomes. If
setAgentStatusdeletes the sleeping record,sleepingisundefinedand the expression isfalse, so the test passes without proving that the record settled todone.Assert the intended end state instead.
♻️ Suggested clearer assertion
- const sleeping = store.getState().sleepingAgentSessionsByPaneKey[PANE] - expect(sleeping?.state === 'working' && sleeping.prompt === 'finish the reminted pane').toBe( - false - ) + const sleeping = store.getState().sleepingAgentSessionsByPaneKey[PANE] + // Why: the live record must settle or be dropped; a retained `working` row is the bug. + expect(sleeping?.state).not.toBe('working')src/main/ipc/pty-restore-record-seeding.test.ts (1)
540-546: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winStrengthen the cross-pane isolation assertion.
The shared
beforeEachresetsregisterPaneKeyAliasMock. Because this test spawns onlytab-2, the negativetab-1assertion passes without testing cross-pane rebinding. Assert the exact alias call set, or spawn both panes in one test and assert that the destination remainstab-1.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9ffbea7b-7178-4ede-9592-0c064b845026
📒 Files selected for processing (9)
src/main/agent-hooks/server-reminted-pane-key.test.tssrc/main/agent-hooks/server.tssrc/main/ipc/pty-restore-record-seeding.test.tssrc/main/ipc/pty.tssrc/main/persistence/restoring-sessions/pane-alias-normalization.test.tssrc/main/persistence/restoring-sessions/pane-alias-normalization.tssrc/renderer/src/store/slices/agent-status-reminted-pane-key.test.tssrc/shared/pane-key-alias.test.tssrc/shared/pane-key-alias.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
| } else if (remintedSpawnPaneKey && validatedPaneKey) { | ||
| // Why: reminted $$ tokens are spawn-physical; alias them to the metadata-proven | ||
| // tab:leaf key so later hooks still route after env is rewritten to canonical. | ||
| agentHookServer.registerPaneKeyAlias( | ||
| remintedSpawnPaneKey, | ||
| validatedPaneKey, | ||
| result.id, | ||
| Date.now(), | ||
| { authorityVerified: true } | ||
| ) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Trace migration-unsupported pane state producers and clear sites.
set -euo pipefail
rg -nP -C 6 'clearMigrationUnsupportedPtysForPaneKey|clearMigrationUnsupportedPty\b|markMigrationUnsupported' --type=tsRepository: stablyai/orca
Length of output: 151
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- candidate files ---'
fd -t f 'pty\.ts$|.*agentHook.*' .
printf '%s\n' '--- relevant symbols and call sites ---'
rg -n -C 5 'clearMigration|UnsupportedPty|migration.?unsupported|registerPaneKeyAlias|remintedSpawnPaneKey|validatedPaneKey' . --glob '*.{ts,tsx,js,jsx}'Repository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- pty.ts target ---'
sed -n '7080,7170p' src/main/ipc/pty.ts
printf '%s\n' '--- pty.ts migration-state references ---'
rg -n -C 8 'clearMigration|markMigration|migrationUnsupported|registerPaneKeyAlias' src/main/ipc/pty.ts
printf '%s\n' '--- migration state module ---'
fd -t f 'migration-unsupported-pty-state\.ts$' srcRepository: stablyai/orca
Length of output: 10874
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- migration state implementation ---'
wc -l src/main/agent-hooks/migration-unsupported-pty-state.ts
cat -n src/main/agent-hooks/migration-unsupported-pty-state.ts
printf '%s\n' '--- alias implementation and callers ---'
rg -n -C 12 'registerPaneKeyAlias\s*[=:]|\bregisterPaneKeyAlias\s*\(' src/main --glob '*.{ts,tsx}'Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- alias guard and registration ---'
sed -n '1640,1775p' src/main/agent-hooks/server.ts
printf '%s\n' '--- reminted collision tests ---'
sed -n '145,180p' src/main/agent-hooks/server-reminted-pane-key.test.tsRepository: stablyai/orca
Length of output: 6162
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- alias resolution ---'
rg -n -C 10 'resolvePaneKeyAlias\s*\(' src/main/agent-hooks/server.ts | head -80
printf '%s\n' '--- deterministic contract probe ---'
python3 - <<'PY'
from pathlib import Path
pty = Path("src/main/ipc/pty.ts").read_text()
server = Path("src/main/agent-hooks/server.ts").read_text()
reminted = pty[pty.index("} else if (remintedSpawnPaneKey && validatedPaneKey)"):pty.index("} else if (validatedPaneKey)", pty.index("} else if (remintedSpawnPaneKey && validatedPaneKey)"))]
print("reminted_clears_destination:", "clearMigrationUnsupportedPtysForPaneKey(validatedPaneKey)" in reminted)
print("collision_guard_present:", "existing.stablePaneKey !== toPaneKey && isOpaqueRemintedPaneKey(fromPaneKey)" in server)
print("collision_guard_returns:", "if (existing && existing.stablePaneKey !== toPaneKey && isOpaqueRemintedPaneKey(fromPaneKey)) {\n return" in server)
# Reproduce the alias guard's observable mapping for a reminted collision.
aliases = {"$$same": "tab-a:leaf-a"}
incoming = ("$$same", "tab-b:leaf-b")
if incoming[0] in aliases and aliases[incoming[0]] != incoming[1]:
accepted = False
routed_destination = aliases[incoming[0]]
else:
accepted = True
aliases[incoming[0]] = incoming[1]
routed_destination = aliases[incoming[0]]
print("collision_alias_accepted:", accepted)
print("collision_hook_destination:", routed_destination)
PYRepository: stablyai/orca
Length of output: 3803
Clear migration-unsupported state for reminted spawns. When remintedSpawnPaneKey && validatedPaneKey, call clearMigrationUnsupportedPtysForPaneKey(validatedPaneKey) after registering the alias. Otherwise, stale entries from earlier legacy PTYs remain visible for the pane. The alias collision path intentionally keeps the existing mapping; it does not leave hooks unroutable.
Electron visual proof (worktree
|
Review status (
|
Electron CDP validation (
|
Final preparation status
|
…-reminted-pane-key # Conflicts: # src/main/ipc/pty.ts
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Greptile SummaryThe PR routes opaque reminted pane keys to metadata-proven canonical pane identities across spawn, hook ingestion, and persisted restoration.
Confidence Score: 4/5The PR is not yet safe to merge because restart restoration can still rebind a reused remint token to a later pane. Live registration preserves the first destination, but persisted duplicate aliases are merged by newest timestamp, so a restart can route leftover hook posts to the wrong pane and leave the original pane stale. Files Needing Attention: src/main/persistence/restoring-sessions/pane-alias-normalization.ts and pane-alias-normalization.test.ts
|
| Filename | Overview |
|---|---|
| src/shared/pane-key-alias.ts | Defines the bounded exact remint-token validator and valid alias source-to-destination combinations. |
| src/main/ipc/pty/ipc/spawn-env.ts | Derives canonical pane identity from validated spawn metadata and rewrites forwarded pane environment values. |
| src/main/ipc/pty/ipc/spawn-commit.ts | Registers reminted physical keys as aliases of the canonical pane after a successful PTY spawn. |
| src/main/agent-hooks/server.ts | Extends alias registration to reminted keys while preventing a live alias from changing destinations. |
| src/main/persistence/restoring-sessions/pane-alias-normalization.ts | Extends persisted normalization and registration to accept reminted aliases. |
| src/main/persistence/restoring-sessions/pane-alias-normalization.test.ts | Covers persisted remint normalization and duplicate-row merge behavior. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[PTY spawn with reminted key] --> B[Metadata-proven canonical pane key]
B --> C[Register exact remint alias]
C --> D[Provider hook posts reminted key]
D --> E[Hook server resolves canonical pane]
E --> F[Renderer receives updated agent status]
C --> G[Persist alias]
G --> H[Restore aliases after restart]
Reviews (4): Last reviewed commit: "fix(ssh): keep pane identity env strippe..." | Re-trigger Greptile
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2487feae-1a0d-406b-970a-55ba1571dd80
📒 Files selected for processing (12)
src/main/agent-hooks/server-reminted-pane-key.test.tssrc/main/agent-hooks/server.tssrc/main/codex/codex-index-heal-binary-contract.test.tssrc/main/ipc/pty-restore-record-seeding.test.tssrc/main/ipc/pty/ipc/spawn-commit.tssrc/main/ipc/pty/ipc/spawn-env.tssrc/main/ipc/pty/ipc/spawn-state.tssrc/main/persistence/restoring-sessions/pane-alias-normalization.test.tssrc/main/persistence/restoring-sessions/pane-alias-normalization.tssrc/renderer/src/store/slices/agent-status-reminted-pane-key.test.tssrc/shared/pane-key-alias.test.tssrc/shared/pane-key-alias.ts
🚧 Files skipped from review as they are similar to previous changes (8)
- src/shared/pane-key-alias.test.ts
- src/main/ipc/pty-restore-record-seeding.test.ts
- src/main/persistence/restoring-sessions/pane-alias-normalization.test.ts
- src/main/persistence/restoring-sessions/pane-alias-normalization.ts
- src/renderer/src/store/slices/agent-status-reminted-pane-key.test.ts
- src/shared/pane-key-alias.ts
- src/main/agent-hooks/server.ts
- src/main/agent-hooks/server-reminted-pane-key.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| } else if (ctx.opaqueRemintedSpawnPaneKey && ctx.validatedPaneKey) { | ||
| // Reminted $$ tokens are spawn-physical; alias them to the metadata-proven tab:leaf key. | ||
| agentHookServer.registerPaneKeyAlias( | ||
| ctx.opaqueRemintedSpawnPaneKey, | ||
| ctx.validatedPaneKey, | ||
| ctx.result.id, | ||
| Date.now(), | ||
| { authorityVerified: true } | ||
| ) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
printf '%s\n' '--- repository knowledge scopes ---'
find /tmp/coderabbit-repo-knowledge/stablyai/orca-89dc44e4 \
-maxdepth 2 -type f \( -path '*/repository_conventions/*' -o -path '*/architecture/*' -o -path '*/learnings/*' \) -print 2>/dev/null | sort
printf '%s\n' '--- target file outline ---'
ast-grep outline src/main/ipc/pty/ipc/spawn-commit.ts
printf '%s\n' '--- target file ---'
sed -n '1,230p' src/main/ipc/pty/ipc/spawn-commit.ts
printf '%s\n' '--- directly bound symbols and callers ---'
rg -n -A8 -B8 \
'commitPtyIpcSpawn|registerPaneKeyAlias|opaqueRemintedSpawnPaneKey|before_agent_start|agent_end|spawn-commit' \
src/main/ipc/pty src/main | head -400Repository: stablyai/orca
Length of output: 46473
🏁 Script executed:
printf '%s\n' '--- repository knowledge files ---'
find /tmp/coderabbit-repo-knowledge -maxdepth 4 -type f -print 2>/dev/null | sort | head -100
printf '%s\n' '--- spawn execution path ---'
sed -n '1,240p' src/main/ipc/pty/ipc/spawn-execute.ts
sed -n '1,120p' src/main/ipc/pty/ipc/spawn-run.ts
printf '%s\n' '--- hook server implementation ---'
fd -i 'server' src/main/agent-hooks src/main | head -30
rg -n -A18 -B12 \
'registerPaneKeyAlias|resolve.*PaneKey|before_agent_start|agent_end|post.*hook|hook.*event' \
src/main/agent-hooks src/main/pi | head -500
printf '%s\n' '--- spawn preparation and pane-key derivation ---'
sed -n '1,130p' src/main/ipc/pty/ipc/spawn-env.ts
sed -n '1,180p' src/main/ipc/pty/ipc/spawn-state.tsRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
printf '%s\n' '--- AgentHookServer binding ---'
rg -l 'class AgentHookServer|export const agentHookServer|registerPaneKeyAlias' src/main/agent-hooks
rg -n -A35 -B15 'registerPaneKeyAlias|resolvePaneKey|ingestRemote|handle.*Hook|hook_event_name' \
src/main/agent-hooks/server.ts src/main/agent-hooks/*.ts 2>/dev/null | head -350
printf '%s\n' '--- stable-pane provider spawn binding ---'
rg -n -A45 -B20 'function spawnForStablePane|spawnForStablePane|provider\.spawn|spawn\(' \
src/main/ipc/pty/pane src/main/providers src/main/ipc/pty | head -350
printf '%s\n' '--- hook environment and reminted-key consumers ---'
rg -n -A25 -B15 'opaqueRemintedSpawnPaneKey|ORCA_AGENT_HOOK|spawnPaneKey|paneKey' \
src/main/ipc/pty/ipc/spawn-env.ts src/main/agent-hooks src/main/providers | head -400
printf '%s\n' '--- applicable conventions and learning ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/src-main-pty.md \
/tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/src-main-ipc.md \
/tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/src-main-pty.md \
/tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/src-main-ipc.md 2>/dev/nullRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
printf '%s\n' '--- AgentHookServer declarations ---'
rg -n \
'class AgentHookServer|registerPaneKeyAlias|alias|ingestRemote|normalizeHookPayload|handleHook|paneKey' \
src/main/agent-hooks/server.ts | head -180
printf '%s\n' '--- AgentHookServer relevant source ---'
sed -n '1,220p' src/main/agent-hooks/server.ts
sed -n '220,500p' src/main/agent-hooks/server.ts
sed -n '500,820p' src/main/agent-hooks/server.ts
printf '%s\n' '--- spawn hook setup before provider.spawn ---'
rg -n -A20 -B20 \
'buildPtyEnv|buildPtyOptions|spawnOptions|onPtySpawnCommitted|ensureWslHookRelayForReattach|agentHookServer' \
src/main/ipc/pty/ipc/spawn-env.ts \
src/main/ipc/pty/ipc/spawn-options.ts \
src/main/ipc/pty/ipc/spawn-execute.ts \
src/main/providers | head -350Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
printf '%s\n' '--- alias registration and resolution ---'
sed -n '1740,1845p' src/main/agent-hooks/server.ts
sed -n '2110,2275p' src/main/agent-hooks/server.ts
printf '%s\n' '--- hook HTTP/remote ingress callers ---'
rg -n 'ingestRemote|ingestLocal|applyNormalizedStatus|normalizeLocal|handleRequest|buildPtyEnv' \
src/main/agent-hooks/server.ts src/main/agent-hooks/*.ts | grep -v '\.test\.ts' | head -120
sed -n '2275,2470p' src/main/agent-hooks/server.ts
printf '%s\n' '--- complete pane-key preparation and hook environment assembly ---'
sed -n '1,115p' src/main/ipc/pty/ipc/spawn-env.ts
rg -n -A30 -B15 'buildPtyEnv|ORCA_AGENT_HOOK_PANE|ORCA_AGENT_HOOK|paneKey' \
src/main/agent-hooks/server.ts src/main/ipc/pty src/main/providers | grep -v '\.test\.ts' | head -260Repository: stablyai/orca
Length of output: 47602
🏁 Script executed:
printf '%s\n' '--- alias registration body and status disposition ---'
sed -n '1820,1965p' src/main/agent-hooks/server.ts
sed -n '1160,1260p' src/main/agent-hooks/server.ts
sed -n '1420,1475p' src/main/agent-hooks/server.ts
printf '%s\n' '--- ingress paths before and after alias resolution ---'
sed -n '2285,2325p' src/main/agent-hooks/server.ts
sed -n '2580,2665p' src/main/agent-hooks/server.ts
printf '%s\n' '--- opaque-key and stable-key contracts ---'
cat src/shared/pane-key-alias.ts
rg -n -A25 -B10 'function parsePaneKey|export function parsePaneKey|parseValidPaneKey' \
src/shared/stable-pane-id.ts src/main/ipc/pty/pane/key-state.ts
printf '%s\n' '--- existing reminted-key regression coverage ---'
sed -n '1,260p' src/main/agent-hooks/server-reminted-pane-key.test.tsRepository: stablyai/orca
Length of output: 32033
🏁 Script executed:
printf '%s\n' '--- local provider spawn contract ---'
rg -n -A35 -B15 'async spawn|spawn\(options|buildSpawnEnv|onPtySpawnCommitted' \
src/main/providers/local-pty-provider.ts src/main/providers/types.ts | head -260
printf '%s\n' '--- spawn environment handoff ---'
sed -n '100,230p' src/main/ipc/pty/ipc/spawn-env.ts
sed -n '45,115p' src/main/ipc/pty/ipc/spawn-options.ts
printf '%s\n' '--- canonical hook normalizer pane-key validation ---'
rg -n -A35 -B15 'paneKey.*parsePaneKey|parsePaneKey.*paneKey|normalizeHookPayload' \
src/shared/agent-hook-listener src/shared/agent-hook-listener.ts | head -260Repository: stablyai/orca
Length of output: 13726
🏁 Script executed:
printf '%s\n' '--- full environment assembly after pane-key selection ---'
sed -n '1,260p' src/main/ipc/pty/ipc/spawn-env.ts
sed -n '1,220p' src/main/ipc/pty/ipc/spawn-env-codex.ts
printf '%s\n' '--- all production writes and reads of ORCA_PANE_KEY ---'
rg -n -A12 -B12 'ORCA_PANE_KEY' src/main src/shared | grep -v '\.test\.ts' | head -320
printf '%s\n' '--- provider spawn implementations ---'
rg -l 'class .*PtyProvider|spawn\(.*Pty|async spawn' src/main/providers | head -40
rg -n -A30 -B15 'ORCA_PANE_KEY|buildSpawnEnv|async spawn|spawn =|spawn\(' \
src/main/providers/local-pty-provider.ts \
src/main/providers/daemon-pty-provider.ts \
src/main/providers/ssh-pty-provider.ts \
src/main/providers | grep -v '\.test\.ts' | head -420Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
printf '%s\n' '--- final spawn-option and local-spawn environment binding ---'
rg -l 'function spawnLocalPty|spawnLocalPty|buildSpawnEnv' src/main/providers src/main/ipc/pty | head -40
rg -n -A45 -B20 'function spawnLocalPty|spawnLocalPty|buildSpawnEnv' \
src/main/providers src/main/ipc/pty | grep -v '\.test\.ts' | head -320
printf '%s\n' '--- commit persistence and spawn-commit callbacks ---'
sed -n '1,280p' src/main/ipc/pty/ipc/spawn-commit-persist.ts
rg -n -A20 -B20 'onPtySpawnCommitted|registerPaneKeyAlias|opaqueRemintedSpawnPaneKey' \
src/main/ipc/pty src/main/providers | grep -v '\.test\.ts' | head -260Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
printf '%s\n' '--- exact IPC spawn environment field handoff ---'
rg -n -A8 -B8 'spawnEnv\s*=|ctx\.spawnEnv|env:\s*ctx\.env|env:\s*ctx\.baseEnv' \
src/main/ipc/pty/ipc src/main/ipc/pty/runtime | head -220
printf '%s\n' '--- local reattach behavior ---'
sed -n '1,115p' src/main/providers/local-pty-spawn.ts
rg -n -A35 -B15 'function reattachLocalPty|export function reattachLocalPty' \
src/main/providers src/main | head -120
printf '%s\n' '--- remote reattach path around provider spawn ---'
rg -n -A45 -B20 'reattachSshPtySessionForSpawn|attachOnly|spawn.*sessionId' \
src/main/providers src/main/ssh | grep -v '\.test\.ts' | head -280Repository: stablyai/orca
Length of output: 40773
Install the reminted pane-key alias before reattach hooks can arrive.
When an existing PTY still uses ctx.opaqueRemintedSpawnPaneKey, provider.spawn can reattach it before commitPtyIpcSpawn registers the alias. parseHookEnvelope then drops early before_agent_start or agent_end events because the opaque key is not a valid canonical pane key. Add a reattach regression and install the alias before the provider reattach path. Fresh spawns already rewrite ORCA_PANE_KEY to ctx.stablePaneKey.
| ? makePaneKey(args.tabId, ctx.metadataLeafId) | ||
| : null | ||
| ctx.legacySpawnPaneKey = verifiedPaneKey ? null : parseLegacyNumericPaneKey(spawnPaneKey) | ||
| const normalizedSpawnPaneKey = spawnPaneKey?.trim() ?? '' |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
printf '%s\n' '--- scoped knowledge files ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- knowledge headers ---'
for f in /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/*/*.md; do
[ -f "$f" ] && { printf '\n### %s\n' "$f"; head -5 "$f"; }
done
printf '%s\n' '--- target file map ---'
ast-grep outline src/main/ipc/pty/ipc/spawn-env.ts
printf '%s\n' '--- target source ---'
cat -n src/main/ipc/pty/ipc/spawn-env.ts
printf '%s\n' '--- direct references ---'
rg -n -C 3 'spawnPaneKey|ORCA_PANE_KEY|spawn-env' src/main/ipc/ptyRepository: stablyai/orca
Length of output: 29072
🏁 Script executed:
printf '%s\n' '--- state and spawn flow symbols ---'
rg -n -C 6 'interface PtyIpcSpawnState|type PtyIpcSpawnState|args:.*Pty|pty:spawn|assemblePtyIpcSpawnEnv|env:' src/main/ipc/pty/ipc src/main/ipc/pty
printf '%s\n' '--- pane-key parser definitions ---'
rg -n -C 8 'function parseValidPaneKey|const parseValidPaneKey|export .*parseValidPaneKey|function parseLegacyNumericPaneKey|export .*parseLegacyNumericPaneKey' src/shared src/main
printf '%s\n' '--- liveness contract ---'
cat -n src/main/ipc/pty/provider/liveness.ts
printf '%s\n' '--- relevant convention and learning ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/src.md
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings/src-main-ipc.mdRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
printf '%s\n' '--- PtySpawnIpcArgs definition ---'
sed -n '1,80p' src/main/ipc/pty/ipc/spawn-types.ts
printf '%s\n' '--- IPC registration ---'
cat -n src/main/ipc/pty/ipc/spawn.ts
printf '%s\n' '--- parser definitions ---'
rg -n 'parseValidPaneKey|parseLegacyNumericPaneKey' src/main/ipc/pty/pane src/shared
sed -n '1,180p' src/main/ipc/pty/pane/key-state.ts
printf '%s\n' '--- liveness implementation ---'
sed -n '20,45p' src/main/ipc/pty/provider/liveness.tsRepository: stablyai/orca
Length of output: 7754
Guard spawnPaneKey before calling .trim().
If ORCA_PANE_KEY contains a non-string value, spawnPaneKey?.trim() can throw TypeError and abort PTY spawning. Use a type check before trimming and add a wrong-shaped input test.
|
Conflict resolution and review complete.
The PR remains open; hosted checks are still settling. |
…-3993) (stablyai#15714) * fix(agent-hooks): route reminted pane keys to canonical identity (STA-3993) Spawn was stripping $$<base32>:L$$ ORCA_PANE_KEY values (and the launch token) instead of rewriting them to the metadata-proven tab:leaf key, so OMP hooks never entered last-status.json and sleeping rows stayed working. Alias that exact remint form onto the canonical pane so later posts still route, and keep unmatched tokens from stamping another pane. * fix(agent-hooks): keep reminted pane-key aliases first-pane-wins Remint tokens have no embedded tab identity, so a later spawn that reused the same $$ token with a different tab/leaf was overwriting the alias and routing leftover hook posts onto the new pane. Refuse destination changes for that form while still allowing same-pane pty id updates. * fix(agent-hooks): keep pane alias limit import valid after refactor * fix(agent-hooks): bound pane alias destination keys * fix(ssh): keep pane identity env stripped when hooks disabled --------- Co-authored-by: Merge Sim <sim@local>






ELI5
Some OMP panes never reported done because their
ORCA_PANE_KEYwas a reminted$$<hash>:L$$token instead oftabId:leafUuid. The hook pipeline dropped those posts, so the sidebar stayed on Working. Spawn now rewrites that exact remint form to the pane's proventabId:leafUuidkey, and the hook server aliases the remint token to that same pane — not to a neighbor.What Changed
ORCA_PANE_KEYfrom proven tab+leaf metadata when the env value is a reminted$$<base32>:L$$token (or otherwise not the canonical key). The launch token is no longer stripped on that path.tab:0keys.$$token with a different tab/leaf cannot rebind leftover posts onto the new pane. Same-pane pty-id updates still work.Why
normalizeHookPayloadonly acceptsparsePaneKey()(<tabId>:<leafUuid>).registerPaneKeyAliaspreviously accepted only same-tab numeric keys, so a reminted$$…:L$$post was unroutable and last-status never gained a row. The sleeping session then stayed atstate: workingfrom the live title snapshot.#15658 covers a different OMP stuck-working path (
willContinue/ nested OSC133;D). This PR is only the reminted-key path.Linked Issue
Fixes #14018
Fixes STA-3993
Visual Proof
Not a layout change. The user-visible effect is the existing sidebar Working indicator settling after a completed OMP turn on a reminted-key pane. Full-window CDP captures from this branch (
bd031da06e) are on the PR (idle empty-state and sidebar + Terminal 1). A reminted$$key was not faked in the live app.Testing
TDD:
$$…:L$$ingest produced an empty snapshot; spawn envORCA_PANE_KEYwas stripped (undefined)registerPaneKeyAliaslegacy-only; metadata pane-key fallback removed)Also:
pnpm typecheckpassed.oxlint --deny-warningsandoxfmton changed files only — clean.Windows 11 high spec (low spec unreachable this session): four remint suites 21/21 pass; a live ConPTY child showed canonical
tab:leafORCA_PANE_KEY. Opaque$$remint env propagation on ConPTY remains unvalidated — we did not observe a reminted token in a live Windows child.Review
$$<base32>:L$$→ one canonical pane). A foreign remint token still cannot stamp another pane. After first bind, a remint token cannot be rebound onto a different pane. A parseable UUID from another pane is overwritten with this spawn's metadata key, not aliased.pty:spawnmetadata path.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author
Out of scope
willContinue/ nested-shell OSC133;Dretiring launch authority. Complementary, not this remint-key hole.