Files
orca/src/shared/pane-key-alias.test.ts
T
Brennan BensonandMerge Sim f2e9ba453c fix(agent-hooks): route reminted pane keys to canonical identity (STA-3993) (#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>
2026-08-30 17:54:13 -07:00

30 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { makePaneKey } from './stable-pane-id'
import { canRegisterPaneKeyAlias, isOpaqueRemintedPaneKey } from './pane-key-alias'
const CANONICAL = makePaneKey('tab-1', '11111111-1111-4111-8111-111111111111')
const REMINTED = '$$MFRGGZDFMY:L$$'
describe('opaque reminted pane keys', () => {
it('accepts the exact $$<base32>:L$$ remint form', () => {
expect(isOpaqueRemintedPaneKey(REMINTED)).toBe(true)
expect(canRegisterPaneKeyAlias(REMINTED, CANONICAL)).toBe(true)
})
it('rejects canonical keys, numeric keys with a different tab, and unmatched tokens', () => {
expect(isOpaqueRemintedPaneKey(CANONICAL)).toBe(false)
expect(canRegisterPaneKeyAlias(CANONICAL, CANONICAL)).toBe(false)
expect(canRegisterPaneKeyAlias('tab-other:0', CANONICAL)).toBe(false)
expect(canRegisterPaneKeyAlias('tab-1:0', CANONICAL)).toBe(true)
expect(canRegisterPaneKeyAlias('$$not-a-token$$', CANONICAL)).toBe(false)
expect(canRegisterPaneKeyAlias('nearest-pane', CANONICAL)).toBe(false)
expect(canRegisterPaneKeyAlias(REMINTED, '$$ONXW2ZJAON:L$$')).toBe(false)
expect(canRegisterPaneKeyAlias(REMINTED, 'tab-1:0')).toBe(false)
})
it('rejects oversized canonical destinations', () => {
const oversizedPane = `${'x'.repeat(180)}:11111111-1111-4111-8111-111111111111`
expect(canRegisterPaneKeyAlias(REMINTED, oversizedPane)).toBe(false)
})
})