ccmanager 2.11.0 → 2.11.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Kodai Kabasawa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -6,6 +6,7 @@ export declare class ConfigurationManager {
6
6
  private legacyShortcutsPath;
7
7
  private configDir;
8
8
  private config;
9
+ private worktreeLastOpened;
9
10
  constructor();
10
11
  private loadConfig;
11
12
  private migrateLegacyShortcuts;
@@ -30,6 +30,12 @@ export class ConfigurationManager {
30
30
  writable: true,
31
31
  value: {}
32
32
  });
33
+ Object.defineProperty(this, "worktreeLastOpened", {
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true,
37
+ value: new Map()
38
+ });
33
39
  // Determine config directory based on platform
34
40
  const homeDir = homedir();
35
41
  this.configDir =
@@ -275,17 +281,13 @@ export class ConfigurationManager {
275
281
  this.setCommandPresets(presets);
276
282
  }
277
283
  getWorktreeLastOpened() {
278
- return this.config.worktreeLastOpened || {};
284
+ return Object.fromEntries(this.worktreeLastOpened);
279
285
  }
280
286
  setWorktreeLastOpened(worktreePath, timestamp) {
281
- if (!this.config.worktreeLastOpened) {
282
- this.config.worktreeLastOpened = {};
283
- }
284
- this.config.worktreeLastOpened[worktreePath] = timestamp;
285
- this.saveConfig();
287
+ this.worktreeLastOpened.set(worktreePath, timestamp);
286
288
  }
287
289
  getWorktreeLastOpenedTime(worktreePath) {
288
- return this.config.worktreeLastOpened?.[worktreePath];
290
+ return this.worktreeLastOpened.get(worktreePath);
289
291
  }
290
292
  // Effect-based methods for type-safe error handling
291
293
  /**
@@ -303,9 +303,13 @@ export class SessionManager extends EventEmitter {
303
303
  const session = this.sessions.get(worktreePath);
304
304
  if (session) {
305
305
  session.isActive = active;
306
- // If becoming active, emit a restore event with the output history
307
- if (active && session.outputHistory.length > 0) {
308
- this.emit('sessionRestore', session);
306
+ // If becoming active, record the timestamp when this worktree was opened
307
+ if (active) {
308
+ configurationManager.setWorktreeLastOpened(worktreePath, Date.now());
309
+ // Emit a restore event with the output history if available
310
+ if (session.outputHistory.length > 0) {
311
+ this.emit('sessionRestore', session);
312
+ }
309
313
  }
310
314
  }
311
315
  }
@@ -641,10 +641,17 @@ export class WorktreeService {
641
641
  if (sortByLastSession) {
642
642
  worktrees.sort((a, b) => {
643
643
  // Get last opened timestamps for both worktrees
644
- const timeA = configurationManager.getWorktreeLastOpenedTime(a.path) || 0;
645
- const timeB = configurationManager.getWorktreeLastOpenedTime(b.path) || 0;
644
+ const timeA = configurationManager.getWorktreeLastOpenedTime(a.path);
645
+ const timeB = configurationManager.getWorktreeLastOpenedTime(b.path);
646
+ // If both timestamps are undefined, preserve original order
647
+ if (timeA === undefined && timeB === undefined) {
648
+ return 0;
649
+ }
650
+ // If only one is undefined, treat it as older (0)
651
+ const compareTimeA = timeA || 0;
652
+ const compareTimeB = timeB || 0;
646
653
  // Sort in descending order (most recent first)
647
- return timeB - timeA;
654
+ return compareTimeB - compareTimeA;
648
655
  });
649
656
  }
650
657
  return worktrees;
@@ -98,7 +98,6 @@ export interface ConfigurationData {
98
98
  worktree?: WorktreeConfig;
99
99
  command?: CommandConfig;
100
100
  commandPresets?: CommandPresetsConfig;
101
- worktreeLastOpened?: Record<string, number>;
102
101
  }
103
102
  export interface GitProject {
104
103
  name: string;
@@ -4,7 +4,7 @@ import stripAnsi from 'strip-ansi';
4
4
  import { getStatusDisplay } from '../constants/statusIcons.js';
5
5
  import { formatGitFileChanges, formatGitAheadBehind, formatParentBranch, } from './gitStatus.js';
6
6
  // Constants
7
- const MAX_BRANCH_NAME_LENGTH = 40; // Maximum characters for branch name display
7
+ const MAX_BRANCH_NAME_LENGTH = 70; // Maximum characters for branch name display
8
8
  const MIN_COLUMN_PADDING = 2; // Minimum spaces between columns
9
9
  // Utility function to truncate strings with ellipsis
10
10
  export function truncateString(str, maxLength) {
@@ -156,7 +156,7 @@ describe('prepareWorktreeItems', () => {
156
156
  branch: 'feature/this-is-a-very-long-branch-name-that-should-be-truncated',
157
157
  };
158
158
  const items = prepareWorktreeItems([longBranch], []);
159
- expect(items[0]?.baseLabel.length).toBeLessThanOrEqual(50); // 40 + status + default
159
+ expect(items[0]?.baseLabel.length).toBeLessThanOrEqual(80); // 70 + status + default
160
160
  });
161
161
  });
162
162
  describe('column alignment', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccmanager",
3
- "version": "2.11.0",
3
+ "version": "2.11.2",
4
4
  "description": "TUI application for managing multiple Claude Code sessions across Git worktrees",
5
5
  "license": "MIT",
6
6
  "author": "Kodai Kabasawa",