clideck 1.30.7 → 1.30.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/config.js CHANGED
@@ -107,6 +107,23 @@ function matchPreset(cmd) {
107
107
  return PRESETS.find(p => binName(p.command) === bin);
108
108
  }
109
109
 
110
+ function firstCommandToken(command) {
111
+ const raw = String(command || '').trim();
112
+ const m = raw.match(/^(['"])(.*?)\1|^(\S+)/);
113
+ return m ? (m[2] || m[3] || '') : '';
114
+ }
115
+
116
+ function commandPathMissing(command) {
117
+ const token = firstCommandToken(command);
118
+ return !token || (token.startsWith('/') && !existsSync(token));
119
+ }
120
+
121
+ function isShellCommand(cmd, preset) {
122
+ return preset?.presetId === 'shell'
123
+ || cmd.presetId === 'shell'
124
+ || (!cmd.isAgent && !cmd.presetId && String(cmd.label || '').toLowerCase() === 'shell');
125
+ }
126
+
110
127
  function migrate(cfg) {
111
128
  // Migrate profiles → defaultTheme
112
129
  if (cfg.profiles && !cfg.defaultTheme) {
@@ -118,8 +135,13 @@ function migrate(cfg) {
118
135
  if (!cfg.defaultTheme || cfg.defaultTheme === 'solarized-dark') cfg.defaultTheme = 'catppuccin-mocha';
119
136
  // Backfill and sync fields from presets
120
137
  for (const cmd of cfg.commands) {
121
- const preset = cmd.presetId ? PRESETS.find(p => p.presetId === cmd.presetId) : matchPreset(cmd);
122
- if (preset?.presetId === 'shell' && (!cmd.command || (cmd.command === '/bin/zsh' && !existsSync('/bin/zsh')))) {
138
+ let preset = cmd.presetId ? PRESETS.find(p => p.presetId === cmd.presetId) : matchPreset(cmd);
139
+ if (isShellCommand(cmd, preset)) {
140
+ preset = PRESETS.find(p => p.presetId === 'shell') || preset;
141
+ cmd.presetId = 'shell';
142
+ cmd.label = cmd.label || 'Shell';
143
+ }
144
+ if (preset?.presetId === 'shell' && commandPathMissing(cmd.command)) {
123
145
  cmd.command = defaultShell;
124
146
  }
125
147
  // Stamp presetId for reliable lookup
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clideck",
3
- "version": "1.30.7",
3
+ "version": "1.30.9",
4
4
  "description": "One screen for all your AI coding agents — run, monitor, and manage multiple CLI agents from a single browser tab",
5
5
  "main": "server.js",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "trim-clip",
3
3
  "name": "Trim Clip",
4
- "version": "1.2.0",
4
+ "version": "1.3.0",
5
5
  "author": "CliDeck",
6
6
  "description": "Copy selected terminal text with trailing whitespace trimmed",
7
7
  "icon": "<svg class=\"w-4 h-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"6\" cy=\"6\" r=\"3\"/><circle cx=\"6\" cy=\"18\" r=\"3\"/><line x1=\"20\" y1=\"4\" x2=\"8.12\" y2=\"15.88\"/><line x1=\"14.47\" y1=\"14.48\" x2=\"20\" y2=\"20\"/><line x1=\"8.12\" y1=\"8.12\" x2=\"12\" y2=\"12\"/></svg>",
@@ -11,6 +11,13 @@
11
11
  "label": "Enabled",
12
12
  "type": "toggle",
13
13
  "default": true
14
+ },
15
+ {
16
+ "key": "hotkey",
17
+ "label": "Trim Key",
18
+ "type": "text",
19
+ "default": "F8",
20
+ "description": "Key to copy selected terminal text with whitespace trimmed (e.g. F8, Ctrl+Shift+C)"
14
21
  }
15
22
  ]
16
23
  }
@@ -1,31 +1,53 @@
1
1
  let enabled = true;
2
2
  let btnEl = null;
3
+ let apiRef = null;
4
+ let currentHotkey = null;
5
+
6
+ async function trimAndCopy() {
7
+ if (!enabled) return;
8
+ const text = apiRef.getTerminalSelection();
9
+ if (!text || !text.trim()) { apiRef.toast('Select text to copy & trim', { type: 'warn' }); return; }
10
+ const trimmed = text
11
+ .split('\n')
12
+ .map(l => l.trimEnd())
13
+ .join('\n')
14
+ .replace(/^\n+/, '').replace(/\n+$/, '');
15
+ try {
16
+ await navigator.clipboard.writeText(trimmed);
17
+ const saved = text.length - trimmed.length;
18
+ apiRef.toast(saved ? `Copied & trimmed ${saved} char${saved !== 1 ? 's' : ''}` : 'Copied', { type: 'success' });
19
+ } catch {
20
+ apiRef.toast('Clipboard access denied — allow it in browser site settings', { type: 'error' });
21
+ }
22
+ }
23
+
24
+ function bindHotkey(hotkey) {
25
+ const next = hotkey || 'F8';
26
+ if (next === currentHotkey) return;
27
+ const prev = currentHotkey;
28
+ if (prev) apiRef.unregisterHotkey(prev);
29
+ if (apiRef.registerHotkey(next, trimAndCopy)) {
30
+ currentHotkey = next;
31
+ } else if (prev) {
32
+ apiRef.registerHotkey(prev, trimAndCopy);
33
+ apiRef.toast(`Hotkey "${next}" is taken, keeping "${prev}"`, { type: 'warn' });
34
+ } else {
35
+ apiRef.toast(`Hotkey "${next}" is unavailable`, { type: 'warn' });
36
+ }
37
+ }
3
38
 
4
39
  export function init(api) {
40
+ apiRef = api;
5
41
  api.onMessage('settings', (msg) => {
6
42
  enabled = msg.enabled !== false;
7
43
  if (btnEl) btnEl.style.display = enabled ? '' : 'none';
44
+ bindHotkey(msg.hotkey || 'F8');
8
45
  });
9
46
  api.send('getSettings');
10
47
 
11
48
  btnEl = api.addToolbarButton({
12
49
  title: 'Trim & Copy',
13
50
  icon: '<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><path d="M20 4 8.12 15.88M14.47 14.48 20 20M8.12 8.12 12 12"/></svg>',
14
- async onClick() {
15
- const text = api.getTerminalSelection();
16
- if (!text || !text.trim()) { api.toast('Select text to copy & trim', { type: 'warn' }); return; }
17
- const trimmed = text
18
- .split('\n')
19
- .map(l => l.trimEnd())
20
- .join('\n')
21
- .replace(/^\n+/, '').replace(/\n+$/, '');
22
- try {
23
- await navigator.clipboard.writeText(trimmed);
24
- const saved = text.length - trimmed.length;
25
- api.toast(saved ? `Copied & trimmed ${saved} char${saved !== 1 ? 's' : ''}` : 'Copied', { type: 'success' });
26
- } catch {
27
- api.toast('Clipboard access denied — allow it in browser site settings', { type: 'error' });
28
- }
29
- }
51
+ onClick: trimAndCopy,
30
52
  });
31
53
  }
@@ -135,10 +135,17 @@ function ensureCommandForPreset(preset) {
135
135
  }
136
136
 
137
137
  function ensureShellCommand() {
138
- let cmd = state.cfg.commands.find(c => c.presetId === 'shell' || (!c.isAgent && !c.presetId));
139
- if (cmd) return cmd;
140
138
  const shellPreset = state.presets.find(p => p.presetId === 'shell');
141
139
  const command = shellPreset?.command || state.cfg.defaultShell;
140
+ let cmd = state.cfg.commands.find(c => c.presetId === 'shell' || (!c.isAgent && !c.presetId && String(c.label || '').toLowerCase() === 'shell'));
141
+ if (cmd) {
142
+ if (!cmd.command || (cmd.command === '/bin/zsh' && command && command !== '/bin/zsh')) {
143
+ cmd.presetId = 'shell';
144
+ cmd.command = command;
145
+ send({ type: 'config.update', config: state.cfg });
146
+ }
147
+ return cmd;
148
+ }
142
149
  if (!command) return null;
143
150
  cmd = {
144
151
  id: crypto.randomUUID(),