feat(triage): implement Quick Dump notes, direct task/list assignment, and fix stale JWT user resolution
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 53s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 53s
This commit is contained in:
1 parent
2d4a2bde41
commit
d6bc2976d9
7 files changed
+695
-196
No files matched your search
+32
-3
@@ -36,7 +36,7 @@ export function triggerHaptic(pattern: number | number[] = 15): void {
|
||||
}
|
||||
}
|
||||
|
||||
async function request<T>(path: string, options: RequestInit = {}): Promise<T> {
|
||||
async function request<T>(path: string, options: RequestInit = {}, isRetry = false): Promise<T> {
|
||||
const token = getToken();
|
||||
const headers: Record<string, string> = {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -52,6 +52,24 @@ async function request<T>(path: string, options: RequestInit = {}): Promise<T> {
|
||||
headers,
|
||||
});
|
||||
|
||||
if (res.status === 401 && !isRetry && !path.includes('/auth/login') && !path.includes('/auth/quickstart')) {
|
||||
try {
|
||||
const qsRes = await fetch('/api/v1/auth/quickstart', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
if (qsRes.ok) {
|
||||
const qsData = await qsRes.json();
|
||||
if (qsData.token) {
|
||||
setToken(qsData.token);
|
||||
return request<T>(path, options, true);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// ignore and fall through to standard error handling
|
||||
}
|
||||
}
|
||||
|
||||
if (!res.ok) {
|
||||
let errMsg = `HTTP ${res.status}`;
|
||||
try {
|
||||
@@ -107,12 +125,23 @@ export const api = {
|
||||
content: string,
|
||||
priority: PriorityLevel = 'normal',
|
||||
source: 'manual' | 'voice' = 'manual',
|
||||
dueDate = ''
|
||||
dueDate = '',
|
||||
options?: {
|
||||
target?: 'inbox' | 'task' | 'list_item' | 'document';
|
||||
targetListId?: string;
|
||||
}
|
||||
): Promise<Thought> {
|
||||
try {
|
||||
const thought = await request<Thought>('/api/v1/inbox', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ content, priority, source, dueDate }),
|
||||
body: JSON.stringify({
|
||||
content,
|
||||
priority,
|
||||
source,
|
||||
dueDate,
|
||||
target: options?.target || 'inbox',
|
||||
targetListId: options?.targetListId || '',
|
||||
}),
|
||||
});
|
||||
return thought;
|
||||
} catch (err) {
|
||||
|
||||
Reference in new issue
Block a user