Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Apr 28, 2020. It is now read-only.

Add rebuild button and command #123

Merged
merged 4 commits into from
May 20, 2019
Merged

Add rebuild button and command #123

merged 4 commits into from
May 20, 2019

Conversation

nhooyr
Copy link
Contributor

@nhooyr nhooyr commented May 20, 2019

Unfortunately the command is not coming up in the command palette, not sure why.

@kylecarbs

And no key bind yet, doesn't seem to be exposed in code-server.

This should be good enough for release though.

} else {
alert("reload failed; please see logs in sail terminal")
}
stopReloadUI()
}
}

window.addEventListener("ide-ready", () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is where the changes are.

sail.js Outdated
text: "rebuild",
tooltip: "press super+alt+r to rebuild",
command: "rebuild-sail-container"
// showBeak: true <- what does this do?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

It adds a little arrow above the item. For example if you click the notification bell it will show up.

let elements = document.getElementsByClassName(className);
for (let e of elements) {
e.parentNode.removeChild(e)
(function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why wrap this all in a function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The global variables become scoped to the file. This is what Webpack and other module loaders due for the browser to isolate modules.

@nhooyr
Copy link
Contributor Author

nhooyr commented May 20, 2019

@code-asher, any ideas why the command doesn't show up in the command palette?

@code-asher
Copy link
Member

I don't think adding something to the command registry adds it to the palette. IIRC there is a workbench registry and registering actions on that is what adds them to the palette (as well as letting you define keybindings).

@code-asher
Copy link
Member

code-asher commented May 20, 2019

Actually just ran into code that makes it look like you can manually append to the command palette as well:

MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
	command: {
		id,
		title,
		category
	},
	when
});

We expose the menu registry so that might work.

@code-asher
Copy link
Member

code-asher commented May 20, 2019

For keybindings there is the keybinding registry we could expose. I'm not sure what the practical difference is between using the workspace registry vs command + keybinding + menu registry combo.

Edit: nvm, looked at the code, the workspace registry just uses the command, keybinding, and menu registries, so no practical difference.

@nhooyr
Copy link
Contributor Author

nhooyr commented May 20, 2019

Edit: nvm, looked at the code, the workspace registry just uses the command, keybinding, and menu registries, so no practical difference.

If it uses the command registry, why doesn't the rebuild command show up?

@nhooyr
Copy link
Contributor Author

nhooyr commented May 20, 2019

I think I want registerCommandAndKeybindingRule on the IKeybindingsRegistry.

@nhooyr
Copy link
Contributor Author

nhooyr commented May 20, 2019

@ammario
Copy link
Member

ammario commented May 20, 2019

I get the following when doing sail run from this branch

2019-05-20 12:51:35 ERROR	failed to wait for project to be online: container cdr_sail not running
+ cd /home/user/go/src/go.coder.com/sail
+ code-server --host localhost --port 0 --data-dir /home/user/.config/Code --extensions-dir /home/user/.vscode/extensions --allow-http --no-auth
+ tee /tmp/code-server.log
internal/buffer.js:53
  throw new ERR_OUT_OF_RANGE(type || 'offset',
  ^

RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 268. Received 270
    at boundsError (internal/buffer.js:53:9)
    at Buffer.readUInt32BE (internal/buffer.js:196:5)
    at Function.fromBuffer (nbin.js:1:3737)
    at Function.fromBuffer (nbin.js:1:3603)
    at Function.fromBuffer (nbin.js:1:3603)
    at Function.fromBuffer (nbin.js:1:3603)
    at Object.<anonymous> (nbin.js:1:2075)
    at r (nbin.js:1:222)
    at nbin.js:1:1021
    at nbin.js:1:1030
2019-05-20 12:51:35 ERROR	build run failed: container cdr_sail not running

@nhooyr
Copy link
Contributor Author

nhooyr commented May 20, 2019

Seems to be a code-server issue @kylecarbs

@code-asher
Copy link
Member

Edit: nvm, looked at the code, the workspace registry just uses the command, keybinding, and menu registries, so no practical difference.

If it uses the command registry, why doesn't the rebuild command show up?

That only adds it as a command, the menu registry is what adds it to the palette.

@nhooyr
Copy link
Contributor Author

nhooyr commented May 20, 2019

Then what did you mean by

the workspace registry just uses the command, keybinding, and menu registries, so no practical difference.

What is the workspace registry for?

@code-asher
Copy link
Member

code-asher commented May 20, 2019

As far as I can tell, when you call registerWorkbenchAction on the workbench registry, it essentially just calls CommandsRegistry.registerCommand (this adds the command), KeybindingsRegistry.registerKeybindingRule (this adds the keybinding to run the command), and MenuRegistry.appendMenuItem (this adds the command to the command palette) (and MenuRegistry.addCommand but I tested without that and it still works so I'm not sure what it does).

So you could call all three manually, or call registerWorkbenchAction and let it do all three.

@nhooyr
Copy link
Contributor Author

nhooyr commented May 20, 2019

Sounds good, I think we need to expose it though.

@code-asher
Copy link
Member

code-asher commented May 20, 2019

Yup, and SyncActionDescriptor as well looks like since that's what it takes as an argument.

@nhooyr
Copy link
Contributor Author

nhooyr commented May 20, 2019

What does that do?

@code-asher
Copy link
Member

My bad, edited my response but the workbench registry takes a SyncActionDescriptor as an argument. It looks basically like a sort of wrapper around a command.

@code-asher
Copy link
Member

Might not be a bad idea to just expose the service collection in its entirety. I think we discussed doing that at one point.

@code-asher
Copy link
Member

nvm on my previous comment, I got service collections and the registries mixed up. I don't think the registries exist on the service collection.

@nhooyr
Copy link
Contributor Author

nhooyr commented May 20, 2019

Yea, I'm working on it. Just going to import the global registry and expose it.

@nhooyr
Copy link
Contributor Author

nhooyr commented May 20, 2019

@code-asher PR updated

@nhooyr
Copy link
Contributor Author

nhooyr commented May 20, 2019

Should be good now, key bind is cmd+r and it shows up in command palette so a user can rebind if they want.

@nhooyr
Copy link
Contributor Author

nhooyr commented May 20, 2019

(ctrl+r on linux/windows)

@nhooyr nhooyr requested a review from code-asher May 20, 2019 21:47
@nhooyr
Copy link
Contributor Author

nhooyr commented May 20, 2019

This PR is just waiting for a new release of code-server to include the actions registry API.

@code-asher
Copy link
Member

code-asher commented May 20, 2019

Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

LGTM.

sail.js Outdated
const statusBarService = window.ide.workbench.statusbarService
statusBarService.addEntry({
text: "rebuild",
tooltip: "press super+r to rebuild",
Copy link
Member

Choose a reason for hiding this comment

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

ctrl or cmd now, but since the user can customize keybindings it might be better not to display this text at all. There is probably a way to get the current keybinding but I'm not sure off the top of my head how you'd access that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point

sail.js Outdated
})
})
}())
Copy link
Member

Choose a reason for hiding this comment

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

Not really any of my business, but I am curious about the loss of the newline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

}), "sail: Rebuild container", "sail");

const statusBarService = window.ide.workbench.statusbarService
statusBarService.addEntry({
Copy link
Member

Choose a reason for hiding this comment

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

Did we want to only show this when we detect a change to the Dockerfile?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can just leave it there.

Also prevent rebuild while rebuild is in progress, just in case.
@nhooyr nhooyr merged commit 3a40670 into master May 20, 2019
@nhooyr nhooyr deleted the button branch May 20, 2019 23:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants