-
Notifications
You must be signed in to change notification settings - Fork 8
Add a snooze option for port discovery #100
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
marwan-at-work
wants to merge
7
commits into
main
Choose a base branch
from
marwan/snooze
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.
+37
−8
Open
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6b1d651
Make port discovery optional via settings
marwan-at-work 2e4daa2
Merge branch 'main' into marwan/snooze
tendstofortytwo 4708ad7
Merge branch 'main' into marwan/snooze
tendstofortytwo b39abe4
store snooze timer to disk
tendstofortytwo 5f7a15d
fix sign
tendstofortytwo 0fd92c3
fix text content
tendstofortytwo 0a4b3f9
fix readme error
tendstofortytwo 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ export class Tailscale { | |
| private notifyExit?: () => void; | ||
| private socket?: string; | ||
| private ws?: WebSocket; | ||
| private snoozing?: boolean; | ||
|
|
||
| constructor(vscode: vscodeModule) { | ||
| this._vscode = vscode; | ||
|
|
@@ -363,13 +364,30 @@ export class Tailscale { | |
| if (msg.type != 'newPort') { | ||
| return; | ||
| } | ||
| if (this.snoozing) { | ||
| return; | ||
| } | ||
| const shouldServe = await this._vscode.window.showInformationMessage( | ||
| msg.message, | ||
| { modal: false }, | ||
| 'Serve' | ||
| 'Serve', | ||
| 'Snooze Notifications' | ||
| ); | ||
| if (shouldServe) { | ||
| if (shouldServe === 'Serve') { | ||
| await this.runFunnel(msg.port); | ||
| } else if (shouldServe === 'Snooze Notifications') { | ||
| this.snooze(); | ||
| const openSettings = await this._vscode.window.showInformationMessage( | ||
| 'Snoozed for 15 minutes. You can fully turn off port discovery in the settings', | ||
| { modal: false }, | ||
| 'Open Settings' | ||
| ); | ||
| if (openSettings) { | ||
| this._vscode.commands.executeCommand( | ||
| 'workbench.action.openSettings', | ||
| 'tailscale.portDiscovery.enabled' | ||
| ); | ||
| } | ||
| } | ||
| }); | ||
| this._vscode.window.onDidOpenTerminal(async (e: vscode.Terminal) => { | ||
|
|
@@ -401,6 +419,13 @@ export class Tailscale { | |
| }); | ||
| } | ||
|
|
||
| async snooze() { | ||
| this.snoozing = true; | ||
| setTimeout(() => { | ||
| this.snoozing = false; | ||
| }, 900000); // fifteen minutes | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prefer |
||
| } | ||
|
|
||
| async runFunnel(port: number) { | ||
| await this.serveAdd({ | ||
| protocol: 'https', | ||
|
|
||
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.
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.
This is only going to snooze for 15 minutes within the instance of VS Code it was triggered in. I would like a prompt for the duration, including day, week, and month. For this, I am thinking we could use
context.globalStoragePathand persist the port config (snooze info) to disk.Thoughts @samlinville @christine-tailscale
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.
When does this notification show up? Will the snooze function delay just this message or will it snooze all notifications from us?
I'm assuming that users would want to snooze because they're in the middle of something else and want to save it for later. What if instead of offering them custom snooze options, we offer them a quick yes/no decision? And then if they click no, we can use that notification to educate them where port discovery lives if they want to come back to it later?
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.
The notification shows up as part of port discovery and as this PR stands snoozes discovery entirely:
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.
We should persist in the requested snooze duration (storing the time when we can unsnooze). We should not offer a calendar or complex form to fill out (we're trying to work around an annoyance, let's not annoy them more). Let's keep it simple.
15 minutes seems too short, TBH. The goal is to provide a reasonable snooze option that keeps the port disco from annoying users. If snooze is too short, we're still annoying them. The minimum risk is that the person will disable port disco notifications altogether. The max is the uninstall.
I wouldn't oppose a single "Snooze for 1hr" or "Snooze" and then prompting with 1 hour, 2 hours, or this session. (For example)