Skip to content

SynthesisContainer

The SynthesisContainer class is responsible for managing the insertion of text into the editor at a specified location and for handling the scrolling of the editor to ensure that the inserted text is visible to the user. It also provides functionality to display a placeholder in the editor and to remove it later.

Methods

addConfirmButton()

addConfirmButton(text, callback): void

Adds a confirm button to the editor. This function generates a unique ID for the button, appends the button to the editor content, and attaches an event listener to the button. When the button is clicked, it prevents the default form submission behavior and executes the provided callback function.

Parameters

ParameterTypeDescription
textstringThe text to be displayed on the button.
callback() => voidThe callback function to be executed when the button is clicked.

Source

render/SynthesisContainer.ts:158


appendText()

appendText(text): void

Appends the given text to the editor and ensures the newly added text is visible. This method wraps the private _appendText method to insert the text, and then calls scrollIntoView on the editor to scroll to the location where the text was added.

Parameters

ParameterTypeDescription
textstringThe text to be appended to the editor content.

Source

render/SynthesisContainer.ts:72


getMessagesToHere()

getMessagesToHere(curLine, curCh): ChatMessageWithMetadata[]

Retrieves all messages up to the specified cursor position.= This function parses the content of the editor up to the specified cursor position and extracts chat messages with metadata. It identifies the role of each message (user or assistant) and extracts the content and metadata for each message. The messages are then returned as an array of ChatCompletionMessage objects.

Parameters

ParameterTypeDescription
curLinenumberThe current line position of the cursor in the editor (defaults to the current line).
curChnumberThe current character position of the cursor in the editor (defaults to the current character).

Returns

An array of chat messages up to the specified cursor position.

Source

render/SynthesisContainer.ts:177


renderMetadata()

renderMetadata(metadata): void

Appends the provided metadata as a hidden div element to the editor. This function takes an array of AssistantMessageMetadata objects and converts it into a JSON string. The JSON string is then wrapped in a div element with a style set to display

, which is appended to the editor content. This allows the metadata to be included in the document without being visible to the user.

Parameters

ParameterTypeDescription
metadataAssistantMessageMetadata[]An array of metadata objects to be appended.

Source

render/SynthesisContainer.ts:142


resetText()

resetText(): void

Resets the text in the editor starting from the line after the end of the code fence. It replaces the range of text from the specified starting point to the current cursor position with a new line, a prompt indicator, and a space. This is typically used to clear the editor content and prepare it for new input or messages.

Source

render/SynthesisContainer.ts:119


waitPlaceholder()

waitPlaceholder(placeholder): () => void

Displays a placeholder in the editor and returns a function to remove it. This method inserts a temporary placeholder string into the editor at the current cursor position. The placeholder is styled to pulsate, indicating an ongoing process. The method returns a cleanup function that, when called, removes the placeholder from the editor.

Parameters

ParameterTypeDescription
placeholderstringThe text to be displayed as a placeholder.

Returns

A function that removes the placeholder from the editor when called.

(): void
Source

render/SynthesisContainer.ts:98

Source

render/SynthesisContainer.ts:92


Generated using typedoc-plugin-markdown and TypeDoc