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

All preferences and offline data for DevDocs are lost after VSCode restart #4

Open
volo-zyko opened this issue Jul 13, 2017 · 9 comments

Comments

@volo-zyko
Copy link

As far as I understand this is restriction imposed by vscode.previewHtml but still it has to be tackled somehow. Either vscode.previewHtml has to be extended/superseded (that's on VSCode side) or DevDocs settings has to be saved externally (on vscode-devdocs side) and passed to DevDocs when it's opened.

This is really annoying issue and is a showstopper for me. :(

@sagaban
Copy link

sagaban commented Jul 21, 2017

I have the same issue :( Are you open to PR?

@jcw-
Copy link
Contributor

jcw- commented Oct 14, 2017

It does not appear to currently be possible to do this because:

  1. VS Code's previewHtml uses an Electron webview with a non-persistent session. This is because it specifies a partition name without a persist: prefix and avoids using the default (persistent) partition. This means the webview persists in-memory and is lost when VS Code is restarted.
  2. There does not appear to be any way to use a persistent webview in VS Code.
  3. The technique used by this extension is to load HTML containing an iframe pointing to devdocs.io. However, it is not possible to modify the contents of the iframe (e.g. to try and manually import/set preferences) due to cross-frame scripting security (this is a good thing). Any import/export or setting of preferences on the iframe would need to use an interface exposed by devdocs.io - and there isn't such a thing (not such a good thing). One option would be for devdocs to call a parent method (if it exists) to allow for the opportunity to override preferences, which could then be defined in this extension's HTML file.
  4. Modifying where devdocs.io stores the preferences is also not really an option, as it uses a cookie to hold this data.

Workarounds:

  • Use a tool such as Fiddler or Wireshark to inject the pre-configured cookie into the network communication between VS Code and devdocs.io.
  • Run devdocs.io locally and modify the code so that the defaults match what you actually want, run it locally using rvmsudo bundle exec rackup -p 80 -o 0.0.0.0 and serve it instead of devdocs.io by leveraging etc/hosts. This is the option I ended up going with.

@cstuder
Copy link

cstuder commented Nov 7, 2017

That's too bad.

Another idea: Devdocs.io is open source, we could suggest a feature in which the initial configuration can be transmitted JSON encoded by pseudo-GET-parameter or in the hash part of the URI. Devdocs.io would then have to import the parameters during the initial load (As if the user had just 'imported' the setttings.)

This would shift the initial configuration into vscode-devdocs settings. Unfortunately this would mean that you would have to manually update these settings when you want to change the devdocs.io settings. Syncing these settings wouldn't be possible as far as I can see. (Havin only little extension development experience.)

@cstuder
Copy link

cstuder commented Nov 7, 2017

Alternatively add an option to open the documentation in an external browser window.

@jcw-
Copy link
Contributor

jcw- commented Nov 15, 2017

@cstuder Yeah, I considered the same thing, I actually looked into submitting a PR against devdocs to support non-cookie based storage of configuration, but it turned out to be a bit more complicated than I had hoped, so I didn't pursue it: freeCodeCamp/devdocs#199
Probably still within the realm of possibility though.

I'm not sure it makes sense to open anything external in this particular extension, it's pretty focused on doing it inline - there is actually a second devdocs extension that does what you describe though (opens a search in a browser).

@akfish
Copy link
Owner

akfish commented Nov 16, 2017

I agree with what @jcw- said. I investigated some possible fixes including:

  • Making devdocs stateless by passing configurations via url parameters (won't fix offline caching obviously)
  • Consume devdocs database directly and use vscode's native UI

They've proven to be too much work for me and I unfortunately don't have enough free time for this.

At this time I won't recommend using this extension any more. I moved on to using dash instead. Thanks for trying it out and sorry for the inconveniences. PLs are still welcome and I'll review and merge them whenever possible.

@wmertens
Copy link

There is also https://github.com/egoist/devdocs-desktop/ which has a global hotkey

@L3v3L
Copy link

L3v3L commented Dec 8, 2018

would the new move from previewHtml to webView (microsoft/vscode#62630) help in solving this issue?

@wmertens
Copy link

Hmm that needs to be done anyway since the previewHtml is deprecated. It has a retainContextWhenHidden flag that keeps the window state when the tab is not visible, which will help, but it still destroy the content when the tab is closed, which may or may not mean cached content is gone.

If devdocs has an API to manage the cache though, the extension could use that to maintain the devdocs cache. That would be 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants