Interface AssistSession
- All Superinterfaces:
AutoCloseable
One live AI-assist session. Holds the embedded chat panel, the underlying agentic harness, and
any per-session resources (e.g. a conversation log writer) that must be released when the session
ends. Hosts obtain sessions through
DesignerAiContext.assistant(); AssistAction
mounts popup-shaped ones and listens for the onApplied(Runnable) and onCloseRequested(Runnable) signals to know when to hide.
Sessions are EDT-only. close() is idempotent and safe to call from popup-hide
listeners. The AutoCloseable contract lets hosts that mount sessions outside a popup wrap
the lifecycle in try-with.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the conversation log and releases per-session resources.voidMoves keyboard focus to the session's prompt input.voidRegister a callback fired after the session's reply renderer successfully applies a suggestion back to the host.voidonCloseRequested(Runnable listener) Register a callback fired when the embedded panel requests dismissal — the user clicks the × button in the panel's header, or hits Esc.
-
Method Details
-
component
JComponent component()- Returns:
- the Swing component to mount. The same instance is returned every call. Stable for the lifetime of the session.
-
focusPrompt
void focusPrompt()Moves keyboard focus to the session's prompt input. Hosts call this when their mounted surface is re-activated: the popup mount uses it when the user re-triggers the action while the popup is already showing, so the embed is typable again without hunting for the text area.EDT only. Does nothing when the component is not currently displayable.
-
onApplied
Register a callback fired after the session's reply renderer successfully applies a suggestion back to the host. The popup-mounting trigger uses this to dismiss its popup; an inline host (no popup) is free to ignore it.Listeners fire in registration order on the EDT. Adding a listener after the first apply fires it on subsequent applies but does not replay missed ones.
-
onCloseRequested
Register a callback fired when the embedded panel requests dismissal — the user clicks the × button in the panel's header, or hits Esc. The popup-mounting trigger uses this to dismiss its popup.Listeners fire in registration order on the EDT.
-
close
void close()Closes the conversation log and releases per-session resources. Idempotent. Any in-flight request to the model is not cancelled — its result is dropped when it returns.- Specified by:
closein interfaceAutoCloseable
-