Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

Merge master 3240978f into codex-integrate-org-into-master

Max0a4b3b2f0eef
diff --cc storage/media_service.py
index 523fee148,4c36f6316..bb79bbd54
--- a/storage/media_service.py
+++ b/storage/media_service.py
@@@ -189,32 -150,19 +189,50 @@@ def get_by_token(conn: Connection, toke
return dict(row) if row else None
+def referenced_session_ids(conn: Connection, token: str) -> list[str]:
+ """Return sessions that contain a trusted reference to *token*."""
+
+ if not token:
+ return []
+ return [
+ str(session_id)
+ for session_id in conn.execute(
+ select(media_object_references.c.session_id)
+ .where(media_object_references.c.token == token)
+ .order_by(media_object_references.c.session_id)
+ ).scalars()
+ ]
+
+
+def is_referenced_by_session(conn: Connection, token: str, session_id: str) -> bool:
+ if not token or not session_id:
+ return False
+ return (
+ conn.execute(
+ select(media_object_references.c.token)
+ .where(
+ media_object_references.c.token == token,
+ media_object_references.c.session_id == session_id,
+ )
+ .limit(1)
+ ).scalar_one_or_none()
+ is not None
+ )
++
++
+ def get_live_user_upload_by_path(
+ conn: Connection,
+ *,
+ session_id: str,
+ local_path: str,
+ ) -> Optional[dict[str, Any]]:
+ """Return an existing idempotent browser upload for this session/path."""
+ row = conn.execute(
+ select(media_objects).where(
+ media_objects.c.session_id == session_id,
+ media_objects.c.source == "user_upload",
+ media_objects.c.local_path == local_path,
+ media_objects.c.revoked_at.is_(None),
+ )
+ ).mappings().first()
+ return dict(row) if row else None
diff --cc ui/src/i18n/en.json
index 76a3e03be,6eacee0f0..9781e6fdc
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@@ -3280,9 -3226,14 +3280,15 @@@
"voicePermissionFailed": "Microphone access failed. Check your browser permission and try again.",
"voiceStartFailed": "Voice recording could not start in this browser. Reload the page or try a supported browser.",
"voiceDraftChanged": "The draft changed during voice input. The recovered transcript is available to copy.",
+ "attachmentTooLarge": "This file exceeds the 100 MB attachment limit.",
+ "attachmentEmpty": "Empty files cannot be attached.",
+ "attachmentSessionUnavailable": "This session is no longer available.",
+ "attachmentNetwork": "The upload connection failed. Try again.",
+ "attachmentFailed": "The file could not be uploaded. Try again.",
+ "retryAttachment": "Retry upload",
"removeAttachment": "Remove",
- "dropOverlay": "Drop files to attach"
+ "dropOverlay": "Drop files to attach",
+ "voicePreview": "Live transcription preview"
},
"media": {
"preview": "Preview",
diff --cc ui/src/i18n/zh.json
index 56f7a6a9e,3f9c68789..72e0f487d
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@@ -3280,9 -3226,14 +3280,15 @@@
"voicePermissionFailed": "无法使用麦克风,请检查浏览器权限后重试。",
"voiceStartFailed": "当前浏览器无法启动语音录制,请刷新页面或更换支持的浏览器。",
"voiceDraftChanged": "语音输入期间草稿已变化,已保留整理结果供复制。",
+ "attachmentTooLarge": "文件超过 100 MB 的附件上限。",
+ "attachmentEmpty": "不能上传空文件。",
+ "attachmentSessionUnavailable": "当前会话已不可用。",
+ "attachmentNetwork": "上传连接失败,请重试。",
+ "attachmentFailed": "文件上传失败,请重试。",
+ "retryAttachment": "重试上传",
"removeAttachment": "移除",
- "dropOverlay": "拖放文件以添加"
+ "dropOverlay": "拖放文件以添加",
+ "voicePreview": "实时转写预览"
},
"media": {
"preview": "预览",
diff --cc ui/src/lib/apiFetch.test.ts
index 17e90f84e,ffbe8029a..a39483383
--- a/ui/src/lib/apiFetch.test.ts
+++ b/ui/src/lib/apiFetch.test.ts
@@@ -123,31 -267,55 +252,83 @@@ describe('apiFetch remote auth recovery
expect(fetchMock).toHaveBeenCalledTimes(3);
});
+ it('recovers from a successful session probe that requires authorization refresh', async () => {
+ await recoverRemoteAuthFromSessionProbe(Response.json({
+ remote: true,
+ authenticated: false,
+ authorization_refresh_required: true,
+ }));
+
+ expect(remoteAuth.deferRemoteAuthRedirect).toHaveBeenCalledOnce();
+ expect(window.location.assign).not.toHaveBeenCalled();
+ });
+
+ it('uses the dedicated login endpoint outside an iOS standalone PWA', async () => {
+ remoteAuth.deferRemoteAuthRedirect.mockReturnValue(false);
+ vi.stubGlobal(
+ 'fetch',
+ vi.fn(async () =>
+ Response.json({ error: 'remote_access_login_required' }, { status: 401 }),
+ ),
+ );
+
+ await apiFetch('/api/inbox');
+
+ await vi.waitFor(() => expect(window.location.assign).toHaveBeenCalledWith(
+ '/auth/login?next=%2Finbox%3Ffilter%3Dopen',
+ ));
+ expect(remoteAuth.remoteLoginPath).toHaveBeenCalledWith('/inbox?filter=open');
+ });
++
+ it('evicts a stalled shared CSRF refresh after a rejected mutation aborts', async () => {
+ let cookie = 'vibe_csrf_token=stale-token';
+ let tokenFetches = 0;
+ let mutationCalls = 0;
+ vi.stubGlobal('document', {
+ get cookie() {
+ return cookie;
+ },
+ set cookie(value: string) {
+ cookie = value.includes('Max-Age=0') ? '' : value.split(';', 1)[0];
+ },
+ });
+ const fetchMock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
+ if (input === '/api/csrf-token') {
+ tokenFetches += 1;
+ if (tokenFetches === 1) {
+ return new Promise<Response>(() => undefined);
+ }
+ document.cookie = 'vibe_csrf_token=fresh-token; path=/';
+ return Response.json({ csrf_token: 'fresh-token' });
+ }
+
+ mutationCalls += 1;
+ if (mutationCalls === 1) {
+ cookie = '';
+ return Response.json({ ok: false, message: 'Forbidden: invalid csrf token' }, { status: 403 });
+ }
+ const token = new Headers(init?.headers).get('X-Vibe-CSRF-Token');
+ return Response.json({ ok: token === 'fresh-token' }, {
+ status: token === 'fresh-token' ? 200 : 403,
+ });
+ });
+ vi.stubGlobal('fetch', fetchMock);
+ const controller = new AbortController();
+
+ const stalled = apiFetch('/api/attachments', {
+ method: 'POST',
+ body: new FormData(),
+ signal: controller.signal,
+ });
+ await vi.waitFor(() => expect(fetchMock).toHaveBeenCalledTimes(2));
+ const stalledResult = expect(stalled).rejects.toMatchObject({ name: 'TimeoutError' });
+ controller.abort(new DOMException('upload timed out', 'TimeoutError'));
+
+ await stalledResult;
+ await expect(apiFetch('/api/settings', { method: 'POST' })).resolves.toMatchObject({
+ status: 200,
+ });
+ expect(tokenFetches).toBe(2);
+ expect(fetchMock).toHaveBeenCalledTimes(4);
+ });
});