-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: basic example how to use openTab on client/server side #865
base: main
Are you sure you want to change the base?
Conversation
@@ -52,6 +64,35 @@ export function registerChat(languageClient: LanguageClient, extensionUri: Uri, | |||
languageClient.info(`[VSCode Client] Received telemetry event from server ${JSON.stringify(e)}`) | |||
}) | |||
|
|||
languageClient.onRequest(openTabRequestType.method, async (params, _) => { | |||
const mapErrorType = (type: string | undefined): number => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to re-create this function every request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its only an example change so that I can start working on the open tab story
const endTime = Date.now() + 60000 // 1 minute from now | ||
const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)) | ||
while (Date.now() < endTime) { | ||
if (openTabResponseQueue.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are tab requests and responses guaranteed to be in order? Can we index them by requestId
instead?
@@ -132,12 +173,30 @@ export function registerChat(languageClient: LanguageClient, extensionUri: Uri, | |||
if (!isValidAuthFollowUpType(message.params.followUp.type)) | |||
languageClient.sendNotification(followUpClickNotificationType, message.params) | |||
break | |||
case openTabRequestType.method: | |||
openTabResponseQueue.push(message.params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we resolve the promise here immediately instead of spinning a loop every 100ms?
default: | ||
if (isServerEvent(message.command)) languageClient.sendNotification(message.command, message.params) | ||
break | ||
} | ||
}, undefined) | ||
|
||
async function waitForOpenTabResult(): Promise<UiMessageResultParams | undefined> { | ||
const endTime = Date.now() + 60000 // 1 minute from now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why one minute? How expensive is it to create a tab?
@@ -105,6 +105,17 @@ export const QChatServer = | |||
return chatController.onCodeInsertToCursorPosition(params) | |||
}) | |||
|
|||
chat.onReady(_ => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the expected behavior? To create a new tab on load?
Problem
DO NOT MERGE
Solution
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.