Skip to content
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

better hledger-web first startup experience #855

Open
simonmichael opened this issue Jul 31, 2018 · 7 comments
Open

better hledger-web first startup experience #855

simonmichael opened this issue Jul 31, 2018 · 7 comments
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. web The hledger-web tool.

Comments

@simonmichael
Copy link
Owner

Reported on list today: hledger-web fails to start when no journal file exists yet. And if you have started it by clicking icons you won’t know why. We should provide a better startup experience.

@simonmichael simonmichael added A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. web The hledger-web tool. easy? good-first-issue If you're a new contributor, this might be a good one for you. labels Jul 31, 2018
@simonmichael simonmichael changed the title better hledger-web first startup better hledger-web first startup experience Jul 31, 2018
@simonmichael simonmichael added the hacktoberfest Come on you merry Hacktobers, I dare you to fix something label Oct 14, 2018
@simonmichael simonmichael removed hacktoberfest Come on you merry Hacktobers, I dare you to fix something labels Nov 11, 2018
@jazcarate
Copy link
Contributor

@simonmichael I'm trying to dip my toes into this issue but I'm encountering some unexpected friction.

I was about to refactor the withJournalDo to add a exceptional handler (something like withJournalDoOrElse :: CliOpts -> (Journal -> IO a) -> IO a -> IO a) when the journal did not exist, or coudn't be parsed. But that would cascade in a refactor of readJournalFile, readJournalFile up until requireJournalFileExists which yeilds just a IO (); not something that can be catched.

So I opted to re-validate the doesFileExist before withJournalDo on the hledgerWebMain. This double-checking of the journal existence is a tad redundant, but I felt it was less intrusive than creating a whole new branch of withJournalDoOrElse. This path was not without its own friction. It started to make hard to spool the yesod application, as both paths would need a lot of the same config (eg. the host and port) but it is not so easily extracted.

I did a very quick try to change the makeApplication to consume a Maybe Journal but the code started to spaghetti out of control 😅.

When you wrote this issue, did you have any clear idea how you would want the code to look like?
I'll keep trying things out 😄

@simonmichael simonmichael removed easy? good-first-issue If you're a new contributor, this might be a good one for you. labels Oct 31, 2021
@simonmichael
Copy link
Owner Author

I did not! Thanks for looking at it. We should probably think about the desired user experience too. This issue primarily matters on Windows I guess.

@jazcarate
Copy link
Contributor

Ok, so a bit of tinkering, I reached a possible solution.
Rather than decouple the Journal from the app; have another Yesod application entirely that has only the error string, and display this web application with a single route when something goes wrong.

There is a draft in #1753 with a couple of open questions. Let me know if this is a sensible approach; or I should reconsider.

@simonmichael
Copy link
Owner Author

@jazcarate that's clever. What about just automatically creating an empty journal file in the default place when it's unspecified and nonexistent ? At least for hledger-web, possibly for hledger/hledger-ui as well ? Any significant downsides ?

@jazcarate
Copy link
Contributor

🤔
This is the third time writing this comment 😅.
After three successive "Aha" moments, I can't think of a downside. Though I'm not entirely sure what would be the consequences of running the web app with a nulljournal.
I saw there is the capability of adding messages to the app, so I think I can route the error as a message/alert and send a nulljournal.
I'll wire the web to to that and test it 👍

@simonmichael
Copy link
Owner Author

All tools should work fine with an empty journal, I'm just not sure if auto-creating the file will be problem free. Let's see.

@simonmichael
Copy link
Owner Author

When a file is specified with -f but does not exist, we should not auto-create in that case.

@simonmichael simonmichael added A-WISH Some kind of improvement request, hare-brained proposal, or plea. and removed A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. labels Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. web The hledger-web tool.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants