Compare commits
1 Commits
arcswap-wo
...
hc/fix-cra
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58bf036613 |
14
frontend/package-lock.json
generated
14
frontend/package-lock.json
generated
@@ -62,6 +62,7 @@
|
||||
"svelte-infinite-loading": "^1.4.0",
|
||||
"svelte-tiny-virtual-list": "^2.0.5",
|
||||
"tailwind-merge": "^1.13.2",
|
||||
"uuid": "^11.1.0",
|
||||
"vscode": "npm:@codingame/monaco-vscode-api@~11.1.2",
|
||||
"vscode-languageclient": "~9.0.1",
|
||||
"vscode-uri": "~3.0.8",
|
||||
@@ -12222,6 +12223,19 @@
|
||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
|
||||
"devOptional": true
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz",
|
||||
"integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/broofa",
|
||||
"https://github.com/sponsors/ctavan"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"uuid": "dist/esm/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/validate-npm-package-license": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
|
||||
|
||||
@@ -138,6 +138,7 @@
|
||||
"svelte-infinite-loading": "^1.4.0",
|
||||
"svelte-tiny-virtual-list": "^2.0.5",
|
||||
"tailwind-merge": "^1.13.2",
|
||||
"uuid": "^11.1.0",
|
||||
"vscode": "npm:@codingame/monaco-vscode-api@~11.1.2",
|
||||
"vscode-languageclient": "~9.0.1",
|
||||
"vscode-uri": "~3.0.8",
|
||||
|
||||
@@ -612,12 +612,8 @@
|
||||
}
|
||||
|
||||
function addChatHandler(editor: meditor.IStandaloneCodeEditor) {
|
||||
try {
|
||||
aiChatEditorHandler = new AIChatEditorHandler(editor)
|
||||
reviewingChanges = aiChatEditorHandler.reviewingChanges
|
||||
} catch (err) {
|
||||
console.error('Could not add chat handler', err)
|
||||
}
|
||||
aiChatEditorHandler = new AIChatEditorHandler(editor)
|
||||
reviewingChanges = aiChatEditorHandler.reviewingChanges
|
||||
}
|
||||
|
||||
$: $reviewingChanges && autocompletor?.reject()
|
||||
@@ -625,62 +621,58 @@
|
||||
let completorDisposable: Disposable | undefined = undefined
|
||||
let autocompletor: Autocompletor | undefined = undefined
|
||||
function addSuperCompletor(editor: meditor.IStandaloneCodeEditor) {
|
||||
try {
|
||||
if (completorDisposable) {
|
||||
completorDisposable.dispose()
|
||||
}
|
||||
autocompletor = new Autocompletor(editor, lang)
|
||||
|
||||
// last user events (currently disabled):
|
||||
// let lastTs = Date.now()
|
||||
// editor.onDidChangeModelContent((e) => {
|
||||
// const thisTs = Date.now()
|
||||
// lastTs = thisTs
|
||||
// setTimeout(() => {
|
||||
// if (thisTs === lastTs) {
|
||||
// autocompletor?.savePatch()
|
||||
// }
|
||||
// }, 150)
|
||||
// })
|
||||
|
||||
completorDisposable = editor.onDidChangeCursorPosition((e) => {
|
||||
autocompletor?.reject()
|
||||
if ($reviewingChanges) {
|
||||
return
|
||||
}
|
||||
const position = editor.getPosition()
|
||||
if (!position) {
|
||||
return
|
||||
}
|
||||
const upToText = editor.getModel()?.getValueInRange({
|
||||
startLineNumber: position.lineNumber,
|
||||
startColumn: 0,
|
||||
endLineNumber: position.lineNumber,
|
||||
endColumn: position.column
|
||||
})
|
||||
const lastChar = upToText ? upToText[upToText.length - 1] : ''
|
||||
if (lastChar && lastChar.match(/[\(\{\s:="',]/)) {
|
||||
autocompletor?.predict()
|
||||
}
|
||||
})
|
||||
|
||||
editor.addCommand(KeyCode.Tab, () => {
|
||||
if (autocompletor?.hasChanges()) {
|
||||
autocompletor?.accept()
|
||||
autocompletor?.predict()
|
||||
} else {
|
||||
editor.trigger('keyboard', 'tab', {})
|
||||
}
|
||||
})
|
||||
|
||||
editor.onKeyDown((e) => {
|
||||
if (e.keyCode === KeyCode.Escape) {
|
||||
autocompletor?.reject()
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('Could not add supercompletor', err)
|
||||
if (completorDisposable) {
|
||||
completorDisposable.dispose()
|
||||
}
|
||||
autocompletor = new Autocompletor(editor, lang)
|
||||
|
||||
// last user events (currently disabled):
|
||||
// let lastTs = Date.now()
|
||||
// editor.onDidChangeModelContent((e) => {
|
||||
// const thisTs = Date.now()
|
||||
// lastTs = thisTs
|
||||
// setTimeout(() => {
|
||||
// if (thisTs === lastTs) {
|
||||
// autocompletor?.savePatch()
|
||||
// }
|
||||
// }, 150)
|
||||
// })
|
||||
|
||||
completorDisposable = editor.onDidChangeCursorPosition((e) => {
|
||||
autocompletor?.reject()
|
||||
if ($reviewingChanges) {
|
||||
return
|
||||
}
|
||||
const position = editor.getPosition()
|
||||
if (!position) {
|
||||
return
|
||||
}
|
||||
const upToText = editor.getModel()?.getValueInRange({
|
||||
startLineNumber: position.lineNumber,
|
||||
startColumn: 0,
|
||||
endLineNumber: position.lineNumber,
|
||||
endColumn: position.column
|
||||
})
|
||||
const lastChar = upToText ? upToText[upToText.length - 1] : ''
|
||||
if (lastChar && lastChar.match(/[\(\{\s:="',]/)) {
|
||||
autocompletor?.predict()
|
||||
}
|
||||
})
|
||||
|
||||
editor.addCommand(KeyCode.Tab, () => {
|
||||
if (autocompletor?.hasChanges()) {
|
||||
autocompletor?.accept()
|
||||
autocompletor?.predict()
|
||||
} else {
|
||||
editor.trigger('keyboard', 'tab', {})
|
||||
}
|
||||
})
|
||||
|
||||
editor.onKeyDown((e) => {
|
||||
if (e.keyCode === KeyCode.Escape) {
|
||||
autocompletor?.reject()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$: $copilotInfo.enabled &&
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
import { isInitialCode } from '$lib/script_helpers'
|
||||
import { langToExt } from '$lib/editorUtils'
|
||||
import { scriptLangToEditorLang } from '$lib/scripts'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
export let lang: ScriptLang | 'bunnative'
|
||||
export let code: string
|
||||
@@ -35,31 +36,27 @@
|
||||
if (!contextCodePath) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
if (initializedWithInitCode === null && code) {
|
||||
if (isInitialCode(code)) {
|
||||
initializedWithInitCode = true
|
||||
} else {
|
||||
initializedWithInitCode = false
|
||||
selectedContext = [
|
||||
{
|
||||
type: 'code',
|
||||
title: contextCodePath
|
||||
}
|
||||
]
|
||||
}
|
||||
} else if (initializedWithInitCode) {
|
||||
// if the code was initial and was changed, add code context, then prevent it from being added again
|
||||
if (initializedWithInitCode === null && code) {
|
||||
if (isInitialCode(code)) {
|
||||
initializedWithInitCode = true
|
||||
} else {
|
||||
initializedWithInitCode = false
|
||||
selectedContext = [
|
||||
{
|
||||
type: 'code',
|
||||
title: contextCodePath
|
||||
}
|
||||
]
|
||||
initializedWithInitCode = false
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Could not update context', err)
|
||||
} else if (initializedWithInitCode) {
|
||||
// if the code was initial and was changed, add code context, then prevent it from being added again
|
||||
selectedContext = [
|
||||
{
|
||||
type: 'code',
|
||||
title: contextCodePath
|
||||
}
|
||||
]
|
||||
initializedWithInitCode = false
|
||||
}
|
||||
}
|
||||
$: contextCodePath && code && onCodeChange()
|
||||
@@ -71,21 +68,17 @@
|
||||
args: Record<string, any>,
|
||||
dbSchemas: DBSchemas
|
||||
) {
|
||||
try {
|
||||
const schemaRes = lang === 'graphql' ? args.api : args.database
|
||||
if (typeof schemaRes === 'string') {
|
||||
const schemaPath = schemaRes.replace('$res:', '')
|
||||
const schema = dbSchemas[schemaPath]
|
||||
if (schema && schema.lang === lang) {
|
||||
db = { schema, resource: schemaPath }
|
||||
} else {
|
||||
db = undefined
|
||||
}
|
||||
const schemaRes = lang === 'graphql' ? args.api : args.database
|
||||
if (typeof schemaRes === 'string') {
|
||||
const schemaPath = schemaRes.replace('$res:', '')
|
||||
const schema = dbSchemas[schemaPath]
|
||||
if (schema && schema.lang === lang) {
|
||||
db = { schema, resource: schemaPath }
|
||||
} else {
|
||||
db = undefined
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Could not update schema', err)
|
||||
} else {
|
||||
db = undefined
|
||||
}
|
||||
}
|
||||
$: updateSchema(lang, args, $dbSchemas)
|
||||
@@ -159,7 +152,7 @@
|
||||
}
|
||||
})
|
||||
|
||||
let currentChatId: string = crypto.randomUUID()
|
||||
let currentChatId: string = uuidv4()
|
||||
let savedChats: Record<
|
||||
string,
|
||||
{
|
||||
@@ -292,7 +285,7 @@
|
||||
|
||||
async function saveAndClear() {
|
||||
await saveChat()
|
||||
currentChatId = crypto.randomUUID()
|
||||
currentChatId = uuidv4()
|
||||
displayMessages = []
|
||||
messages = [prepareSystemMessage()]
|
||||
}
|
||||
@@ -348,7 +341,6 @@
|
||||
let indexDB: IDBPDatabase<ChatSchema> | undefined = undefined
|
||||
async function initIndexDB() {
|
||||
try {
|
||||
console.log('Initializing chat history database')
|
||||
indexDB = await openDB<ChatSchema>('copilot-chat-history', 1, {
|
||||
upgrade(indexDB) {
|
||||
if (!indexDB.objectStoreNames.contains('chats')) {
|
||||
@@ -356,10 +348,8 @@
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log('Chat history database initialized')
|
||||
|
||||
const chats = await indexDB.getAll('chats')
|
||||
console.log('Retrieved chats')
|
||||
savedChats = chats.reduce((acc, chat) => {
|
||||
acc[chat.id] = chat
|
||||
return acc
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { type editor as meditor } from 'monaco-editor'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
export type VisualChange =
|
||||
| {
|
||||
@@ -71,7 +72,7 @@ export function setGlobalCSS(id: string, cssCode: string) {
|
||||
}
|
||||
|
||||
function addInlineGhostText(change: Extract<VisualChange, { type: 'added_inline' }>) {
|
||||
const cssId = crypto.randomUUID()
|
||||
const cssId = uuidv4()
|
||||
const decoration = {
|
||||
range: {
|
||||
startLineNumber: change.position.line,
|
||||
|
||||
Reference in New Issue
Block a user