Repository navigation
[Feature request] Authoritative foreground-session change hook for terminal integrations, including warm resume #5279
Description
Problem
Terminal integrations need to associate a pane with the currently foreground
root conversation, rather than the last conversation that submitted a prompt.
Command sessionStart hooks do not appear to provide a complete foreground-change
stream when switching between already-loaded sessions.
Isolated observation
Tested Copilot CLI 1.0.105 on Linux, using an empty disposable project, separate
HOME/COPILOT_HOME/XDG_CONFIG_HOME, user-level command hooks for sessionStart,
sessionEnd and userPromptSubmitted, normal folder consent and Manual Approval.
No auto-approval, production hooks or existing conversations were used.
- Start the interactive CLI and submit a synthetic prompt in session A.
ObservesessionStart(A, source=new)anduserPromptSubmitted(A). - Run
/newand submit another synthetic prompt in B.
ObservesessionStart(B, source=new)anduserPromptSubmitted(B). - Run
/resume <A-id>, then/session idto independently confirm A is foreground. - Repeat
/resume <B-id>,/session id, then/resume <A-id>,/session id.
Across these warm A-B-A switches, there were no additional Start, End or
Prompt hook invocations within the bounded 5-8 second observation windows.
A file written only by Start hooks would still identify B while A is displayed.
New idle conversations likewise produced no Start until the first submitted
prompt in this run.
A same-version /restart changed the observed CLI owner PID/start identity.
After restart, the first submitted prompt emitted Start with source=resume.
This was not a cross-version handoff test.
Limitation: model requests were rejected by account billing-entity
configuration, so this observation does not establish successful-completion,
subagent, background-model or all-platform behavior. The foreground switches,
session IDs and hook events were nevertheless observed independently. Please
confirm whether this limitation affects the intended lifecycle contract.
Requested capability
Please provide or document one supported identity-only integration surface:
- A complete, causally serialized foreground-session-changed event covering
warm switches, startup, new/clear/no-current transitions, with ordering and
failure/supersession semantics; or - A read-only authenticated accessor for current root identity (or no-current),
resolved session-store location and an activation revision/conditional-current
operation suitable for safely publishing asynchronous identity records.
An equivalent supported in-process integration would also work. Explicit revision
fields are not essential if the API guarantees complete serialized publication.
Session-only snapshots or hook-arrival counters alone do not establish that
delayed work still belongs to the current activation, particularly A-B-A.
This is not a request for tool approval, busy/idle authority, a heartbeat service,
or access to transcript contents. The goal is to stop relying on diagnostic log
registration lines to identify the displayed conversation.
Related but different: #4365 discusses prompt-hook/new/clear behavior; this request
concerns command-hook coverage of warm foreground switches.
Activity