Skip to content

feat: open app in tab or slim-window #16152

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

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: open app on tab or slim-window
  • Loading branch information
BrunoQuaresma committed Jan 15, 2025
commit 774daa1b3ec4e382d3102d7f55a04ac8de33d45f
28 changes: 19 additions & 9 deletions site/src/modules/resources/AppLink/AppLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
}

event.preventDefault();

// This is an external URI like "vscode://", so
// it needs to be opened with the browser protocol handler.
if (app.external && !app.url.startsWith("http")) {
// If the protocol is external the browser does not
// redirect the user from the page.
const isBrowserProtocol = app.external && !app.url.startsWith("http");
Copy link
Member

@code-asher code-asher Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait this is actually the opposite, right? Not a browser protocol (like vscode://). Maybe isExternalProtocol?

Well, I guess the browser does handle it by launching the external app, but isBrowser makes me think of http://

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It made sense to me before you brought this up—now I’m not so sure. Maybe shouldOpenAppExternally?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that name


if (isBrowserProtocol) {
// This is a magic undocumented string that is replaced
// with a brand-new session token from the backend.
// This only exists for external URLs, and should only
Expand All @@ -149,12 +149,22 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
setFetchingSessionToken(false);
}
window.location.href = url;
} else {
window.open(
href,
Language.appTitle(appDisplayName, generateRandomString(12)),
"width=900,height=600",
);
return;
}

switch (app.open_in) {
case "slim-window": {
window.open(
href,
Language.appTitle(appDisplayName, generateRandomString(12)),
"width=900,height=600",
);
return;
}
case "tab": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be the default case or are we guaranteed open_in will always be set and only contain one of these two values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ensure it will always be set and contain one of these two values.

window.open(href);
return;
}
}
}}
>
Expand Down
Loading