Add welcome.html for displaying when no Git repo is open
This commit adds a new welcome.html file to display a message to the user when no Git repository is open. The message informs the user that DevChat is designed for answering questions about Git repositories and asks them to open a Git repository folder to start using DevChat.
This commit is contained in:
parent
0b6d783fb1
commit
0742e54f98
@ -2,7 +2,7 @@
|
|||||||
"name": "devchat",
|
"name": "devchat",
|
||||||
"displayName": "DevChat",
|
"displayName": "DevChat",
|
||||||
"description": "Write prompts, not code",
|
"description": "Write prompts, not code",
|
||||||
"version": "0.0.33",
|
"version": "0.0.34",
|
||||||
"icon": "assets/devchat.png",
|
"icon": "assets/devchat.png",
|
||||||
"publisher": "merico",
|
"publisher": "merico",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
@ -10,6 +10,22 @@ interface LoadHistoryMessages {
|
|||||||
entries: Array<LogEntry>;
|
entries: Array<LogEntry>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function welcomeMessage(): LogEntry {
|
||||||
|
// create default logEntry to show welcome message
|
||||||
|
return {
|
||||||
|
hash: 'message',
|
||||||
|
user: 'system',
|
||||||
|
date: '',
|
||||||
|
request: 'How to use DevChat?',
|
||||||
|
response: `
|
||||||
|
DevChat provides an editing operation method through problem driven development. You can start the journey of using DevChat from the following aspects.
|
||||||
|
1. Right click to select a file or a piece of code to add to DevChat and try asking AI about the file/code.
|
||||||
|
2. Use the+button in DevChat to select a git diff message and try using "/commit_message" command to generate a commit message.
|
||||||
|
`,
|
||||||
|
context: []
|
||||||
|
} as LogEntry;
|
||||||
|
}
|
||||||
|
|
||||||
regInMessage({command: 'historyMessages', options: { skip: 0, maxCount: 0 }});
|
regInMessage({command: 'historyMessages', options: { skip: 0, maxCount: 0 }});
|
||||||
regOutMessage({command: 'loadHistoryMessages', entries: [{hash: '',user: '',date: '',request: '',response: '',context: [{content: '',role: ''}]}]});
|
regOutMessage({command: 'loadHistoryMessages', entries: [{hash: '',user: '',date: '',request: '',response: '',context: [{content: '',role: ''}]}]});
|
||||||
export async function historyMessages(message: any, panel: vscode.WebviewPanel|vscode.WebviewView): Promise<void> {
|
export async function historyMessages(message: any, panel: vscode.WebviewPanel|vscode.WebviewView): Promise<void> {
|
||||||
@ -50,7 +66,7 @@ export async function historyMessages(message: any, panel: vscode.WebviewPanel|v
|
|||||||
|
|
||||||
const loadHistoryMessages: LoadHistoryMessages = {
|
const loadHistoryMessages: LoadHistoryMessages = {
|
||||||
command: 'loadHistoryMessages',
|
command: 'loadHistoryMessages',
|
||||||
entries: logEntriesFlat,
|
entries: logEntries.length>0? logEntriesFlat : [welcomeMessage()],
|
||||||
};
|
};
|
||||||
|
|
||||||
MessageHandler.sendMessage(panel, loadHistoryMessages);
|
MessageHandler.sendMessage(panel, loadHistoryMessages);
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
import * as path from 'path';
|
||||||
import WebviewManager from './webviewManager';
|
import WebviewManager from './webviewManager';
|
||||||
|
|
||||||
import '../handler/loadHandlers';
|
import '../handler/loadHandlers';
|
||||||
import handleMessage from '../handler/messageHandler';
|
import handleMessage from '../handler/messageHandler';
|
||||||
|
import { createChatDirectoryAndCopyInstructionsSync } from '../init/chatConfig';
|
||||||
|
import ExtensionContextHolder from '../util/extensionContext';
|
||||||
|
import CustomCommands from '../command/customCommand';
|
||||||
|
|
||||||
|
|
||||||
export class DevChatViewProvider implements vscode.WebviewViewProvider {
|
export class DevChatViewProvider implements vscode.WebviewViewProvider {
|
||||||
private _view?: vscode.WebviewView;
|
private _view?: vscode.WebviewView;
|
||||||
private _webviewManager: WebviewManager|undefined;
|
private _webviewManager: WebviewManager | undefined;
|
||||||
|
|
||||||
constructor(private readonly _context: vscode.ExtensionContext) {
|
constructor(private readonly _context: vscode.ExtensionContext) {
|
||||||
// Subscribe to the onDidChangeWorkspaceFolders event
|
// Subscribe to the onDidChangeWorkspaceFolders event
|
||||||
@ -19,6 +23,15 @@ export class DevChatViewProvider implements vscode.WebviewViewProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resolveWebviewView(webviewView: vscode.WebviewView, context: vscode.WebviewViewResolveContext, _token: vscode.CancellationToken): void {
|
resolveWebviewView(webviewView: vscode.WebviewView, context: vscode.WebviewViewResolveContext, _token: vscode.CancellationToken): void {
|
||||||
|
// 创建 .chat 目录并复制 workflows
|
||||||
|
createChatDirectoryAndCopyInstructionsSync(ExtensionContextHolder.context?.extensionUri!);
|
||||||
|
|
||||||
|
const workspaceDir = vscode.workspace.workspaceFolders?.[0].uri.fsPath;
|
||||||
|
if (workspaceDir) {
|
||||||
|
const workflowsDir = path.join(workspaceDir!, '.chat', 'workflows');
|
||||||
|
CustomCommands.getInstance().parseCommands(workflowsDir);
|
||||||
|
}
|
||||||
|
|
||||||
this._view = webviewView;
|
this._view = webviewView;
|
||||||
|
|
||||||
this._webviewManager = new WebviewManager(webviewView.webview, this._context.extensionUri);
|
this._webviewManager = new WebviewManager(webviewView.webview, this._context.extensionUri);
|
||||||
@ -58,4 +71,4 @@ export class DevChatViewProvider implements vscode.WebviewViewProvider {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
@ -1 +1,21 @@
|
|||||||
<p>You need open a folder before DevChat!</p>
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Welcome to DevChat</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
text-align: center;
|
||||||
|
padding: 50px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Welcome to DevChat</h1>
|
||||||
|
<p>DevChat is designed for prompts drive development about your Git repository.</p>
|
||||||
|
<p>Please open a Git repository folder to start using DevChat.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -159,6 +159,11 @@ const webviewConfig = {
|
|||||||
filename: 'index.html',
|
filename: 'index.html',
|
||||||
chunks: ['index']
|
chunks: ['index']
|
||||||
}),
|
}),
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
template: path.resolve(__dirname, 'src', 'welcome.html'),
|
||||||
|
filename: 'welcome.html',
|
||||||
|
chunks: ['welcome']
|
||||||
|
}),
|
||||||
new CopyWebpackPlugin({
|
new CopyWebpackPlugin({
|
||||||
patterns: [
|
patterns: [
|
||||||
{ from: 'assets', to: 'assets' },
|
{ from: 'assets', to: 'assets' },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user