@geminilight/mindos 0.2.0 → 0.2.1

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/README.md CHANGED
@@ -130,7 +130,7 @@ mindos onboard
130
130
  ```
131
131
 
132
132
  The setup wizard will guide you through:
133
- 1. Knowledge base path → default `~/.mindos/my-mind`
133
+ 1. Knowledge base path → default `~/MindOS`
134
134
  2. Choose template (en / zh / empty / custom)
135
135
  3. Ports (Web UI + MCP)
136
136
  4. Auth token (auto-generated or passphrase-seeded)
@@ -153,7 +153,7 @@ Or skip the wizard and edit `~/.mindos/config.json` manually (see Config Referen
153
153
 
154
154
  ```json
155
155
  {
156
- "mindRoot": "~/.mindos/my-mind",
156
+ "mindRoot": "~/MindOS",
157
157
  "port": 3000,
158
158
  "mcpPort": 8787,
159
159
  "authToken": "",
@@ -179,7 +179,7 @@ Or skip the wizard and edit `~/.mindos/config.json` manually (see Config Referen
179
179
 
180
180
  | Field | Default | Description |
181
181
  | :--- | :--- | :--- |
182
- | `mindRoot` | `~/.mindos/my-mind` | **Required**. Absolute path to the knowledge base root. |
182
+ | `mindRoot` | `~/MindOS` | **Required**. Absolute path to the knowledge base root. |
183
183
  | `port` | `3000` | Optional. Web app port. |
184
184
  | `mcpPort` | `8787` | Optional. MCP server port. |
185
185
  | `authToken` | — | Optional. Protects App `/api/*` and MCP `/mcp` with bearer token auth. For Agent / MCP clients. Recommended when exposed to a network. |
package/README_zh.md CHANGED
@@ -82,6 +82,7 @@ MindOS 是一个**人机协同心智系统**——基于本地优先的协作知
82
82
  - **引用同步**:通过引用与反向链接保持跨文件状态一致。
83
83
  - **知识图谱**:可视化笔记间关系与依赖。
84
84
  - **Git 时光机**:记录修改历史,支持审计与安全回滚。
85
+ - **跨设备同步**:通过 Git 自动 commit、push、pull —— 一台设备的编辑几分钟内同步到所有设备。
85
86
 
86
87
  <details>
87
88
  <summary><strong>即将到来</strong></summary>
@@ -131,12 +132,13 @@ mindos onboard --install-daemon
131
132
  > `--install-daemon`:配置完成后,自动将 MindOS 安装为后台 OS 服务(关闭终端仍运行,崩溃自动重启)。
132
133
 
133
134
  配置向导将引导你完成:
134
- 1. 知识库路径 → 默认 `~/.mindos/my-mind`
135
+ 1. 知识库路径 → 默认 `~/MindOS`
135
136
  2. 选择模板(en / zh / empty / custom)
136
137
  3. 端口配置(Web UI + MCP)
137
138
  4. Auth token(自动生成或口令派生)
138
139
  5. Web UI 访问密码(可选)
139
140
  6. 配置 AI Provider(Anthropic / OpenAI)+ API Key — 或选择 **skip**,稍后通过 `mindos config set` 补填
141
+ 7. 启动模式 — **后台服务**(推荐,开机自启)或前台运行
140
142
 
141
143
  配置自动保存到 `~/.mindos/config.json`。
142
144
 
@@ -153,34 +155,50 @@ mindos onboard --install-daemon
153
155
 
154
156
  ```json
155
157
  {
156
- "mindRoot": "~/.mindos/my-mind",
158
+ "mindRoot": "~/MindOS",
157
159
  "port": 3000,
158
160
  "mcpPort": 8787,
159
161
  "authToken": "",
160
162
  "webPassword": "",
163
+ "startMode": "daemon",
161
164
  "ai": {
162
165
  "provider": "anthropic",
163
166
  "providers": {
164
167
  "anthropic": { "apiKey": "sk-ant-...", "model": "claude-sonnet-4-6" },
165
168
  "openai": { "apiKey": "sk-...", "model": "gpt-5.4", "baseUrl": "" }
166
169
  }
170
+ },
171
+ "sync": {
172
+ "enabled": true,
173
+ "provider": "git",
174
+ "remote": "origin",
175
+ "branch": "main",
176
+ "autoCommitInterval": 30,
177
+ "autoPullInterval": 300
167
178
  }
168
179
  }
169
180
  ```
170
181
 
171
182
  | 字段 | 默认值 | 说明 |
172
183
  | :--- | :--- | :--- |
173
- | `mindRoot` | `~/.mindos/my-mind` | **必填**。知识库根目录的绝对路径 |
184
+ | `mindRoot` | `~/MindOS` | **必填**。知识库根目录的绝对路径 |
174
185
  | `port` | `3000` | 可选。Web 服务端口 |
175
186
  | `mcpPort` | `8787` | 可选。MCP 服务端口 |
176
187
  | `authToken` | — | 可选。保护 App `/api/*` 和 MCP `/mcp` 的 Bearer Token 认证。供 Agent / MCP 客户端使用,暴露到网络时建议设置 |
177
188
  | `webPassword` | — | 可选。为 Web UI 添加登录密码保护。供浏览器访问,与 `authToken` 相互独立 |
189
+ | `startMode` | `start` | 启动模式:`daemon`(后台服务,开机自启)、`start`(前台)或 `dev` |
178
190
  | `ai.provider` | `anthropic` | 当前使用的 provider:`anthropic` 或 `openai` |
179
191
  | `ai.providers.anthropic.apiKey` | — | Anthropic API Key |
180
192
  | `ai.providers.anthropic.model` | `claude-sonnet-4-6` | Anthropic 模型 ID |
181
193
  | `ai.providers.openai.apiKey` | — | OpenAI API Key |
182
194
  | `ai.providers.openai.model` | `gpt-5.4` | OpenAI 模型 ID |
183
195
  | `ai.providers.openai.baseUrl` | — | 可选。用于代理或 OpenAI 兼容 API 的自定义接口地址 |
196
+ | `sync.enabled` | `false` | 启用/禁用 Git 自动同步 |
197
+ | `sync.provider` | `git` | 同步方式(目前仅支持 `git`) |
198
+ | `sync.remote` | `origin` | Git 远程仓库名 |
199
+ | `sync.branch` | `main` | 同步分支 |
200
+ | `sync.autoCommitInterval` | `30` | 文件变更后自动 commit+push 的延迟秒数 |
201
+ | `sync.autoPullInterval` | `300` | 自动从远程 pull 的间隔秒数 |
184
202
 
185
203
  多个 provider 可以同时配置,切换时只需修改 `ai.provider` 字段,无需重新填写 API Key。Shell 环境变量(`ANTHROPIC_API_KEY`、`OPENAI_API_KEY` 等)优先级高于配置文件。
186
204
 
@@ -192,6 +210,12 @@ mindos onboard --install-daemon
192
210
  > [!TIP]
193
211
  > 使用 `--install-daemon` 时,MindOS 会作为后台 OS 服务安装并自动启动,无需手动执行 `mindos start`。如果跳过了该参数,运行 `mindos start` 手动启动,或运行 `mindos update` 升级到最新版本。
194
212
 
213
+ 在浏览器中打开 Web UI:
214
+
215
+ ```bash
216
+ mindos open
217
+ ```
218
+
195
219
  ### 3. 通过 MindOS Agent 注入你的个人心智
196
220
 
197
221
  1. 打开 MindOS GUI 中内置的 Agent 对话面板。
@@ -386,12 +410,13 @@ MindOS/
386
410
  ├── mcp/ # MCP Server — 将工具映射到 App API 的 HTTP 适配器
387
411
  ├── skills/ # MindOS Skills(`mindos`、`mindos-zh`)— Agent 工作流指南
388
412
  ├── templates/ # 预设模板(`en/`、`zh/`、`empty/`)— onboard 时复制到知识库目录
389
- ├── bin/ # CLI 入口(`mindos onboard`、`mindos start`、`mindos dev`、`mindos token`)
413
+ ├── bin/ # CLI 入口(`mindos onboard`、`mindos start`、`mindos open`、`mindos sync`、`mindos token`)
390
414
  ├── scripts/ # 配置向导与辅助脚本
391
415
  └── README.md
392
416
 
393
417
  ~/.mindos/ # 用户数据目录(项目外,不会被提交)
394
- ├── config.json # 所有配置(AI 密钥、端口、Auth token、知识库路径)
418
+ ├── config.json # 所有配置(AI 密钥、端口、Auth token、同步设置)
419
+ ├── sync-state.json # 同步状态(最后同步时间、冲突文件)
395
420
  └── my-mind/ # 你的私有知识库(默认路径,onboard 时可自定义)
396
421
  ```
397
422
 
@@ -407,11 +432,19 @@ MindOS/
407
432
  | `mindos start --daemon` | 安装并以后台 OS 服务方式启动(关闭终端仍运行,崩溃自动重启) |
408
433
  | `mindos dev` | 启动 app + MCP 服务(开发模式,热更新) |
409
434
  | `mindos dev --turbopack` | 开发模式 + Turbopack(更快的 HMR) |
435
+ | `mindos open` | 在默认浏览器中打开 Web UI |
410
436
  | `mindos stop` | 停止正在运行的 MindOS 进程 |
411
437
  | `mindos restart` | 停止后重新启动 |
412
438
  | `mindos build` | 手动构建生产版本 |
413
439
  | `mindos mcp` | 仅启动 MCP 服务 |
414
440
  | `mindos token` | 查看当前 Auth token 及 MCP 配置片段 |
441
+ | `mindos sync` | 查看同步状态(`sync status` 的别名) |
442
+ | `mindos sync init` | 交互式配置 Git 远程同步 |
443
+ | `mindos sync status` | 查看同步状态:最后同步时间、未推送提交、冲突 |
444
+ | `mindos sync now` | 手动触发完整同步(commit + push + pull) |
445
+ | `mindos sync on` | 启用自动同步 |
446
+ | `mindos sync off` | 禁用自动同步 |
447
+ | `mindos sync conflicts` | 列出未解决的冲突文件 |
415
448
  | `mindos gateway install` | 安装后台服务(Linux 用 systemd,macOS 用 LaunchAgent) |
416
449
  | `mindos gateway uninstall` | 卸载后台服务 |
417
450
  | `mindos gateway start` | 启动后台服务 |
package/app/README.md CHANGED
@@ -16,7 +16,7 @@ mindos dev # or: mindos start
16
16
 
17
17
  ```bash
18
18
  npm install
19
- MIND_ROOT=~/.mindos/my-mind ANTHROPIC_API_KEY=sk-ant-... npm run dev
19
+ MIND_ROOT=~/MindOS ANTHROPIC_API_KEY=sk-ant-... npm run dev
20
20
  # Or copy .env.local.example to app/.env.local and fill in values
21
21
  ```
22
22
 
@@ -0,0 +1,56 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { getMindRoot } from '@/lib/fs';
5
+
6
+ function copyRecursive(src: string, dest: string) {
7
+ const stat = fs.statSync(src);
8
+ if (stat.isDirectory()) {
9
+ if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
10
+ for (const entry of fs.readdirSync(src)) {
11
+ copyRecursive(path.join(src, entry), path.join(dest, entry));
12
+ }
13
+ } else {
14
+ // Skip if file already exists
15
+ if (fs.existsSync(dest)) return;
16
+ // Ensure parent directory exists
17
+ const dir = path.dirname(dest);
18
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
19
+ fs.copyFileSync(src, dest);
20
+ }
21
+ }
22
+
23
+ export async function POST(req: NextRequest) {
24
+ try {
25
+ const body = await req.json();
26
+ const template = body.template as string;
27
+
28
+ if (!['en', 'zh', 'empty'].includes(template)) {
29
+ return NextResponse.json({ error: 'Invalid template' }, { status: 400 });
30
+ }
31
+
32
+ // Resolve template source directory
33
+ // templates/ is at the repo root (sibling of app/)
34
+ const repoRoot = path.resolve(process.cwd(), '..');
35
+ const templateDir = path.join(repoRoot, 'templates', template);
36
+
37
+ if (!fs.existsSync(templateDir)) {
38
+ return NextResponse.json({ error: `Template "${template}" not found` }, { status: 404 });
39
+ }
40
+
41
+ const mindRoot = getMindRoot();
42
+ if (!fs.existsSync(mindRoot)) {
43
+ fs.mkdirSync(mindRoot, { recursive: true });
44
+ }
45
+
46
+ copyRecursive(templateDir, mindRoot);
47
+
48
+ return NextResponse.json({ ok: true, template });
49
+ } catch (e) {
50
+ console.error('[/api/init] Error:', e);
51
+ return NextResponse.json(
52
+ { error: e instanceof Error ? e.message : String(e) },
53
+ { status: 500 },
54
+ );
55
+ }
56
+ }
@@ -6,6 +6,7 @@ import ShellLayout from '@/components/ShellLayout';
6
6
  import { TooltipProvider } from '@/components/ui/tooltip';
7
7
  import { LocaleProvider } from '@/lib/LocaleContext';
8
8
  import ErrorBoundary from '@/components/ErrorBoundary';
9
+ import RegisterSW from './register-sw';
9
10
 
10
11
  const geistSans = Geist({
11
12
  variable: '--font-geist-sans',
@@ -39,7 +40,13 @@ const lora = Lora({
39
40
  export const metadata: Metadata = {
40
41
  title: 'MindOS',
41
42
  description: 'Personal knowledge base',
42
- icons: { icon: '/logo-square.svg' },
43
+ icons: { icon: '/logo-square.svg', apple: '/icons/icon-192.png' },
44
+ manifest: '/manifest.json',
45
+ other: {
46
+ 'mobile-web-app-capable': 'yes',
47
+ 'apple-mobile-web-app-capable': 'yes',
48
+ 'apple-mobile-web-app-status-bar-style': 'black-translucent',
49
+ },
43
50
  };
44
51
 
45
52
  export const viewport = {
@@ -63,6 +70,7 @@ export default function RootLayout({
63
70
  return (
64
71
  <html lang="en" suppressHydrationWarning>
65
72
  <head>
73
+ <meta name="theme-color" content="#c8871e" />
66
74
  {/* Patch Node.removeChild/insertBefore to swallow errors caused by browser
67
75
  extensions (translators, Grammarly, etc.) that mutate the DOM between SSR
68
76
  and hydration. See: https://github.com/facebook/react/issues/17256 */}
@@ -90,6 +98,7 @@ export default function RootLayout({
90
98
  </ShellLayout>
91
99
  </ErrorBoundary>
92
100
  </TooltipProvider>
101
+ <RegisterSW />
93
102
  </LocaleProvider>
94
103
  </body>
95
104
  </html>
@@ -0,0 +1,15 @@
1
+ 'use client';
2
+
3
+ import { useEffect } from 'react';
4
+
5
+ export default function RegisterSW() {
6
+ useEffect(() => {
7
+ if ('serviceWorker' in navigator) {
8
+ navigator.serviceWorker.register('/sw.js').catch((err) => {
9
+ console.warn('[SW] Registration failed:', err);
10
+ });
11
+ }
12
+ }, []);
13
+
14
+ return null;
15
+ }
@@ -1,12 +1,13 @@
1
1
  'use client';
2
2
 
3
3
  import Link from 'next/link';
4
- import { FileText, Table, Clock, Sparkles, Puzzle, ArrowRight, FilePlus, Search, ChevronDown } from 'lucide-react';
4
+ import { FileText, Table, Clock, Sparkles, Puzzle, ArrowRight, FilePlus, Search, ChevronDown, Terminal } from 'lucide-react';
5
5
  import { useState } from 'react';
6
6
  import { useLocale } from '@/lib/LocaleContext';
7
7
  import { encodePath, relativeTime } from '@/lib/utils';
8
8
  import { getAllRenderers } from '@/lib/renderers/registry';
9
9
  import '@/lib/renderers/index'; // registers all renderers
10
+ import OnboardingView from './OnboardingView';
10
11
 
11
12
  interface RecentFile {
12
13
  path: string;
@@ -21,7 +22,7 @@ const RENDERER_ENTRY: Record<string, string> = {
21
22
  timeline: 'CHANGELOG.md',
22
23
  backlinks: 'BACKLINKS.md',
23
24
  summary: 'DAILY.md',
24
- 'agent-inspector': 'Agent-Audit.md',
25
+ 'agent-inspector': '.agent-log.json',
25
26
  workflow: 'Workflow.md',
26
27
  'diff-viewer': 'Agent-Diff.md',
27
28
  'config-panel': 'CONFIG.json',
@@ -45,6 +46,11 @@ export default function HomeContent({ recent }: { recent: RecentFile[] }) {
45
46
  const { t } = useLocale();
46
47
  const [showAll, setShowAll] = useState(false);
47
48
 
49
+ // Empty knowledge base → show onboarding
50
+ if (recent.length === 0) {
51
+ return <OnboardingView />;
52
+ }
53
+
48
54
  const formatTime = (mtime: number) => relativeTime(mtime, t.home.relativeTime);
49
55
 
50
56
  const renderers = getAllRenderers();
@@ -0,0 +1,161 @@
1
+ 'use client';
2
+
3
+ import { useState } from 'react';
4
+ import { useRouter } from 'next/navigation';
5
+ import { Sparkles, Globe, BookOpen, FileText, Loader2, GitBranch } from 'lucide-react';
6
+ import { useLocale } from '@/lib/LocaleContext';
7
+
8
+ type Template = 'en' | 'zh' | 'empty';
9
+
10
+ const TEMPLATES: Array<{
11
+ id: Template;
12
+ icon: React.ReactNode;
13
+ dirs: string[];
14
+ }> = [
15
+ {
16
+ id: 'en',
17
+ icon: <Globe size={20} />,
18
+ dirs: ['Profile/', 'Connections/', 'Notes/', 'Workflows/', 'Resources/', 'Projects/'],
19
+ },
20
+ {
21
+ id: 'zh',
22
+ icon: <BookOpen size={20} />,
23
+ dirs: ['画像/', '关系/', '笔记/', '流程/', '资源/', '项目/'],
24
+ },
25
+ {
26
+ id: 'empty',
27
+ icon: <FileText size={20} />,
28
+ dirs: ['README.md', 'CONFIG.json', 'INSTRUCTION.md'],
29
+ },
30
+ ];
31
+
32
+ export default function OnboardingView() {
33
+ const { t } = useLocale();
34
+ const router = useRouter();
35
+ const [loading, setLoading] = useState<Template | null>(null);
36
+
37
+ const ob = t.onboarding;
38
+
39
+ async function handleSelect(template: Template) {
40
+ setLoading(template);
41
+ try {
42
+ const res = await fetch('/api/init', {
43
+ method: 'POST',
44
+ headers: { 'Content-Type': 'application/json' },
45
+ body: JSON.stringify({ template }),
46
+ });
47
+ if (!res.ok) {
48
+ const data = await res.json().catch(() => ({}));
49
+ throw new Error(data.error || `HTTP ${res.status}`);
50
+ }
51
+ router.refresh();
52
+ } catch (e) {
53
+ console.error('[Onboarding] init failed:', e);
54
+ setLoading(null);
55
+ }
56
+ }
57
+
58
+ return (
59
+ <div className="content-width px-4 md:px-6 py-12 md:py-20">
60
+ {/* Header */}
61
+ <div className="text-center mb-10">
62
+ <div className="inline-flex items-center gap-2 mb-4">
63
+ <Sparkles size={18} style={{ color: 'var(--amber)' }} />
64
+ <h1
65
+ className="text-2xl font-semibold tracking-tight"
66
+ style={{ fontFamily: "'IBM Plex Mono', monospace", color: 'var(--foreground)' }}
67
+ >
68
+ MindOS
69
+ </h1>
70
+ </div>
71
+ <p
72
+ className="text-sm leading-relaxed max-w-md mx-auto"
73
+ style={{ color: 'var(--muted-foreground)' }}
74
+ >
75
+ {ob.subtitle}
76
+ </p>
77
+ </div>
78
+
79
+ {/* Template cards */}
80
+ <div className="grid grid-cols-1 sm:grid-cols-3 gap-4 max-w-2xl mx-auto mb-10">
81
+ {TEMPLATES.map((tpl) => {
82
+ const isLoading = loading === tpl.id;
83
+ const isDisabled = loading !== null;
84
+ return (
85
+ <button
86
+ key={tpl.id}
87
+ disabled={isDisabled}
88
+ onClick={() => handleSelect(tpl.id)}
89
+ className="group relative flex flex-col items-start gap-3 p-5 rounded-xl border text-left transition-all duration-150 hover:border-amber-500/50 hover:bg-amber-500/5 disabled:opacity-60 disabled:cursor-not-allowed"
90
+ style={{ background: 'var(--card)', borderColor: 'var(--border)' }}
91
+ >
92
+ {/* Icon + title */}
93
+ <div className="flex items-center gap-2.5 w-full">
94
+ <span style={{ color: 'var(--amber)' }}>{tpl.icon}</span>
95
+ <span
96
+ className="text-sm font-semibold"
97
+ style={{ color: 'var(--foreground)', fontFamily: "'IBM Plex Sans', sans-serif" }}
98
+ >
99
+ {ob.templates[tpl.id].title}
100
+ </span>
101
+ {isLoading && (
102
+ <Loader2 size={14} className="animate-spin ml-auto" style={{ color: 'var(--amber)' }} />
103
+ )}
104
+ </div>
105
+
106
+ {/* Description */}
107
+ <p className="text-xs leading-relaxed" style={{ color: 'var(--muted-foreground)' }}>
108
+ {ob.templates[tpl.id].desc}
109
+ </p>
110
+
111
+ {/* Directory preview */}
112
+ <div
113
+ className="w-full rounded-lg px-3 py-2 text-[11px] leading-relaxed"
114
+ style={{
115
+ background: 'var(--muted)',
116
+ fontFamily: "'IBM Plex Mono', monospace",
117
+ color: 'var(--muted-foreground)',
118
+ opacity: 0.8,
119
+ }}
120
+ >
121
+ {tpl.dirs.map((d) => (
122
+ <div key={d}>{d}</div>
123
+ ))}
124
+ </div>
125
+ </button>
126
+ );
127
+ })}
128
+ </div>
129
+
130
+ {/* Import hint */}
131
+ <p
132
+ className="text-center text-xs leading-relaxed max-w-sm mx-auto"
133
+ style={{ color: 'var(--muted-foreground)', opacity: 0.6, fontFamily: "'IBM Plex Mono', monospace" }}
134
+ >
135
+ {ob.importHint}
136
+ </p>
137
+
138
+ {/* Sync hint card */}
139
+ <div
140
+ className="max-w-md mx-auto mt-6 flex items-center gap-3 px-4 py-3 rounded-lg border text-left"
141
+ style={{ borderColor: 'var(--border)', background: 'var(--card)' }}
142
+ >
143
+ <GitBranch size={16} style={{ color: 'var(--muted-foreground)', flexShrink: 0 }} />
144
+ <div className="min-w-0">
145
+ <p className="text-xs" style={{ color: 'var(--muted-foreground)' }}>
146
+ {ob.syncHint ?? 'Want cross-device sync? Run'}
147
+ {' '}
148
+ <code
149
+ className="font-mono px-1 py-0.5 rounded select-all"
150
+ style={{ background: 'var(--muted)', fontSize: '11px' }}
151
+ >
152
+ mindos sync init
153
+ </code>
154
+ {' '}
155
+ {ob.syncHintSuffix ?? 'in the terminal after setup.'}
156
+ </p>
157
+ </div>
158
+ </div>
159
+ </div>
160
+ );
161
+ }
@@ -18,9 +18,10 @@ import { SyncTab } from './settings/SyncTab';
18
18
  interface SettingsModalProps {
19
19
  open: boolean;
20
20
  onClose: () => void;
21
+ initialTab?: Tab;
21
22
  }
22
23
 
23
- export default function SettingsModal({ open, onClose }: SettingsModalProps) {
24
+ export default function SettingsModal({ open, onClose, initialTab }: SettingsModalProps) {
24
25
  const [tab, setTab] = useState<Tab>('ai');
25
26
  const [data, setData] = useState<SettingsData | null>(null);
26
27
  const [saving, setSaving] = useState(false);
@@ -48,6 +49,11 @@ export default function SettingsModal({ open, onClose }: SettingsModalProps) {
48
49
  setStatus('idle');
49
50
  }, [open]);
50
51
 
52
+ // Switch to requested tab when opening with initialTab
53
+ useEffect(() => {
54
+ if (open && initialTab) setTab(initialTab);
55
+ }, [open, initialTab]);
56
+
51
57
  // Apply font immediately
52
58
  useEffect(() => {
53
59
  const fontMap: Record<string, string> = {
@@ -8,7 +8,9 @@ import FileTree from './FileTree';
8
8
  import SearchModal from './SearchModal';
9
9
  import AskModal from './AskModal';
10
10
  import SettingsModal from './SettingsModal';
11
+ import SyncStatusBar, { SyncDot, MobileSyncDot, useSyncStatus } from './SyncStatusBar';
11
12
  import { FileNode } from '@/lib/types';
13
+ import type { Tab } from './settings/types';
12
14
  import { useLocale } from '@/lib/LocaleContext';
13
15
 
14
16
  interface SidebarProps {
@@ -40,9 +42,13 @@ export default function Sidebar({ fileTree, collapsed = false, onCollapse, onExp
40
42
  const [searchOpen, setSearchOpen] = useState(false);
41
43
  const [askOpen, setAskOpen] = useState(false);
42
44
  const [settingsOpen, setSettingsOpen] = useState(false);
45
+ const [settingsTab, setSettingsTab] = useState<Tab | undefined>(undefined);
43
46
  const [mobileOpen, setMobileOpen] = useState(false);
44
47
  const { t } = useLocale();
45
48
 
49
+ // Shared sync status for collapsed dot & mobile dot
50
+ const { status: syncStatus } = useSyncStatus();
51
+
46
52
  const pathname = usePathname();
47
53
  const currentFile = pathname.startsWith('/view/')
48
54
  ? pathname.slice('/view/'.length).split('/').map(decodeURIComponent).join('/')
@@ -60,6 +66,8 @@ export default function Sidebar({ fileTree, collapsed = false, onCollapse, onExp
60
66
 
61
67
  useEffect(() => { setMobileOpen(false); }, [pathname]);
62
68
 
69
+ const openSyncSettings = () => { setSettingsTab('sync'); setSettingsOpen(true); };
70
+
63
71
  const sidebarContent = (
64
72
  <div className="flex flex-col h-full">
65
73
  <div className="flex items-center justify-between px-4 py-4 border-b border-border shrink-0">
@@ -88,6 +96,10 @@ export default function Sidebar({ fileTree, collapsed = false, onCollapse, onExp
88
96
  <div className="flex-1 overflow-y-auto min-h-0 px-2 py-2">
89
97
  <FileTree nodes={fileTree} onNavigate={() => setMobileOpen(false)} />
90
98
  </div>
99
+ <SyncStatusBar
100
+ collapsed={collapsed}
101
+ onOpenSyncSettings={openSyncSettings}
102
+ />
91
103
  </div>
92
104
  );
93
105
 
@@ -97,10 +109,14 @@ export default function Sidebar({ fileTree, collapsed = false, onCollapse, onExp
97
109
  {sidebarContent}
98
110
  </aside>
99
111
 
112
+ {/* #7 — Collapsed sidebar: expand button with sync health dot */}
100
113
  {collapsed && (
101
- <button onClick={onExpand} className="hidden md:flex fixed top-4 left-0 z-30 items-center justify-center w-6 h-10 bg-card border border-border rounded-r-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors" title={t.sidebar.expandTitle}>
102
- <PanelLeftOpen size={14} />
103
- </button>
114
+ <div className="hidden md:flex fixed top-4 left-0 z-30 flex-col items-center gap-2">
115
+ <button onClick={onExpand} className="relative flex items-center justify-center w-6 h-10 bg-card border border-border rounded-r-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors" title={t.sidebar.expandTitle}>
116
+ <PanelLeftOpen size={14} />
117
+ <SyncDot status={syncStatus} />
118
+ </button>
119
+ </div>
104
120
  )}
105
121
 
106
122
  {/* Mobile navbar */}
@@ -113,6 +129,14 @@ export default function Sidebar({ fileTree, collapsed = false, onCollapse, onExp
113
129
  <span className="font-semibold text-foreground text-sm tracking-wide">MindOS</span>
114
130
  </Link>
115
131
  <div className="flex items-center gap-0.5">
132
+ {/* #8 — Mobile sync dot: visible when there's a problem */}
133
+ <button
134
+ onClick={openSyncSettings}
135
+ className="p-2.5 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors active:bg-accent flex items-center justify-center"
136
+ aria-label="Sync status"
137
+ >
138
+ <MobileSyncDot status={syncStatus} />
139
+ </button>
116
140
  <button onClick={() => setSearchOpen(true)} className="p-2.5 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors active:bg-accent" aria-label={t.sidebar.searchTitle}>
117
141
  <Search size={20} />
118
142
  </button>
@@ -130,7 +154,7 @@ export default function Sidebar({ fileTree, collapsed = false, onCollapse, onExp
130
154
 
131
155
  <SearchModal open={searchOpen} onClose={() => setSearchOpen(false)} />
132
156
  <AskModal open={askOpen} onClose={() => setAskOpen(false)} currentFile={currentFile} />
133
- <SettingsModal open={settingsOpen} onClose={() => setSettingsOpen(false)} />
157
+ <SettingsModal open={settingsOpen} onClose={() => { setSettingsOpen(false); setSettingsTab(undefined); }} initialTab={settingsTab} />
134
158
  </>
135
159
  );
136
160
  }