@@ -1088,6 +1088,147 @@ func TestTUIColumnOptionsCanEnableTasksWorkflow(t *testing.T) {
10881088 t .Fatal ("expected advanced.tasks_enabled to persist as true" )
10891089 }
10901090}
1091+
1092+ func TestTUIColumnOptionsCanDisableMouse (t * testing.T ) {
1093+ setupTuiTestEnv (t )
1094+
1095+ m := newModel (testServerAddr , withExternalIODisabled ())
1096+ m .currentView = viewQueue
1097+
1098+ result , _ := m .Update (tea.KeyMsg {Type : tea .KeyRunes , Runes : []rune {'o' }})
1099+ updated := result .(model )
1100+ if updated .currentView != viewColumnOptions {
1101+ t .Fatalf ("expected column options view, got %v" , updated .currentView )
1102+ }
1103+
1104+ idx := - 1
1105+ for i , opt := range updated .colOptionsList {
1106+ if opt .id == colOptionMouse {
1107+ idx = i
1108+ break
1109+ }
1110+ }
1111+ if idx < 0 {
1112+ t .Fatal ("expected mouse option in column options" )
1113+ }
1114+ updated .colOptionsIdx = idx
1115+
1116+ result , cmd := updated .Update (tea.KeyMsg {Type : tea .KeyEnter })
1117+ toggled := result .(model )
1118+ if toggled .mouseEnabled {
1119+ t .Fatal ("expected mouse to be disabled after toggle" )
1120+ }
1121+ if cmd == nil {
1122+ t .Fatal ("expected mouse toggle command after disabling mouse" )
1123+ }
1124+ msgs := collectMsgs (cmd )
1125+ if ! hasMsgType (msgs , "tea.disableMouseMsg" ) {
1126+ t .Fatalf ("expected disableMouseMsg after disabling mouse, got %v" , msgs )
1127+ }
1128+
1129+ result , cmd = toggled .Update (tea.KeyMsg {Type : tea .KeyEsc })
1130+ closed := result .(model )
1131+ if closed .currentView != viewQueue {
1132+ t .Fatalf ("expected to return to queue view, got %v" , closed .currentView )
1133+ }
1134+ if cmd == nil {
1135+ t .Fatal ("expected save command after closing column options" )
1136+ }
1137+ msgs = collectMsgs (cmd )
1138+ if len (msgs ) > 0 {
1139+ if last := msgs [len (msgs )- 1 ]; last != nil {
1140+ if errMsg , ok := last .(configSaveErrMsg ); ok {
1141+ t .Fatalf ("save config failed: %v" , errMsg .err )
1142+ }
1143+ }
1144+ }
1145+
1146+ cfg , err := config .LoadGlobal ()
1147+ if err != nil {
1148+ t .Fatalf ("LoadGlobal failed: %v" , err )
1149+ }
1150+ if cfg .MouseEnabled {
1151+ t .Fatal ("expected mouse_enabled to persist as false" )
1152+ }
1153+ }
1154+
1155+ func TestTUIColumnOptionsCanReEnableMouse (t * testing.T ) {
1156+ setupTuiTestEnv (t )
1157+
1158+ m := newModel (testServerAddr , withExternalIODisabled ())
1159+ m .currentView = viewQueue
1160+ m .width = 120
1161+ m .height = 20
1162+ m .jobs = []storage.ReviewJob {
1163+ makeJob (1 ),
1164+ makeJob (2 ),
1165+ makeJob (3 ),
1166+ }
1167+ m .selectedIdx = 0
1168+ m .selectedJobID = 1
1169+
1170+ result , _ := m .Update (tea.KeyMsg {Type : tea .KeyRunes , Runes : []rune {'o' }})
1171+ updated := result .(model )
1172+
1173+ idx := - 1
1174+ for i , opt := range updated .colOptionsList {
1175+ if opt .id == colOptionMouse {
1176+ idx = i
1177+ break
1178+ }
1179+ }
1180+ if idx < 0 {
1181+ t .Fatal ("expected mouse option in column options" )
1182+ }
1183+ updated .colOptionsIdx = idx
1184+
1185+ result , _ = updated .Update (tea.KeyMsg {Type : tea .KeyEnter })
1186+ disabled := result .(model )
1187+ if disabled .mouseEnabled {
1188+ t .Fatal ("expected mouse to be disabled after first toggle" )
1189+ }
1190+
1191+ result , cmd := disabled .Update (tea.KeyMsg {Type : tea .KeyEnter })
1192+ reenabled := result .(model )
1193+ if ! reenabled .mouseEnabled {
1194+ t .Fatal ("expected mouse to be enabled after second toggle" )
1195+ }
1196+ if cmd == nil {
1197+ t .Fatal ("expected mouse toggle command after enabling mouse" )
1198+ }
1199+ msgs := collectMsgs (cmd )
1200+ if ! hasMsgType (msgs , "tea.enableMouseCellMotionMsg" ) {
1201+ t .Fatalf ("expected enableMouseCellMotionMsg after enabling mouse, got %v" , msgs )
1202+ }
1203+
1204+ result , _ = reenabled .Update (tea.KeyMsg {Type : tea .KeyEsc })
1205+ closed := result .(model )
1206+ if closed .currentView != viewQueue {
1207+ t .Fatalf ("expected to return to queue view, got %v" , closed .currentView )
1208+ }
1209+
1210+ m2 , _ := updateModel (t , closed , mouseWheelDown ())
1211+ if m2 .selectedIdx != 1 || m2 .selectedJobID != 2 {
1212+ t .Fatalf ("expected wheel to work after re-enabling mouse, got idx=%d id=%d" , m2 .selectedIdx , m2 .selectedJobID )
1213+ }
1214+ }
1215+
1216+ func TestNewModelLoadsMouseDisabledFromConfig (t * testing.T ) {
1217+ tmpDir := setupTuiTestEnv (t )
1218+
1219+ configPath := filepath .Join (tmpDir , "config.toml" )
1220+ if err := os .WriteFile (configPath , []byte ("mouse_enabled = false\n " ), 0644 ); err != nil {
1221+ t .Fatalf ("write config: %v" , err )
1222+ }
1223+
1224+ m := newModel (testServerAddr )
1225+ if m .mouseEnabled {
1226+ t .Fatal ("expected newModel to load mouse_enabled = false from config" )
1227+ }
1228+ if len (programOptionsForModel (m )) != 1 {
1229+ t .Fatalf ("expected startup options without mouse capture when disabled, got %d options" , len (programOptionsForModel (m )))
1230+ }
1231+ }
10911232func TestTUISelection (t * testing.T ) {
10921233 t .Run ("MaintainedOnInsert" , func (t * testing.T ) {
10931234 m := newModel (testServerAddr , withExternalIODisabled ())
0 commit comments