-
Notifications
You must be signed in to change notification settings - Fork 42
feat: add experimental workspaces view #947
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
Open
jakehwll
wants to merge
6
commits into
main
Choose a base branch
from
jakehwll/experimental-workspaces-view
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f4681d7
feat: add experimental workspaces view
jakehwll d963f1d
fix: remove unregistered coder.workspaces.refresh command
jakehwll b898481
fix: remove unused import
jakehwll 84d8919
Merge remote-tracking branch 'refs/remotes/origin/jakehwll/experiment…
jakehwll 58075d5
feat: implement basic api handler
jakehwll 8485cdd
🤖 refactor: address PR review feedback for experimental workspaces view
jakehwll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export const WorkspacesApi = {} as const; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Coder Workspaces Webview Panel | ||
|
|
||
| This package contains the Workspaces webview panel for the Coder VS Code extension. | ||
|
|
||
| ## Enabling the Feature | ||
|
|
||
| The workspaces panel is controlled by the `coder.experimental.workspacesPanel` configuration setting. | ||
|
|
||
| To enable via settings.json: | ||
|
|
||
| 1. Open your VS Code settings.json (Cmd/Ctrl + Shift + P → "Preferences: Open User Settings (JSON)") | ||
| 2. Add the following: | ||
|
|
||
| ```json | ||
| { | ||
| "coder.experimental.workspacesPanel": true | ||
| } | ||
| ``` | ||
|
|
||
| 3. Reload VS Code | ||
|
|
||
| A new activity bar icon labeled **"Coder Remote (New)"** will appear when the setting is enabled. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| { | ||
| "name": "@repo/workspaces", | ||
| "version": "1.0.0", | ||
| "description": "Coder Workspaces webview panel", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "build": "vite build", | ||
| "dev": "vite build --watch", | ||
| "typecheck": "tsc --noEmit" | ||
| }, | ||
| "dependencies": { | ||
| "@repo/shared": "workspace:*", | ||
| "@repo/webview-shared": "workspace:*", | ||
| "@tanstack/react-query": "catalog:", | ||
| "@vscode-elements/react-elements": "catalog:", | ||
| "@vscode/codicons": "catalog:", | ||
| "date-fns": "catalog:", | ||
| "react": "catalog:", | ||
| "react-dom": "catalog:" | ||
| }, | ||
| "devDependencies": { | ||
| "@repo/mocks": "workspace:*", | ||
| "@repo/storybook-utils": "workspace:*", | ||
| "@rolldown/plugin-babel": "catalog:", | ||
| "@types/react": "catalog:", | ||
| "@types/react-dom": "catalog:", | ||
| "@vitejs/plugin-react": "catalog:", | ||
| "babel-plugin-react-compiler": "catalog:", | ||
| "typescript": "catalog:", | ||
| "vite": "catalog:" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default function App() { | ||
| return <div>TODO</div>; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| declare module "*.css"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /* TODO */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { ErrorBoundary } from "@repo/webview-shared/react"; | ||
| import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
| import { StrictMode } from "react"; | ||
| import { createRoot } from "react-dom/client"; | ||
|
|
||
| import App from "./App"; | ||
| import "./index.css"; | ||
|
|
||
| const queryClient = new QueryClient(); | ||
|
|
||
| const root = document.getElementById("root"); | ||
| if (!root) { | ||
| throw new Error( | ||
| "Failed to find root element. The webview HTML must contain an element with id='root'.", | ||
| ); | ||
| } | ||
|
|
||
| createRoot(root).render( | ||
| <StrictMode> | ||
| <QueryClientProvider client={queryClient}> | ||
| <ErrorBoundary> | ||
| <App /> | ||
| </ErrorBoundary> | ||
| </QueryClientProvider> | ||
| </StrictMode>, | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| import "./src/index.css"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "extends": "../tsconfig.packages.json", | ||
| "compilerOptions": { | ||
| "paths": { | ||
| "@repo/shared": ["../shared/src"], | ||
| "@repo/webview-shared": ["../webview-shared/src"] | ||
| } | ||
| }, | ||
| "include": ["src", "storybook.preview.ts"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { createReactWebviewConfig } from "../webview-shared/createWebviewConfig"; | ||
|
|
||
| export default createReactWebviewConfig("workspaces", __dirname); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import * as vscode from "vscode"; | ||
|
|
||
| import { | ||
| buildCommandHandlers, | ||
| buildRequestHandlers, | ||
| WorkspacesApi, | ||
| } from "@repo/shared"; | ||
|
|
||
| import { | ||
| dispatchCommand, | ||
| dispatchRequest, | ||
| isIpcCommand, | ||
| isIpcRequest, | ||
| } from "../dispatch"; | ||
| import { getWebviewHtml } from "../html"; | ||
|
|
||
| import type { Logger } from "../../logging/logger"; | ||
|
|
||
| export class WorkspacesPanelProvider | ||
| implements vscode.WebviewViewProvider, vscode.Disposable | ||
| { | ||
| public static readonly viewType = "coder.workspacesPanel"; | ||
|
|
||
| private view?: vscode.WebviewView; | ||
| private disposables: vscode.Disposable[] = []; | ||
|
|
||
| private readonly requestHandlers = buildRequestHandlers(WorkspacesApi, {}); | ||
| private readonly commandHandlers = buildCommandHandlers(WorkspacesApi, {}); | ||
|
|
||
| constructor( | ||
| private readonly extensionUri: vscode.Uri, | ||
| private readonly logger: Logger, | ||
| ) {} | ||
|
|
||
| public refresh(): void { | ||
| this.logger.debug("Workspaces panel refresh requested"); | ||
| } | ||
|
|
||
| resolveWebviewView( | ||
| webviewView: vscode.WebviewView, | ||
| _context: vscode.WebviewViewResolveContext, | ||
| _token: vscode.CancellationToken, | ||
| ): void { | ||
| this.view = webviewView; | ||
|
|
||
| webviewView.webview.options = { | ||
| enableScripts: true, | ||
| localResourceRoots: [ | ||
| vscode.Uri.joinPath( | ||
| this.extensionUri, | ||
| "dist", | ||
| "webviews", | ||
| "workspaces", | ||
| ), | ||
| ], | ||
| }; | ||
|
|
||
| this.disposeView(); | ||
|
|
||
| this.disposables.push( | ||
| webviewView.webview.onDidReceiveMessage((message: unknown) => { | ||
| this.handleMessage(message).catch((err: unknown) => { | ||
| this.logger.error("Unhandled error in message handler", err); | ||
| }); | ||
| }), | ||
| ); | ||
|
|
||
| webviewView.webview.html = getWebviewHtml( | ||
| webviewView.webview, | ||
| this.extensionUri, | ||
| "workspaces", | ||
| "Coder Workspaces", | ||
| ); | ||
|
|
||
| webviewView.onDidDispose(() => this.disposeView()); | ||
| } | ||
|
|
||
| private async handleMessage(message: unknown): Promise<void> { | ||
| if (isIpcRequest(message)) { | ||
| await dispatchRequest(message, this.requestHandlers, this.view?.webview, { | ||
| logger: this.logger, | ||
| }); | ||
| } else if (isIpcCommand(message)) { | ||
| await dispatchCommand(message, this.commandHandlers, { | ||
| logger: this.logger, | ||
| }); | ||
|
EhabY marked this conversation as resolved.
|
||
| } else { | ||
| this.logger.warn("Unexpected webview message", message); | ||
| } | ||
| } | ||
|
|
||
| private disposeView(): void { | ||
| for (const d of this.disposables) { | ||
| d.dispose(); | ||
| } | ||
| this.disposables = []; | ||
| } | ||
|
|
||
| dispose(): void { | ||
| this.disposeView(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.