Reordered pi prefill extension to check event.reason before consuming env var; appended shell unset/clear for ORCA_PI_PREFILL after pi exits to avoid stale prefill on rerun. Findings addressed: - src/main/pi/titlebar-extension-service.ts:36-46 — Prefill env var consumed before reason check — may silently drop prefill - src/main/pi/titlebar-extension-service.ts:30-46 — ORCA_PI_PREFILL still set in shell env after pi exits Rebased onto current main. Co-authored-by: orca-bot <bot@stably.ai>
This commit is contained in:
co-authored by
orca-bot
parent
ba034c3c3d
commit
74159b43d1
@@ -44,10 +44,10 @@ function getPiPrefillExtensionSource(): string {
|
||||
return [
|
||||
'export default function (pi) {',
|
||||
" pi.on('session_start', async (event, ctx) => {",
|
||||
" if (event.reason !== 'startup') return",
|
||||
` const prefill = process.env.${ORCA_PI_PREFILL_ENV_VAR}`,
|
||||
' if (!prefill) return',
|
||||
` delete process.env.${ORCA_PI_PREFILL_ENV_VAR}`,
|
||||
" if (event.reason !== 'startup') return",
|
||||
' try {',
|
||||
' ctx.ui.setEditorText(prefill)',
|
||||
' } catch {}',
|
||||
|
||||
@@ -188,7 +188,7 @@ describe('buildAgentDraftLaunchPlan', () => {
|
||||
})
|
||||
).toEqual({
|
||||
agent: 'pi',
|
||||
launchCommand: 'pi',
|
||||
launchCommand: 'pi; unset ORCA_PI_PREFILL',
|
||||
expectedProcess: 'pi',
|
||||
env: { ORCA_PI_PREFILL: 'https://github.com/acme/repo/issues/42' }
|
||||
})
|
||||
|
||||
@@ -153,9 +153,16 @@ export function buildAgentDraftLaunchPlan(args: {
|
||||
// Why: the env var is set on the PTY-spawn env (not embedded in the
|
||||
// shell command) so the value never has to be shell-escaped and the
|
||||
// user doesn't see a `FOO='...'` prefix typed into their terminal.
|
||||
// Append a clear-var command so the var is unset from the shell env
|
||||
// once the agent exits — otherwise re-running the agent in the same
|
||||
// terminal would inherit the stale value and re-prefill with the old URL.
|
||||
const clearVar =
|
||||
platform === 'win32'
|
||||
? `set "${config.draftPromptEnvVar}="`
|
||||
: `unset ${config.draftPromptEnvVar}`
|
||||
return {
|
||||
agent,
|
||||
launchCommand: baseCommand,
|
||||
launchCommand: `${baseCommand}; ${clearVar}`,
|
||||
expectedProcess: config.expectedProcess,
|
||||
env: { [config.draftPromptEnvVar]: trimmed }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user