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 +1 -1
- package/src/cli.ts +27 -15
- package/src/components/tabs/TabContext.tsx +15 -9
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -22,32 +22,44 @@ try {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
async function openAsApp(url: string) {
|
|
25
|
-
const {
|
|
25
|
+
const { execFile: execFileCb } = await import('child_process');
|
|
26
|
+
const fs = await import('fs');
|
|
26
27
|
const platform = process.platform;
|
|
27
28
|
|
|
28
|
-
//
|
|
29
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
{ bin: 'chrome', args: [`--app=${url}`] },
|
|
41
|
+
{ bin: 'msedge', args: [`--app=${url}`] },
|
|
42
|
+
]
|
|
41
43
|
: [
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
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
|
-
|
|
97
|
-
|
|
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));
|