Skip to content

Sync: Workspace Commands & Configurable UI Options - #12

Open
malikbenkirane wants to merge 7 commits into
4sp1:mainfrom
malikbenkirane:main
Open

Sync: Workspace Commands & Configurable UI Options#12
malikbenkirane wants to merge 7 commits into
4sp1:mainfrom
malikbenkirane:main

Conversation

@malikbenkirane

Copy link
Copy Markdown
Contributor

This PR adds comprehensive workspace management, makes client UI attachment fully configurable, and finalises the earlier hexagonal‑architecture refactor.

Key changes

  • Workspace commands: list, labeled navigation (neomux workspace <LABEL>), and delete for clean removal of workspaces.
  • Configurable UI attachment: Introduce OptionTermUI, OptionNeovideUI, and generic OptionUI allowing terminal or Neovide clients with custom dimensions and fork behaviour; default shifts to terminal UI.
  • API renaming: WithDebugOptionDebug, WithMinPortOptionStartPort for clearer option semantics.
  • Domain/repository layer: Separate domain models from adapters, providing repository interfaces and moving the SQLite adapter to the proper port‑adapter package.
  • Miscellaneous: Add MRU migration scaffolding and set a default Neovide size of 160 rows × 240 cols.

Notes

  • Update any code that still uses the old With* option functions.
  • The default client change may affect scripts expecting an automatic Neovide launch; explicitly use OptionNeovideUI if that behaviour is required.

- add migrations index
- add migration alter 

TODO: 
- Test migration
- Upgrade adapter
Implements hexagonal architecture by separating domain models from
infrastructure adapters. Previously, adapter-specific types
(proc_adapter.Process, state_adapter.NvimServer) were used directly
throughout the application, creating tight coupling between application
logic and infrastructure implementations.

Changes:
- Creates domain models in `internal/domain/proc` and
  `internal/domain/server` representing core application entities
- Defines repository interfaces in `internal/repo` (Server, Proc) to
  establish clear contracts between layers
- Moves SQLite adapter from `internal/adapter/sqlite/state` to
  `internal/adapter/state/sqlite` following port-adapter naming
- Updates all adapters to implement repository interfaces and return
  domain types instead of adapter-specific structs
- Removes interface definitions from adapter packages, centralizing them
  in the repository layer

This inversion of dependencies allows the core application logic to
remain independent of database or OS-specific implementations. Future
enthusiat developers can now add new adapters (e.g., PostgreSQL,
different process APIs) by implementing repo.Server or repo.Proc without
modifying application code.
Renames functional option constructors from `WithX` to `OptionX` pattern
to improve API consistency and readability. The previous `With` prefix
is typically reserved for builder patterns that chain method calls,
whereas these are standalone function options passed to constructors.

Changes:
- `WithDebug()` → `OptionDebug()`
- `WithMinPort()` → `OptionStartPort()` (also improves naming clarity by
  indicating this sets the starting port for range allocation rather
  than a minimum constraint)

This follows the hexagonal architecture refactoring from commit 77a73c6
which established clearer naming conventions across the repository
layer. The new names better communicate that these are discrete
configuration options rather than chainable modifiers.

All callsites in cmd/attach.go, cmd/duplicate.go, and cmd/new.go updated
to use the new function names. No functional changes to application
behavior.
The client attachment functionality was previously hardcoded to use
Neovide with specific grid dimensions and frame settings. This made it
impossible to use the application with terminal-based nvim or to
customize the UI configuration for different use cases.

I personally churned away from Neovide because of some issues I
experienced attaching a session to a previously detached session
observing empty buffers (UI-wisely only).  I guess these come from the
redrawn logic and [some people are also complaining from crashes using
Neovide noice.nvim](neovim/neovim#22344).

I previously implemented [last-font.nvim] plugin to be able to set GUI
fonts persistent through Neovide (or any other Neovim GUI) sessions. But
as I am turning back to TUI, I choosed to come back to Wezterm that
offers `config.font_size` and `config.font`

> A couple `sed` commands and your're set!

As being a fan of the [fish-shell](https://fishshell.com/) I implemented
a couple [autoloading fish functions](
https://fishshell.com/docs/current/language.html#autoloading-functions)
to manage `wezfont` (this one is coupled with
[sk](https://github.com/skim-rs/skim for fzf-like font selection) and
`wezfont_size SIZE`.

If you want to get the bird-eye picture checkout my dotfiles for
[nvim](https://github.com/malikbenkirane/.nvim) and
[fish](https://github.com/malikbenkirane/.fish).

To wrap up the disgression on my "intelligent" setup, being a "dumb"
maxos user that would prefer to work on
[OpenBSD](https://www.openbsd.org), I do use
[raycast](https://www.raycast.com/) and the terminal UIcombines well
with the emoji extension 😅 ...

Now, this commit introduces three new option functions to configure how
clients attach to the server:

- OptionTermUI(): Configures terminal-based nvim using --remote-ui,
  which runs in the foreground and inherits stdio streams
- OptionNeovideUI(columns, lines): Configures Neovide with customizable
  grid dimensions (defaults to 160x120) and transparent frames, which
  forks as a background process
- OptionUI(fork, command, args...): Low-level option that accepts any
  command with format string substitution for port numbers

The Config struct now stores a cmd function that generates the exec.Cmd
with the appropriate port, plus a fork boolean that determines whether
to use cmd.Start() (background) or cmd.Run() (foreground). Terminal UI
is applied as the default configuration, replacing the previous
hardcoded Neovide behavior.

The Attach() method now properly configures stdio streams and selects
the execution mode based on the fork setting, enabling both interactive
terminal usage and GUI client workflows.
Simplifies navigation and context switching for users handling multiple
project directories.

Introduces a workspace concept where each workspace is a labeled
file‑system path.

Provides a `neomux workspace list` command to display all defined
workspaces and a `neomux workspace <LABEL>` command to change to the
associated directory and start a new shell.

Part of 4sp1#10
Adds a command to delete Neomux workspaces.  

Simplifies cleanup of unused or obsolete workspace configurations.  

Improves user workflow by providing a direct way to remove workspaces
without manual state edit.

Part of 4sp1#11
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