This commit is contained in:
seb
2026-10-07 19:33:26 +02:00
parent ee2056a159
commit 4cc8c49cf1
7 changed files with 152 additions and 49 deletions

View File

@@ -77,6 +77,8 @@ const initialState = {
selectedConversationId: null,
/** First-open draft: no server conversation yet, created on first send. */
draftConversation: false,
/** Prefilled input text waiting to be consumed by the chat UI. */
pendingInput: null,
conversationState: 'idle',
provider: 'openrouter',
model: DEFAULT_MODEL,
@@ -270,6 +272,33 @@ const actions = {
void chatAutomat.actions.loadConversations();
},
/**
* Open the chat drawer with a fresh draft conversation and prefilled prompt.
* @param {string} [prompt='']
*/
openWithPrompt(prompt = '') {
chatOpenedThisSession = true;
closeConversationStream();
chatAutomat.setState({
isOpen: true,
sseEstablished: true,
draftConversation: true,
selectedConversationId: null,
provider: 'openrouter',
model: DEFAULT_MODEL,
messages: [],
conversationState: 'idle',
streamPhase: 'idle',
streamingText: '',
lastUsage: null,
activeTurns: [],
sendError: null,
pendingInput: prompt,
});
ensureCompanyEventsConnected();
void chatAutomat.actions.loadConversations();
},
/**
* Start an implicit new conversation with the first preset model. Nothing is
* created on the server until the first message is sent.