visidata icon indicating copy to clipboard operation
visidata copied to clipboard

Feature request: sheets tabs

Open pacien opened this issue 1 year ago • 12 comments

This is a general user feedback: I tend to create many new filtered sheets when using visidata and exploring datasets. I'm having some troubles keeping track of them and locating myself inside the "stack" of open sheets. I find myself switching back and forth the "sheets sheet" just to see where I am.

I believe that adding some tabs of the currently opened sheets might help. That could be displayed either at the bottom where the current sheet name is shown, or at the top when the menu is disabled.

pacien avatar Sep 18 '23 15:09 pacien

@pacien here is a related discussion (https://github.com/saulpw/visidata/discussions/1656) The topic of tabs came up.

Keeping my bearings in VisiData sheets is still an issue for me.

frosencrantz avatar Sep 21 '23 21:09 frosencrantz

Okay, would y'all mind trying this out? Should work in .visidatarc (requires latest commit on develop for left-click to switch tabs).

vd.options.disp_status_fmt = '{vd.sheetlist}| '

def fitWithin(s, n=10):
    if len(s) > n:
        return s[:n//2-1] + '…' + s[-n//2+1:]
    return s

@VisiData.property
def sheetlist(vd):
    sheetnames = []
    for vs in reversed(vd.sheets[1:]):
        sheetnames.append(f'[:onclick jump-sheet-{vs.shortcut}]' + fitWithin(f'{vs.shortcut}›{vs.name}', 10) + '[:]')

    vs = vd.sheets[0]
    sheetnames.append(f'{vs.shortcut}›{vs.name}')
    return ' | '.join(sheetnames)

saulpw avatar Sep 27 '23 23:09 saulpw

This is a nice UI example, and a great start. However, I feel like the stack confuses me. I'm trying to keep a mental map of how the sheets are connected, parent, children, grandchildren siblings, joins. Some of that is in the naming, but it would be useful if I could see this in the UI. The stack doesn't help me keep track of where I am, rather the order of what I visited and this can be confusing when I backtrack.

Sometimes when exploring with VisiData it is like exploring nodes in a Sankey Diagram (e.g. https://plotly.com/julia/sankey-diagram/), where I might go horizontally or vertically. A FreqSheet is like a column in the SanKey. Diving into a row or rows in a FreqSheet is like going right or left in the SanKey. The stack doesn't help me keep track of where I am, rather the order of what I visited.

Is there a way to make the family relationships between the sheets easier to see and explore in the VisiData UI?

Maybe instead of listing the stack, the sheets shown are the ancestors of the current sheet. If a sheet listed has siblings there is some sort of clickable icon (e.g. ☰) that when clicked show a menu of the sibling sheets. I'm not quite sure what to do about joins with multiple parents. But I think something like this could help me keep track of where I am in my data diving explorations.

frosencrantz avatar Sep 30 '23 19:09 frosencrantz

Hm, this is interesting, @frosencrantz. Suppose that we showed the 'path' of sheets on the statusline, instead of the stack. When you go to the parent sheet, would the order stay the same, but the parent sheet would be highlighted instead? If you quit out of that sheet, does it stay, or leave a hole in the path of sheets, or drop all of its children too? (The leaf that you came from would have a source that isn't in the sheet stack.)

saulpw avatar Sep 30 '23 20:09 saulpw

When you go to the parent sheet, would the order stay the same, but the parent sheet would be highlighted instead?

Yes.

If you quit out of that sheet, does it stay, or leave a hole in the path of sheets, or drop all of its children too? (The leaf that you came from would have a source that isn't in the sheet stack.)

If it is possible to have a non-selectable hole, I think that would be fine, especially if you can see other still live ancestor sheets. It might be helpful if the root data (e.g. file, link) is still easy to reopen if it has been closed.

frosencrantz avatar Oct 01 '23 00:10 frosencrantz

When you go to the parent sheet, would the order stay the same, but the parent sheet would be highlighted instead?

Yes. It might be unclear what children sheets to show when you are on a parent, but I guess if you navigate to a parent from a child or grandchild it makes sense to keep showing the original children. That seems like it would be useful, and I feel like that would help me keep track of where I am within the sheets.

frosencrantz avatar Oct 01 '23 00:10 frosencrantz

So, I started playing with this, and one problem with this approach, is that subsheets from a frequency table are copies of the source sheet, and thus don't form a neat linear progression like you might expect. I don't think we don't want to change this, because the source sheet might be actively used--for instance, in a freq of a freq, when you pressed Enter it would show a subset of the first freqtable, but then you couldn't press Enter from there to go into a proper subset of the original source.

I'm wondering if what you ultimately want, @frosencrantz, is for the sheets sheet to be the list of sheets in the order you opened them, and for the sheets stack to go away. Since we have the shortcuts, we'd only need to keep track of the current sheet and the second-most-recently-visited sheet for Ctrl+^. Getting rid of the sheets stack concept entirely would require a bit of effort, but overall I think it might be less complicated than it currently is, for example with splitpane.

Then the sheets tab could be the sheets list as implemented above, which would be stable (unless you reordered them yourself manually). Maybe we remove consecutive tabs that have a simple parent-child relationship, and replace them with a one-character indicator. So instead of the tabs being a list of the current "path" from source to leaf sheets, it would be a list of leaves.

saulpw avatar Oct 04 '23 23:10 saulpw

@saulpw ordering the sheets in order of creation would go a long way for what I would like, since the sheet stack ends up confusing me. I still feel like there might be a way to have a pipeline sort of view of the sheets ( that might require a new field like "begat"), but I'd be happy to try what you are suggesting.

I think only showing leaf nodes though is not fully what I want. Many times I start from a frequency sheet and then end up wanting to go back to that frequency sheet to explore a different form but I want to keep the different paths that I've started down still in the in the sheets sheet. The frequency sheet is the fork in the road.

Would the single character you are proposing between sheets from the source to the leaves be clickable to get back to the represented frequency sheet? I think that is important.

I enjoy using the stack for directories in my shell, however it hasn't been very helpful in VisiData for me. Maybe others find the stack useful.

frosencrantz avatar Oct 08 '23 16:10 frosencrantz

One of the issues is there is limited horizontal screen space, single characters for intermediate sheets seems reasonable, but it might be useful if different types of sheets have different characters (like a frequency sheet might have a character, while a sheet from " has another). It would be useful if you could somehow make a particular intermediate sheet standout as an interesting spot where there are multiple children.

frosencrantz avatar Oct 10 '23 22:10 frosencrantz

What if we had a sheet-tree sheet, which shows something similar to the output of git log --graph --oneline --all? A graph could show the relationship between parent and child sheets.

daviewales avatar Oct 19 '23 03:10 daviewales

I agree that tabs without order stability are quite confusing. Fitting them linearly is also tricky…

This is a problem shared by IDEs and web browsers in general, together with the issue of tab proliferation. For UI inspiration, there is some extension for Firefox which displays the tab tree on the side in a neat way: https://addons.mozilla.org/en-US/firefox/addon/tree-style-tab/ Though it might take up way too much space if shown at all time.

Though in the case of Visidata, we indeed have a directed acyclic graph (due to the sheet joining) instead of a tree. The vertical ASCII graph similar to the commit graph of git or mercurial is quite nice indeed, allowing to have an overview of the relationships at a glance. Maybe that could be added to the sheets sheet?

pacien avatar Oct 28 '23 17:10 pacien

I do really like the quick demo from Saul earlier in this issue, except for the reordering because of the stack. If the ordering was stable I would be very happy with it.

I do like the idea of a sheet that is aware of the tree structure, where there are parents and children rows. It could also be used for looking at other data that is similar to git log. I was interested in this also for ps output, where there is a parent PID.

I think both of these could help with keeping the mental map of the sheets during a session.

I think the tree-style-tab is similar to what Saul was suggesting in the discussion https://github.com/saulpw/visidata/discussions/1656#discussioncomment-4616798.

So I like all the ideas. I guess I would combine them as:

  1. Add the navigation bar in the status bar. Because of screen space, this will need to compact, so there will be limited details, but it could show many sheets.
  2. Right-Clicking on the navigation bar would popup a tree like panel showing one line per sheet or maybe it just navigates to the sheet that backs the tab bar (see idea below). Left-Clicking would navigate to the sheet represented by that tab.
  3. Update the Sheet-Sheets sheets to be able to have a sheet-tree like view. This type of view should also be usable for other data.

Another thought I had is that the navigation bar/sheet tabs on the status panel should be a first class item. Via a command you can point the navigation bar to one column of another sheet. Typically this would be the name column of a FreqSheet , *IndexSheet or by default the SheetsSheet. The navigation bar will show the cell values of this column as the tab names. When you click on the tab, it would navigate the current sheet to be the result of doing a dive-row of the sheet connected to the navigation bar. You could use right-click to navigate to the source sheet for the tab bar. This maps completely to how a spreadsheet index sheet works, clicking the tab names causes a spreadsheet to switch to the data in that tab. Like on a spreadsheet the navigation bar might need the ability to scroll left/right when the values end up being too wide for the space provided. For anything with an index like a spreadsheet, it would be possible to go directly to the first sheet without starting at the IndexSheet. The Index sheet would be accessible via the navigation bar.

frosencrantz avatar Oct 28 '23 20:10 frosencrantz