Adds an 'ide' url parameter for gk.dev links#4934
Conversation
🤖 Augment PR SummarySummary: This PR updates gk.dev link generation to include an Changes:
Technical Notes: The IDE identifier comes from 🤖 Was this summary useful? React with 👍 or 👎 |
936d004 to
0209c58
Compare
Updates `getGkDevUrl` to asynchronously fetch and include the host IDE (e.g., VS Code) as an `ide` query parameter. It should be used for all register, connect, and upgrade flows. Introduces `getGkDevUrlWithoutIdeArg` for cases where the `ide` parameter is not required, such as draft URLs. Updates all existing call sites to `await` the now-asynchronous `getGkDevUrl` method. Refactors query parameter generation for `source` and `ide` into dedicated helper methods for improved consistency. (#4905, #4934)
0209c58 to
d24cb30
Compare
src/plus/gk/urlsProvider.ts
Outdated
| async getGkDevUrl(pathSegments?: string | string[], query?: string | URLSearchParams): Promise<string> { | ||
| const ide = (await getHostAppName()) ?? 'unknown'; | ||
| query = this.provideQueryWithIdeArg(query, ide); | ||
| query = this.provideQueryWithSourceArg(query); | ||
| const uri = this.buildGkDevUri(pathSegments, query); | ||
| return uri.toString(true); | ||
| } | ||
|
|
||
| getGkDevUrlWithoutIdeArg(pathSegments?: string | string[], query?: string | URLSearchParams): string { |
There was a problem hiding this comment.
Why do we have two functions? Is there some technical reason we can't make it async in every case and just provide the option in the params to include IDE?
There was a problem hiding this comment.
@axosoft-ramint
Yes, you're right.
ViewNode.getUrl supports both async and sync signatures, so I can just update it and it does not require massive changes.
Updates `getGkDevUrl` to asynchronously fetch and include the host IDE (e.g., VS Code) as an `ide` query parameter. It should be used for all register, connect, and upgrade flows. Introduces `getGkDevUrlWithoutIdeArg` for cases where the `ide` parameter is not required, such as draft URLs. Updates all existing call sites to `await` the now-asynchronous `getGkDevUrl` method. Refactors query parameter generation for `source` and `ide` into dedicated helper methods for improved consistency. (#4905, #4934)
d24cb30 to
8d61774
Compare
Updates `getGkDevUrl` to asynchronously fetch and include the host IDE (e.g., VS Code) as an `ide` query parameter. It should be used for all register, connect, and upgrade flows. Introduces `getGkDevUrlWithoutIdeArg` for cases where the `ide` parameter is not required, such as draft URLs. Updates all existing call sites to `await` the now-asynchronous `getGkDevUrl` method. Refactors query parameter generation for `source` and `ide` into dedicated helper methods for improved consistency. (#4905, #4934)
8d61774 to
c7b8c20
Compare
Updates `getGkDevUrl` to asynchronously fetch and include the host IDE (e.g., VS Code) as an `ide` query parameter. It should be used for all register, connect, and upgrade flows. Introduces `getGkDevUrlWithoutIdeArg` for cases where the `ide` parameter is not required, such as draft URLs. Updates all existing call sites to `await` the now-asynchronous `getGkDevUrl` method. Refactors query parameter generation for `source` and `ide` into dedicated helper methods for improved consistency. (#4905, #4934)
c7b8c20 to
fdf0658
Compare
|
@sergeibbb I just got back to this PR after a while off of it, and tried to follow the PR description, the GitHub issue description, and the Jira issue description to understand why this field is needed, and I still do not understand. What would this "ide" parameter encode that's not already a part of the scheme/protocol/completion link encoded in a deep link to GitLens? |
|
@axosoft-ramint (Unfortunately Jira has stopped focusing on the linked comment). |
|
Hi @axosoft-ramint |
Updates `getGkDevUrl` to asynchronously fetch and include the host IDE (e.g., VS Code) as an `ide` query parameter. It should be used for all register, connect, and upgrade flows. Introduces `getGkDevUrlWithoutIdeArg` for cases where the `ide` parameter is not required, such as draft URLs. Updates all existing call sites to `await` the now-asynchronous `getGkDevUrl` method. Refactors query parameter generation for `source` and `ide` into dedicated helper methods for improved consistency. (#4905, #4934)
fdf0658 to
9fe1042
Compare
ramin-t
left a comment
There was a problem hiding this comment.
LGTM after the explanation provided. I suggest confirming that the changelog entry is in the right place before merging, and confirm that always including the ide param in all gkdev urls we use doesn't pose any issues for url flows that are not yet ready for it (as long as it is ignored in those cases, I don't see any harm in including it).
| let uri = pathSegments.length ? Uri.joinPath(this.baseGkDevUri, ...pathSegments) : this.baseGkDevUri; | ||
|
|
||
| query ??= 'source=gitlens'; | ||
| const ide = (await getHostAppName()) ?? 'unknown'; |
There was a problem hiding this comment.
One other thought: are all possible outputs of getHostAppName url-friendly? If we put the string output of that function directly into the query, just confirming we won't have any issues downstream or upstream.
There was a problem hiding this comment.
@axosoft-ramint
are all possible outputs of getHostAppName url-friendly?
No, because we can read it from env.appRoot, 'product.json' where everything can be contained.
If we put the string output of that function directly into the query
We should not put directly to the query string we should always wrap it:
??= `source=gitlens&ide=${encodeURIComponent(ide)}`
However if we put it to the query object, it's wrapped automatically:
query = new URLSearchParams(query);
query.set('ide', "co=de");
the output is:
ide=co%3Dde
Updates `getGkDevUrl` to asynchronously fetch and include the host IDE (e.g., VS Code) as an `ide` query parameter. It should be used for all register, connect, and upgrade flows. Introduces `getGkDevUrlWithoutIdeArg` for cases where the `ide` parameter is not required, such as draft URLs. Updates all existing call sites to `await` the now-asynchronous `getGkDevUrl` method. Refactors query parameter generation for `source` and `ide` into dedicated helper methods for improved consistency. (#4905, #4934)
9fe1042 to
1e94c73
Compare
Updates `getGkDevUrl` to asynchronously fetch and include the host IDE (e.g., VS Code) as an `ide` query parameter. It should be used for all register, connect, and upgrade flows. Introduces `getGkDevUrlWithoutIdeArg` for cases where the `ide` parameter is not required, such as draft URLs. Updates all existing call sites to `await` the now-asynchronous `getGkDevUrl` method. Refactors query parameter generation for `source` and `ide` into dedicated helper methods for improved consistency. (#4905, #4934)
1e94c73 to
05b8bb2
Compare
Updates `getGkDevUrl` to asynchronously fetch and include the host IDE (e.g., VS Code) as an `ide` query parameter. It should be used for all register, connect, and upgrade flows. Introduces `getGkDevUrlWithoutIdeArg` for cases where the `ide` parameter is not required, such as draft URLs. Updates all existing call sites to `await` the now-asynchronous `getGkDevUrl` method. Refactors query parameter generation for `source` and `ide` into dedicated helper methods for improved consistency. (#4905, #4934)



Description
Solves #4905
Checklist
Fixes $XXX -orCloses #XXX -prefix to auto-close the issue that your PR addresses