minbrowser / min

A fast, minimal browser that protects your privacy
https://minbrowser.org/
Apache License 2.0
7.87k stars 697 forks source link

Export task to file + desktop file association + subsequent file sync #1861

Open flightmansam opened 2 years ago

flightmansam commented 2 years ago

From https://github.com/minbrowser/min/issues/909#issuecomment-1007962847##export-task-to-file

So here is a bit of a shower thought I had. This could be like bookmarks V2.

Say you have spent all day in one task doing your taxes or something. And you have another task open with your socials. Maybe even another task with directions to that restaurant you like. These are all reasonable sorta things to be having there. You can easily close them when you want and manage, yada yada. This is a way better version of chrome's grouped tabs in my opinion.

But say you are working on a bigger project. We all know that person in the office that has like 1000 tabs open in chrome just to keep their journal articles in the same place or browsing parts catalogues. Let's help them out. Say after every day or researching a sub-component of a project your tabs are at a state where you know what info is on which page but you're not ready to crystallise them into a document, or reference manager, or tell your boss. You just wanna know you can bring them back again some time. You could export your task as a file (potentially just the same as the JSON you store the sessionRestore.json in). Maybe this file could have a custom file extension, so that when you are in your desktop's file manager and you double-click it, it straight away adds that task to you Min session (or opens Min if it isn't active). Someone's project directory could look something like this:

image

Subcomponents of issue:

Saving and loading the task JSON

  1. Loading a task from a file in a similar manner to sessionRestore.js
  2. When sessionRestore.js saves to the user path, tracking that this task file also needs to be resaved as well. (or save it on program exit)

OS Filesystem integration

  1. Code that opens Min if it's closed (and then run task file loading scripts)
  2. Creating a bang that prompts the save dialogue the OS UI to save a the task file (tentatively: ".min" extension) in a specified location, with a specified filename
  3. Managing permissions

Error handling

  1. If file:/// tabs in the task are no longer available
  2. If task file no longer exists
PalmerAL commented 2 years ago

When sessionRestore.js saves to the user path, tracking that this task file also needs to be resaved as well. (or save it on program exit)

The way I was picturing this is that the export task option would be a static snapshot of your task at the time you exported it, and then opening it would make a new task with those tabs. That would seem to fit with your description (having a tab set as part of a folder, and being able to bring it back later).

If the idea is for a file that gets updated automatically when you change the task, I'm not entirely sure how that would be different from the existing setup. The file you save would effectively just be a pointer to something in the task list, and opening it would focus Min and switch to that task. But that seems only marginally faster than leaving the task collapsed in the task list, and switching back to it by selecting it in the list.

If file:/// tabs in the task are no longer available

This could just be the standard error page when you try to load a file that doesn't exist.

flightmansam commented 2 years ago

The way I was picturing this is that the export task option would be a static snapshot of your task at the time you exported it, and then opening it would make a new task with those tabs.

The concept I'm thinking of has the assumption that you're working on a project that is constantly evolving (i.e. through some tabs) – hence why you haven't committed to shoving it in a gdocs or crystallised an offline file yet. I suspect if someone was working in this way, I would assume having to re-save the file would be annoying, and has the potential to loose work if you forget.

I'm not entirely sure how that would be different from the existing setup

The big difference is that users no longer have to abstractly think of their tabs being stored somewhere "in the browser" (i.e. /Users/samuel/Library/Application Support/Min/restoreSession.json), rather they have a file that IS their subproject, and even better it's in plain text and they can inspect it without needing a browser, or (hopefully never) their browser has long been deleted. This has the added benefit that the browser doesn't need to be the place to manage your project, rather it's the place for doing the project (at least for the parts requiring online stuff).

The file you save would effectively just be a pointer

Yep I think that is an excellent idea, although I'm thinking it is implemented the other way round. Check out my current mindmap for the concept, below.

How does this sound to you?

SaveFile

PalmerAL commented 2 years ago

What kinds of things would you do with the task file outside the browser?

I think the main part I'm stuck on is that the sessionRestore format isn't particularly human-readable or -editable. If you want to edit your tabs for a project, are you (in the general sense, not necessarily you specifically) going to open this in a text editor and start editing it manually, or are you more likely to open it in the task overlay view so that you have a UI to perform management functions? - If you open the overlay UI each time to make changes, then it's functionally equivalent to the existing solution anyway.

The archival component of this does seem more promising - I can imagine including task lists in git repositories, copying to backup disks, etc. Although, in that case it seems like what you would really want is just a plain list of URLs, so that years in the future (when Min may or may not exist), you can copy the URLs and open them in whatever rather than having to go through the JSON.


Sidenote: the main problem here (which I think you've identified) is that when you're working on a project, the browser holds a bunch of information about the research for the project, but is siloed off from the actual content of the project. When I've thought about this in the past, the solution I came up with was to integrate a text editor / note-taking app directly in the browser, so you could merge your own writing and snippets of content you find on the web together. [There's some discussion about this in #1451]. Your suggestion is kind of interesting because it goes in the other direction - the idea is to make the browser have as small a role as possible, and make the browser data integrate well with other apps. But there's no standard for browser data, and we can't make other apps integrate with it, so I'm concerned that in reality there aren't / won't be too many things you can actually do with the data outside the browser.

PalmerAL commented 2 years ago

I guess if the browser did have a text editor built in, you could sort of combine these together if you had an option to "link" a task and a directory together. The directory gets a task file that contains the tabs, and if you make a new text file in the browser it gets saved to that directory automatically.

flightmansam commented 2 years ago

What kinds of things would you do with the task file outside the browser?

The main things that come to mind (other than generally managing your project files how the user sees fit):

the sessionRestore format isn't particularly human-readable or -editable

Hmmmm you raise a really good point, especially since the object stringify doesn't add tabs or line returns. The JSON just works so well with JS and your current codebase. Perhaps it could be stored in a HTML format that could be printed by anything that reads html. Feels a little like scope creep for me.

If you want to edit your tabs for a project,...

I don't imagine anyone would be keen on manually editing their files (me included!). The solution that I'm going for would mean that any task in min behaves exactly the same through the task overlay view, whether it is saved or not. You can rearrange tabs, rename it, etc.

I guess if the browser did have a text editor built in, you could sort of combine these together if you had an option to "link" a task and a directory together. The directory gets a task file that contains the tabs, and if you make a new text file in the browser it gets saved to that directory automatically.

oooo this is interesting! This could definitely give the user another tool to be able to do their project in the browser, while at the same time have actual files that come out of the browser that are theirs and they can do what they want with them.

I guess the main point that is driving me is: we shouldn't be forcing the user into any particular way of managing their projects/research. If you're happy with just storing 1000 tabs (e.g split over 20 tasks) in the browser, then Min can do that. If you want your browser to help with note taking as in #1451, that's okay too! And if you are comfortable just sorting your project in your own file system, why not we help out with that.

In terms of data compatibility with other browsers. It might be quite feasible to have a chrome/firefox type extension written that can import min tabs and just open them as tabs (making them statically opened). Not sure about safari, opera, others. Or download and run a simple command line script which we could support that will give you a plain old list of URLS. All potential options if we need that.

PalmerAL commented 2 years ago

The sharing use case sounds interesting. It does sort of open a different question though - is this just a hacky workaround for a lack of cloud sync? In other words, if we built a real cloud sync service, and had a nice "generate a link to send, with a tab list and a button to download min" feature, would this become less useful?

I don't think HTML vs JSON solves anything, the issue is that the tab objects have a bunch of properties whose values aren't easily understandable (or even if you do understand them, are a pain to edit manually), but that are necessary to make various features within the browser work.

I do think there's a good philosophical argument for this - the visibility argument that you mentioned, and also that seeing your data / having the option to write tools to parse it might make people more confident about avoiding data loss / having control over their data, even if almost everyone doesn't actually use anything other than the Min UI.


It seems like there is a promising idea here, even though it's maybe not fully thought out. I may try to write a prototype of this soon, although I start school again next week, so no guarantees.

flightmansam commented 2 years ago

@PalmerAL

It seems like there is a promising idea here, even though it's maybe not fully thought out. I may try to write a prototype of this soon, although I start school again next week, so no guarantees.

I have already got a branch in my fork of min with this functionality fleshed out. Just going through some testing at the moment. When done, I'll give you a heads up and you can checkout the branch.

:)

PalmerAL commented 2 years ago

Oh, neat!

flightmansam commented 2 years ago

@PalmerAL You can check out my branch: save-tasks-dev

Currently tested on macos but I'm currently fiddling the dials to make a windows build.

How to use:

  1. In your task run the bang !savetask and save wherever. (this will already start updating that file whenever sessionRestore timer runs a save)
  2. Close the task
  3. Open the task by dragging the task into the tab bar or by clicking the file and open with min. (I haven't done the magic for automatic file association on the OS).
  4. Unlink a task file (but still keep it as a task in Min) by holding control/cmd while over the delete task button

Some things to still work on:

NB: My branch save-tasks-dev has been merged with other commits bringing things up to electron 16.0.6 (an updated package.json). When I make the pull request for this feature, I'll cherry pick only the appropriate changes into a new branch (save-tasks).

BTW: when writing this I noticed the following function has the un-used parameter window

function sendIPCToWindow (window, action, data) {
  // if there are no windows, create a new one
  if (!mainWindow) {
    createWindow(function () {
      mainWindow.webContents.send(action, data || {})
    })
  } else {
    mainWindow.webContents.send(action, data || {})
  }
}

is the else statement supposed to be?:

...
  } else {
    window.webContents.send(action, data || {})
  }
...
PalmerAL commented 2 years ago

I'll take a look when I get time, probably this weekend!

Yeah that function seems wrong, I'm thinking it should be something like:

if (window) {
    window.webContents.send
} else if (mainWindow) {
    mainWindow.webContents.send
} else {
    createWindow
}

But this'll need some testing to make sure it still works in the various places that call this.

PalmerAL commented 2 years ago

Sorry for taking so long with this; I've been really busy with other things the past few weeks, and I'm still not really sure what to do with this. I tried out the branch; it seems to work as described. I think the benefit of being able to archive your tabs / put them in git is enough to justify doing this, even if the file isn't really editable.

I'm still thinking about the "project folder" / link a task to a folder option also. I ended up making a prototype of having a text editor in the browser: https://github.com/minbrowser/min/tree/exp-text-editing (!file folder/file.html makes a new document in ~/Documents/folder/file.html; everything auto-saves). But the prototype is lacking enough features that I can't really tell if this would be a useful workflow or not.

The problem is that the two approaches sort of conflict with each other - if you had tasks linked to a file, it would be hard to migrate those to be linked to a folder later. The folder approach seems more useful / can cover more use cases, but also a lot more work to develop, and I'm not sure if it really makes sense to go in that direction or not. The approach in your branch is simpler, but also narrower in terms of what use cases it covers, and would be hard to expand later.


RE your question about file naming: mapping task names directly to file names is probably impossible - task names can be duplicates, contain characters that are disallowed in filenames, etc. It's probably best to either let the user pick a good file name separate from the task name, or use the task ID number (ugly, but the best in terms of making sure each file is unique).

flightmansam commented 2 years ago

Hi PalmerAL. Gosh it's been a long time since revisiting this. I have been using min full time since our last chat (only reverting to firefox when certain websites think I am a bot and block me).

Okay so things I have learnt: This is a good idea in theory. But I found that I am so ingrained in the culture of just leaving all my work "in the browser" and not caring about tasks being separated out in different files to be managed by a filesystem/project hierarchy. I found there are just too many mental barriers going through the saving and syncing process to regularly incorporate it in my day to day browsing experience. What's more, I often found that I forgot where I saved the file to particular tasks. This is probably bad file management on my behalf, but it just means it is definitely not idiot proof, maybe a quick solution could be a recent tasks menu dropdown (e.g. File -> Open Recent -> ...).

Have you thought about this any more?

PalmerAL commented 2 years ago

Sorry, I really haven't thought about this at all.

When you say you don't care about separating tasks / there are too many barriers, are you thinking that the task list is a good solution after all, that you still want tasks in files but wish it was easier, or something else?