Skip to content

feat: tmux module #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

feat: tmux module #229

wants to merge 16 commits into from

Conversation

35C4n0r
Copy link

@35C4n0r 35C4n0r commented Jul 14, 2025

Closes #203
/claim #203

Description

Introduce the tmux module

Demo

https://www.loom.com/share/ec8169d34c3043f7af2163b1a1a14a4b?sid=1ea8bcb2-3db0-43ca-965a-5ed42eec3448

Type of Change

  • New module
  • Bug fix
  • Feature/enhancement
  • Documentation
  • Other

Module Information

Path: registry/anomaly/modules/tmux
New version: v1.0.0
Breaking change: [ ] Yes [x] No

Testing & Validation

  • Tests pass (bun test)
  • Code formatted (bun run fmt)
  • Changes tested locally

Related Issues

#203

@35C4n0r
Copy link
Author

35C4n0r commented Jul 14, 2025

@matifali please review.

@35C4n0r 35C4n0r changed the title Feat tmux feat: tmux module Jul 14, 2025
@35C4n0r
Copy link
Author

35C4n0r commented Jul 15, 2025

@DevelopmentCats let me know if this needs any changes :)

@35C4n0r
Copy link
Author

35C4n0r commented Jul 16, 2025

My bad, added frontmatter.
Can you approve the CI run again.

@bpmct
Copy link
Member

bpmct commented Jul 18, 2025

Hey - We should have clarified this in the issue, but the ability to pre-define sessions in the module via variables, then them to show up as coder_app would be the key reason I see people use this.

@35C4n0r
Copy link
Author

35C4n0r commented Jul 18, 2025

@bpmct

pre-define sessions in the module via variables

Doable 👍🏻 (1 module/session, is that what we want ?)

then them to show up as coder_app

Ok, so it will show up in the UI as a button and then we redirect them to existing terminal and start the tmux server with that session ? Can you explain the expected flow.

@35C4n0r 35C4n0r requested a review from matifali July 19, 2025 04:53
@bpmct
Copy link
Member

bpmct commented Jul 20, 2025

@bpmct

pre-define sessions in the module via variables

Doable 👍🏻 (1 module/session, is that what we want ?)

then them to show up as coder_app

Ok, so it will show up in the UI as a button and then we redirect them to existing terminal and start the tmux server with that session ? Can you explain the expected flow.

Yes. We used to do this in the claude code module. here is an example:

resource "coder_app" "claude_code" {
slug = "claude-code"
display_name = "Claude Code"
agent_id = var.agent_id
command = <<-EOT
#!/bin/bash
set -e
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
if [ "${var.experiment_use_tmux}" = "true" ]; then
if tmux has-session -t claude-code 2>/dev/null; then
echo "Attaching to existing Claude Code tmux session." | tee -a "$HOME/.claude-code.log"
tmux attach-session -t claude-code
else
echo "Starting a new Claude Code tmux session." | tee -a "$HOME/.claude-code.log"
tmux new-session -s claude-code -c ${var.folder} "claude --dangerously-skip-permissions | tee -a \"$HOME/.claude-code.log\"; exec bash"
fi
elif [ "${var.experiment_use_screen}" = "true" ]; then
if screen -list | grep -q "claude-code"; then
echo "Attaching to existing Claude Code screen session." | tee -a "$HOME/.claude-code.log"
screen -xRR claude-code
else
echo "Starting a new Claude Code screen session." | tee -a "$HOME/.claude-code.log"
screen -S claude-code bash -c 'claude --dangerously-skip-permissions | tee -a "$HOME/.claude-code.log"; exec bash'
fi
else
cd ${var.folder}
claude
fi
EOT
icon = var.icon
order = var.order
group = var.group
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tmux session management module
3 participants