Theia API Documentation v1.69.0
    Preparing search index...

    Service for registering and resolving pending image attachments.

    When images are pasted or dropped into the chat input, they are registered here with a short ID. The short ID can be used in the text input (e.g., #imageContext:img_1) while the actual base64 data is stored in this registry.

    This allows:

    • The hover provider to look up image data for previews
    • The variable resolver to expand short IDs to full image data when sending
    • Proper scoping by model ID so multiple chat inputs don't interfere
    interface PendingImageRegistry {
        clearScope(scopeUri: string): void;
        generateShortId(baseName: string, scopeUri: string): string;
        get(scopeUri: string, shortId: string): undefined | PendingImageData;
        getAllForScope(scopeUri: string): ReadonlyMap<string, PendingImageData>;
        getByShortId(shortId: string): undefined | PendingImageData;
        getModelIdForEditor(editorUri: string): undefined | string;
        getScopeUriForModel(modelId: string): string;
        isShortId(arg: string): boolean;
        register(
            scopeUri: string,
            shortId: string,
            imageVariable: ImageContextVariable,
            fullArg: string,
        ): Disposable;
        registerEditorMapping(editorUri: string, modelId: string): Disposable;
    }

    Implemented by

    Index

    Methods

    • Generate a unique short ID for a pending image based on a base name. For dropped files, use the basename (e.g., "photo.png"). For pasted images, use "pasted_image". If duplicates exist, a numeric suffix is added (e.g., "photo_2.png", "pasted_image_2").

      Parameters

      • baseName: string

        The base name to use for the short ID

      • scopeUri: string

        The scope URI to check for duplicates

      Returns string

      A unique short ID within the given scope

    • Get the model ID for an editor URI.

      Parameters

      • editorUri: string

        The editor URI

      Returns undefined | string

      The model ID if registered, undefined otherwise

    • Construct a scope URI from a chat model ID.

      Parameters

      • modelId: string

        The chat model ID

      Returns string

      The scope URI that would be used for this model

    • Check if a short ID looks like a pending image reference.

      Parameters

      • arg: string

        The argument string to check

      Returns boolean

      True if it matches the short ID pattern

    • Register a pending image for a given scope (typically editor URI).

      Parameters

      • scopeUri: string

        The URI identifying the scope (e.g., editor URI)

      • shortId: string

        The short ID to use for this image (e.g., "img_1")

      • imageVariable: ImageContextVariable

        The parsed image variable data

      • fullArg: string

        The full JSON argument string

      Returns Disposable

      A disposable that unregisters this specific image

    • Register a mapping from editor URI to chat model ID. This allows the hover provider to look up the model ID from the editor URI.

      Parameters

      • editorUri: string

        The editor URI

      • modelId: string

        The chat model ID

      Returns Disposable

      A disposable that unregisters the mapping