* host bridge migration: showErrorMessage & showInformationMessage & showWarningMessage Introduces the `showMessage` host API to the VS Code extension, allowing the host to display informational, warning, and error messages to the user. The changes include: - A new `ShowMessageRequest` and `SelectedResponse` message definition in `proto/host/window.proto` to define the request and response structure for showing messages. - A new file `src/hosts/vscode/window/showMessage.ts` that implements the `showErrorMessage`, `showInformationMessage`, and `showWarningMessage` functions. These functions use the VS Code API to display messages based on the `ShowMessageRequest`. - Replace all current call sites with the new implementations * define the request structure This commit introduces the `showErrorMessage`, `showInformationMessage`, and `showWarningMessage` host APIs to the VS Code extension. These APIs allow the host to display informational, warning, and error messages to the user. The changes include: - Added `ShowErrorMessageRequest`, `ShowInformationMessageRequest`, and `ShowWarningMessageRequest` message definitions in `proto/host/window.proto` to define the request structure for showing messages. - Added new files `src/hosts/vscode/window/showErrorMessage.ts`, `src/hosts/vscode/window/showInformationMessage.ts`, and `src/hosts/vscode/window/showWarningMessage.ts` that implement the corresponding functions. These functions use the VS Code API to display messages based on the provided message and options. * Simplify showMessage functions and use options array The `showErrorMessage`, `showInformationMessage`, and `showWarningMessage` functions in `src/hosts/vscode/window/` have been refactored for simplification. - The functions now directly destructure the `modal`, `detail`, and `items` properties from the input object. - The VS Code API calls now directly pass the `modal` and `detail` options, and use the spread operator to pass the `items.options` array as additional arguments. This removes the need for conditional logic to construct the options object. * wip: apply feedback * Update src/integrations/git/commit-message-generator.ts Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * merge conflict --------- Co-authored-by: abeatrix <beatrix@cline.bot> Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
61 lines
2.1 KiB
TypeScript
61 lines
2.1 KiB
TypeScript
import { Controller } from "../index"
|
|
import * as proto from "@/shared/proto"
|
|
import { updateGlobalState } from "../../storage/state"
|
|
import { TerminalInfo } from "@/integrations/terminal/TerminalRegistry"
|
|
import { getHostBridgeProvider } from "@/hosts/host-providers"
|
|
import { ShowMessageRequest, ShowMessageType } from "@/shared/proto/host/window"
|
|
|
|
export async function updateDefaultTerminalProfile(
|
|
controller: Controller,
|
|
request: proto.cline.StringRequest,
|
|
): Promise<proto.cline.TerminalProfileUpdateResponse> {
|
|
const profileId = request.value
|
|
|
|
// Update the terminal profile in the state
|
|
await updateGlobalState(controller.context, "defaultTerminalProfile", profileId)
|
|
|
|
let closedCount = 0
|
|
let busyTerminals: TerminalInfo[] = []
|
|
|
|
// Update the terminal manager of the current task if it exists
|
|
if (controller.task) {
|
|
// Call the updated setDefaultTerminalProfile method that returns closed terminal info
|
|
const result = controller.task.terminalManager.setDefaultTerminalProfile(profileId)
|
|
closedCount = result.closedCount
|
|
busyTerminals = result.busyTerminals
|
|
|
|
// Show information message if terminals were closed
|
|
if (closedCount > 0) {
|
|
const message = `Closed ${closedCount} ${closedCount === 1 ? "terminal" : "terminals"} with different profile.`
|
|
getHostBridgeProvider().windowClient.showMessage(
|
|
ShowMessageRequest.create({
|
|
type: ShowMessageType.INFORMATION,
|
|
message,
|
|
}),
|
|
)
|
|
}
|
|
|
|
// Show warning if there are busy terminals that couldn't be closed
|
|
if (busyTerminals.length > 0) {
|
|
const message =
|
|
`${busyTerminals.length} busy ${busyTerminals.length === 1 ? "terminal has" : "terminals have"} a different profile. ` +
|
|
`Close ${busyTerminals.length === 1 ? "it" : "them"} to use the new profile for all commands.`
|
|
getHostBridgeProvider().windowClient.showMessage(
|
|
ShowMessageRequest.create({
|
|
type: ShowMessageType.WARNING,
|
|
message,
|
|
}),
|
|
)
|
|
}
|
|
}
|
|
|
|
// Broadcast state update to all webviews
|
|
await controller.postStateToWebview()
|
|
|
|
return proto.cline.TerminalProfileUpdateResponse.create({
|
|
closedCount,
|
|
busyTerminalsCount: busyTerminals.length,
|
|
hasBusyTerminals: busyTerminals.length > 0,
|
|
})
|
|
}
|