idea-manager 0.9.4 → 0.9.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idea-manager",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "description": "AI 기반 브레인스토밍 → 구조화 → 프롬프트 생성 도구. MCP Server 내장.",
5
5
  "keywords": [
6
6
  "brainstorm",
package/src/cli.ts CHANGED
@@ -22,32 +22,44 @@ try {
22
22
  }
23
23
 
24
24
  async function openAsApp(url: string) {
25
- const { exec: execCb } = await import('child_process');
25
+ const { execFile: execFileCb } = await import('child_process');
26
+ const fs = await import('fs');
26
27
  const platform = process.platform;
27
28
 
28
- // Shell commands for --app mode per platform
29
- const commands: string[] =
29
+ // Direct browser binary paths — avoids macOS `open -a --args` being ignored
30
+ // when browser is already running
31
+ const browsers: { bin: string; args: string[] }[] =
30
32
  platform === 'darwin'
31
33
  ? [
32
- `open -a "Google Chrome" --args --app=${url}`,
33
- `open -a "Microsoft Edge" --args --app=${url}`,
34
- `open -a "Chromium" --args --app=${url}`,
34
+ { bin: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', args: [`--app=${url}`] },
35
+ { bin: '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge', args: [`--app=${url}`] },
36
+ { bin: '/Applications/Chromium.app/Contents/MacOS/Chromium', args: [`--app=${url}`] },
35
37
  ]
36
38
  : platform === 'win32'
37
39
  ? [
38
- `start "" "chrome" "--app=${url}"`,
39
- `start "" "msedge" "--app=${url}"`,
40
- ]
40
+ { bin: 'chrome', args: [`--app=${url}`] },
41
+ { bin: 'msedge', args: [`--app=${url}`] },
42
+ ]
41
43
  : [
42
- `google-chrome --app=${url}`,
43
- `chromium-browser --app=${url}`,
44
- `microsoft-edge --app=${url}`,
45
- ];
44
+ { bin: 'google-chrome', args: [`--app=${url}`] },
45
+ { bin: 'chromium-browser', args: [`--app=${url}`] },
46
+ { bin: 'microsoft-edge', args: [`--app=${url}`] },
47
+ ];
48
+
49
+ for (const browser of browsers) {
50
+ // On macOS, check binary exists before trying
51
+ if (platform === 'darwin' && !fs.existsSync(browser.bin)) continue;
46
52
 
47
- for (const cmd of commands) {
48
53
  try {
49
54
  await new Promise<void>((resolve, reject) => {
50
- execCb(cmd, (err) => { if (err) reject(err); else resolve(); });
55
+ const child = execFileCb(browser.bin, browser.args, {
56
+ shell: platform === 'win32',
57
+ detached: true,
58
+ stdio: 'ignore',
59
+ }, (err) => { if (err) reject(err); });
60
+ child.unref();
61
+ // Browser launched — resolve after brief delay
62
+ setTimeout(resolve, 500);
51
63
  });
52
64
  return; // success
53
65
  } catch {
@@ -92,16 +92,11 @@ function tabReducer(state: ITabState, action: TabAction): ITabState {
92
92
 
93
93
  const STORAGE_KEY = 'im-tabs';
94
94
 
95
+ const DEFAULT_STATE: ITabState = { tabs: [DASHBOARD_TAB], activeTabId: 'dashboard' };
96
+
95
97
  function loadState(): ITabState {
96
- if (typeof window === 'undefined') return { tabs: [DASHBOARD_TAB], activeTabId: 'dashboard' };
97
- try {
98
- const raw = localStorage.getItem(STORAGE_KEY);
99
- if (raw) {
100
- const parsed = JSON.parse(raw) as ITabState;
101
- return { tabs: ensureDashboard(parsed.tabs), activeTabId: parsed.activeTabId };
102
- }
103
- } catch { /* ignore */ }
104
- return { tabs: [DASHBOARD_TAB], activeTabId: 'dashboard' };
98
+ // Always return default on initial render to match server HTML
99
+ return DEFAULT_STATE;
105
100
  }
106
101
 
107
102
  interface TabContextValue {
@@ -126,6 +121,17 @@ export function useTabContext() {
126
121
  export function TabProvider({ children }: { children: ReactNode }) {
127
122
  const [state, dispatch] = useReducer(tabReducer, undefined, loadState);
128
123
 
124
+ // Hydrate from localStorage after mount (avoids SSR mismatch)
125
+ useEffect(() => {
126
+ try {
127
+ const raw = localStorage.getItem(STORAGE_KEY);
128
+ if (raw) {
129
+ const parsed = JSON.parse(raw) as ITabState;
130
+ dispatch({ type: 'HYDRATE', state: { tabs: ensureDashboard(parsed.tabs), activeTabId: parsed.activeTabId } });
131
+ }
132
+ } catch { /* ignore */ }
133
+ }, []);
134
+
129
135
  // Persist to localStorage
130
136
  useEffect(() => {
131
137
  localStorage.setItem(STORAGE_KEY, JSON.stringify(state));