Skip to content

Commit 6d0c19d

Browse files
committed
feat: add multi-session support for tmux in Coder UI
1 parent a1b4848 commit 6d0c19d

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

registry/anomaly/modules/tmux/README.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,30 @@ up a default or custom tmux configuration with session save/restore capabilities
2323
- `tmux-plugins/tmux-continuum`
2424
- Supports custom tmux configuration
2525
- Enables automatic session save
26-
- To restore in case of server restart `prefix + ctrl+r`
2726
- Configurable save interval
27+
- **Supports multiple named tmux sessions, each as a separate app in the Coder UI**
2828

2929
## Usage
3030

3131
```tf
3232
module "tmux" {
3333
source = "path/to/this/module"
3434
agent_id = coder_agent.example.id
35-
tmux_config = "" # Optional: custom tmux.conf content
36-
save_interval = 1 # Optional: save interval in minutes
35+
tmux_config = "" # Optional: custom tmux.conf content
36+
save_interval = 1 # Optional: save interval in minutes
37+
sessions = ["default", "dev", "ops"] # Optional: list of tmux sessions
38+
order = 1 # Optional: UI order
39+
group = "Terminal" # Optional: UI group
40+
icon = "/icon/tmux.svg" # Optional: app icon
3741
}
3842
```
3943

44+
## Multi-Session Support
45+
46+
This module can provision multiple tmux sessions, each as a separate app in the Coder UI. Use the `sessions` variable to specify a list of session names. For each session, a `coder_app` is created, allowing you to launch or attach to that session directly from the UI.
47+
48+
- **sessions**: List of tmux session names (default: `["default"]`).
49+
4050
## How It Works
4151

4252
- **tmux Installation:**
@@ -58,19 +68,24 @@ module "tmux" {
5868

5969
```tf
6070
module "tmux" {
61-
source = "./registry/anomaly/modules/tmux"
62-
agent_id = var.agent_id
63-
tmux_config = <<-EOT
71+
source = "./registry/anomaly/modules/tmux"
72+
agent_id = var.agent_id
73+
sessions = ["default", "dev", "anomaly"]
74+
tmux_config = <<-EOT
6475
set -g mouse on
6576
set -g history-limit 10000
6677
EOT
78+
group = "Terminal"
79+
order = 2
6780
}
6881
```
6982

7083
> [!NOTE]
84+
>
7185
> - If you provide a custom `tmux_config`, it will completely replace the default configuration. Ensure you include plugin
72-
and TPM initialization lines if you want plugin support.
86+
> and TPM initialization lines if you want plugin support and session persistence.
7387
> - The script will attempt to install dependencies using `sudo` where required.
7488
> - If `git` is not installed, TPM installation will fail.
75-
> - To restore in case of server restart `prefix + ctrl+r`
76-
> - If you are using custom config, you'll be responsible for setting up persistence
89+
> - If you are using custom config, you'll be responsible for setting up persistence and plugins.
90+
> - The `order`, `group`, and `icon` variables allow you to customize how tmux apps appear in the Coder UI.
91+
> - In case of session restart or shh reconnection, the tmux session will be automatically restored :)

registry/anomaly/modules/tmux/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ variable "icon" {
4545
}
4646

4747
variable "sessions" {
48-
type = list(string)
48+
type = list(string)
4949
description = "List of tmux sessions to create or start."
50-
default = ["default"]
50+
default = ["default"]
5151
}
5252

5353
resource "coder_script" "tmux" {

0 commit comments

Comments
 (0)