Skip to content

hud: add a prompt package for the new terminal mode#3464

Merged
nicks merged 1 commit into
masterfrom
nicks/browser
Jun 16, 2020
Merged

hud: add a prompt package for the new terminal mode#3464
nicks merged 1 commit into
masterfrom
nicks/browser

Conversation

@nicks

@nicks nicks commented Jun 15, 2020

Copy link
Copy Markdown
Contributor

Hello @landism, @jazzdan,

Please review the following commits I made in branch nicks/browser:

e503e18 (2020-06-15 16:00:46 -0400)
hud: add a prompt package for the new terminal mode

Code review reminders, by giving a LGTM you attest that:

  • Commits are adequately tested
  • Code is easy to understand and conforms to style guides
  • Incomplete code is marked with TODOs
  • Code is suitably instrumented with logging and metrics

@nicks
nicks requested review from jazzdan and landism June 15, 2020 20:01
@nicks

nicks commented Jun 15, 2020

Copy link
Copy Markdown
Contributor Author

ack, i forgot what a pain dealing with TTY APIs is

Comment thread internal/hud/prompt/prompt.go Outdated
serverStatus := "(without browser UI)"
if hasBrowserUI {
if p.host == "0.0.0.0" {
serverStatus = fmt.Sprintf("on %s (listen on 0.0.0.0)", p.url)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit

Suggested change
serverStatus = fmt.Sprintf("on %s (listen on 0.0.0.0)", p.url)
serverStatus = fmt.Sprintf("at %s (listening on 0.0.0.0)", p.url)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread internal/hud/prompt/prompt.go Outdated
switch r {
case ' ':
_, _ = fmt.Fprintf(p.stdout, "Opening browser: %s\n", p.url.String())
_ = p.openURL(p.url.String())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't know under what cases this might return an error (too many files, can't start a new process, I dunno), but it seems worth it to log any error, so at least it's not silently doing nothing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done!

Comment thread internal/hud/prompt/prompt.go Outdated
}
}()

for ctx.Err() == nil {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IIUC, at the moment, this is just holding onto the subscriber's notify goroutine forever, which ~means its OnChange can only ever be called once (which then might surprise someone trying to edit this subscriber). It seems to work, but also seems different from how our other subscribers work, and potentially accidental (like, does this mostly make p.printed redundant?)

would it be better to put this for loop in a new goroutine? am I missing something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yep! i've been moving towards subscribers that just hold onto their lock until they are done. And using goroutines less often. they're a ton easier to test.

though i think in this case it makes sense to do the input polling on a goroutine, done!

@nicks
nicks merged commit 8839159 into master Jun 16, 2020
@nicks
nicks deleted the nicks/browser branch June 16, 2020 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants