Skip to content

Comments

add layouts support #87

Open
jossephus wants to merge 3 commits intorockorager:mainfrom
jossephus:feat/add-layout-support
Open

add layouts support #87
jossephus wants to merge 3 commits intorockorager:mainfrom
jossephus:feat/add-layout-support

Conversation

@jossephus
Copy link
Contributor

This PR adds support for predefined layouts. It enables specifying layouts with tabs, panes and floating pane support.

supports

  • tabs with children panes and floating panes
  • direction for panes - col and row
  • title, window ratio, width, height
  • cwd, cmd for panes
  • visibility and specifying active tab
  • default_layout to use for all sessions

depends on: #86 since we are using prise.spawn to spawn a layout with cmd

example layouts config with video.

local config = {
    theme = { ... },
    default_layout = "ide",
    layouts = {
        simple = {
            name = "simple",
            tabs = {
                {
                    title = "Main",
                    root = { type = "pane" },
                    floating = {
                        pane = { type = "pane" },
                        visible = false,
                    },
                },
            },
        },
        monitor = {
            name = "monitor",
            active_tab = 2,
            tabs = {
                { title = "Shell", root = { type = "pane" } },
                { title = "Htop", root = { type = "pane", cmd = "htop" } },
            },
        },
        ide = {
            name = "ide",
            tabs = {
                {
                    title = "Code",
                    root = {
                        type = "split",
                        direction = "row",
                        children = {
                            {
                                type = "pane",
                                ratio = 0.3,
                                cwd = "/Users/jossephus/workspace/zigspace/src/prise",
                                cmd = "nvim AGENTS.md",
                            },
                            {
                                type = "split",
                                direction = "col",
                                ratio = 0.7,
                                children = {
                                    { type = "pane", ratio = 0.7, cmd = "nix develop --verbose" },
                                    { type = "pane", ratio = 0.3 },
                                },
                            },
                        },
                    },
                    floating = {
                        pane = { type = "pane", cwd = "~" },
                        visible = true,
                        width = 120,
                        height = 30,
                    },
                },
                {
                    title = "Logs",
                    root = { type = "pane", cwd = "/var/log" },
                },
            },
        },
    },
}
layouts.mp4

work and config design started with https://ampcode.com/threads/T-019bae2e-2593-7412-8b5e-d760915f9aac

@jossephus jossephus changed the title add predefined layouts support add layouts support Jan 11, 2026
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Layout System Review

Overall this is a solid implementation of the layout feature. The code follows TigerStyle conventions with good assertions at API boundaries, and the security-conscious approach in expand_path() (avoiding shell commands for directory checks) is appreciated.

Issues Found

  1. Line 1492: Missing .close existence check before calling pty:close() on floating panes (trivial fix provided)
  2. Line 3701: available_height can go negative on small screens, causing unexpected loop behavior (trivial fix provided)
  3. Line 2868: Magic number 15 for visible height calculation doesn't match items_start_y = 8 in build_layout_picker() - could cause scrolling inconsistencies

Minor Observations

  • The finalize_layout function is ~80 lines, slightly over the TigerStyle 70-line guideline, but the logic is cohesive and well-structured
  • Good error recovery pattern: building new state in memory before destroying old state

Full review context: https://ampcode.com/threads/T-019bafe4-7a36-732c-aba8-2d453c444ad1

@jossephus
Copy link
Contributor Author

fixed all three reported issues including the refactoring of finalize_layout

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.

1 participant