-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into issues/14111
- Loading branch information
Showing
67 changed files
with
1,007 additions
and
387 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
examples/api-samples/src/browser/chat/chat-node-toolbar-action-contribution.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2024 STMicroelectronics and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
|
||
import { | ||
ChatNodeToolbarActionContribution | ||
} from '@theia/ai-chat-ui/lib/browser/chat-node-toolbar-action-contribution'; | ||
import { | ||
isResponseNode, | ||
RequestNode, | ||
ResponseNode | ||
} from '@theia/ai-chat-ui/lib/browser/chat-tree-view'; | ||
import { interfaces } from '@theia/core/shared/inversify'; | ||
|
||
export function bindChatNodeToolbarActionContribution(bind: interfaces.Bind): void { | ||
bind(ChatNodeToolbarActionContribution).toDynamicValue(context => ({ | ||
getToolbarActions: (args: RequestNode | ResponseNode) => { | ||
if (isResponseNode(args)) { | ||
return [{ | ||
commandId: 'sample-command', | ||
icon: 'codicon codicon-feedback', | ||
tooltip: 'Example command' | ||
}]; | ||
} else { | ||
return []; | ||
} | ||
} | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
packages/ai-chat-ui/src/browser/chat-node-toolbar-action-contribution.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2024 EclipseSource GmbH. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
import { RequestNode, ResponseNode } from './chat-tree-view'; | ||
|
||
export interface ChatNodeToolbarAction { | ||
/** | ||
* The command to execute when the item is selected. The handler will receive the `RequestNode` or `ResponseNode` as first argument. | ||
*/ | ||
commandId: string; | ||
/** | ||
* Icon class name(s) for the item (e.g. 'codicon codicon-feedback'). | ||
*/ | ||
icon: string; | ||
/** | ||
* Priority among the items. Can be negative. The smaller the number the left-most the item will be placed in the toolbar. It is `0` by default. | ||
*/ | ||
priority?: number; | ||
/** | ||
* Optional tooltip for the item. | ||
*/ | ||
tooltip?: string; | ||
} | ||
|
||
/** | ||
* Clients implement this interface if they want to contribute to the toolbar of chat nodes. | ||
* | ||
* ### Example | ||
* ```ts | ||
* bind(ChatNodeToolbarActionContribution).toDynamicValue(context => ({ | ||
* getToolbarActions: (args: RequestNode | ResponseNode) => { | ||
* if (isResponseNode(args)) { | ||
* return [{ | ||
* commandId: 'core.about', | ||
* icon: 'codicon codicon-feedback', | ||
* tooltip: 'Show about dialog on response nodes' | ||
* }]; | ||
* } else { | ||
* return []; | ||
* } | ||
* } | ||
* })); | ||
* ``` | ||
*/ | ||
export const ChatNodeToolbarActionContribution = Symbol('ChatNodeToolbarActionContribution'); | ||
export interface ChatNodeToolbarActionContribution { | ||
/** | ||
* Returns the toolbar actions for the given node. | ||
*/ | ||
getToolbarActions(node: RequestNode | ResponseNode): ChatNodeToolbarAction[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.