@cat-factory/app 0.235.0 → 0.236.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 +24 -0
- package/app/components/auth/LoginScreen.vue +15 -3
- package/app/components/auth/UserMenu.vue +1 -0
- package/app/components/board/AddTaskModal.vue +31 -12
- package/app/components/board/CreateInitiativeModal.vue +33 -6
- package/app/components/context/ContextAttachmentFields.vue +63 -42
- package/app/components/documents/ContextDocumentPicker.logic.spec.ts +186 -0
- package/app/components/documents/ContextDocumentPicker.logic.ts +178 -0
- package/app/components/documents/ContextDocumentPicker.vue +269 -34
- package/app/components/layout/WorkspaceMembersSettings.vue +1 -0
- package/app/components/panels/inspector/TaskRunSettings.vue +1 -0
- package/app/components/riskPolicy/RiskPolicyPicker.vue +3 -0
- package/app/components/settings/RiskPolicyPanel.vue +22 -3
- package/app/components/settings/WorkspaceSettingsPanel.vue +7 -0
- package/app/composables/api/documents.ts +10 -0
- package/app/composables/useAiReadiness.ts +4 -3
- package/app/composables/useContextLinking.spec.ts +95 -0
- package/app/composables/useContextLinking.ts +96 -15
- package/app/pages/index.vue +7 -1
- package/app/stores/documents.ts +12 -0
- package/app/stores/models.spec.ts +64 -0
- package/app/stores/models.ts +21 -0
- package/app/types/documents.ts +2 -0
- package/i18n/locales/de.json +15 -4
- package/i18n/locales/en.json +19 -2
- package/i18n/locales/es.json +15 -4
- package/i18n/locales/fr.json +15 -4
- package/i18n/locales/he.json +15 -4
- package/i18n/locales/it.json +15 -4
- package/i18n/locales/ja.json +15 -4
- package/i18n/locales/pl.json +15 -4
- package/i18n/locales/tr.json +15 -4
- package/i18n/locales/uk.json +15 -4
- package/package.json +2 -2
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
listDocumentsContract,
|
|
10
10
|
listDocumentSourcesContract,
|
|
11
11
|
planDocumentContract,
|
|
12
|
+
resolveDocumentRefContract,
|
|
12
13
|
searchDocumentsContract,
|
|
13
14
|
spawnDocumentContract,
|
|
14
15
|
unlinkDocumentForKindContract,
|
|
@@ -48,6 +49,15 @@ export function documentsApi({ send, ws }: ApiContext) {
|
|
|
48
49
|
listDocuments: (workspaceId: string) =>
|
|
49
50
|
send(listDocumentsContract, { pathPrefix: ws(workspaceId) }),
|
|
50
51
|
|
|
52
|
+
// Canonicalise a pasted URL/id without importing it: the pre-flight the attach pickers run
|
|
53
|
+
// so an unusable link is corrected before the task that carries it is saved.
|
|
54
|
+
resolveDocumentRef: (workspaceId: string, source: DocumentSourceKind, body: { ref: string }) =>
|
|
55
|
+
send(resolveDocumentRefContract, {
|
|
56
|
+
pathPrefix: ws(workspaceId),
|
|
57
|
+
pathParams: { source },
|
|
58
|
+
body,
|
|
59
|
+
}),
|
|
60
|
+
|
|
51
61
|
importDocument: (workspaceId: string, source: DocumentSourceKind, body: { ref: string }) =>
|
|
52
62
|
send(importDocumentContract, { pathPrefix: ws(workspaceId), pathParams: { source }, body }),
|
|
53
63
|
|
|
@@ -13,9 +13,10 @@ import type { ModelPreset } from '~/types/model-presets'
|
|
|
13
13
|
* still points at one or more that aren't usable (⇒ the preset-mismatch prompt). Gated on
|
|
14
14
|
* `hasUsableModel` so the no-AI prompt owns the "nothing works" case on its own.
|
|
15
15
|
*
|
|
16
|
-
* Read-only over the existing stores; the catalog is loaded elsewhere (on
|
|
17
|
-
* and after credential edits), so `ready` simply reports whether that load has landed
|
|
18
|
-
* the active workspace.
|
|
16
|
+
* Read-only over the existing stores; the catalog is loaded elsewhere (on the active board
|
|
17
|
+
* changing and after credential edits), so `ready` simply reports whether that load has landed
|
|
18
|
+
* for the active workspace. A load that FAILED leaves it false, which is what keeps the no-AI
|
|
19
|
+
* prompt off a board whose catalog never arrived (see `models.prefetchForBoard`).
|
|
19
20
|
*/
|
|
20
21
|
export function useAiReadiness() {
|
|
21
22
|
const models = useModelsStore()
|
|
@@ -85,6 +85,101 @@ describe('contextKey', () => {
|
|
|
85
85
|
})
|
|
86
86
|
})
|
|
87
87
|
|
|
88
|
+
describe('resolvePending', () => {
|
|
89
|
+
// Fetching an attachment moved AHEAD of the create: an unreachable page is a correction the
|
|
90
|
+
// user can still make with the form open, where the same failure afterwards leaves a task
|
|
91
|
+
// carrying context it never got. These pin the two halves that makes load-bearing: what the
|
|
92
|
+
// host gets back, and that one bad attachment does not hide a second one.
|
|
93
|
+
function stub(
|
|
94
|
+
importDocument: (source: string, ref: string) => Promise<{ externalId: string }>,
|
|
95
|
+
importTask: (
|
|
96
|
+
source: string,
|
|
97
|
+
ref: string,
|
|
98
|
+
) => Promise<{
|
|
99
|
+
externalId: string
|
|
100
|
+
description: string
|
|
101
|
+
}> = async () => ({ externalId: 'T-1', description: '' }),
|
|
102
|
+
) {
|
|
103
|
+
vi.stubGlobal('useDocumentsStore', () => ({ importDocument }))
|
|
104
|
+
vi.stubGlobal('useTasksStore', () => ({ importTask }))
|
|
105
|
+
vi.stubGlobal('useWorkspaceStore', () => ({ workspaceId: 'ws_1' }))
|
|
106
|
+
vi.stubGlobal('useToast', () => ({ add: vi.fn() }))
|
|
107
|
+
vi.stubGlobal('useI18n', () => ({ t: (key: string) => key }))
|
|
108
|
+
vi.stubGlobal('useCopyToClipboard', () => ({ copyAction: () => ({ label: 'copy' }) }))
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
afterEach(() => vi.unstubAllGlobals())
|
|
112
|
+
|
|
113
|
+
it('imports what needs it and hands back items the later link can use directly', async () => {
|
|
114
|
+
stub(async (_source, ref) => ({ externalId: `resolved:${ref}` }))
|
|
115
|
+
const already = item({ externalId: 'acme/repo:docs/done.md', needsImport: false })
|
|
116
|
+
|
|
117
|
+
const { resolved, failures } = await useContextLinking().resolvePending([item(), already])
|
|
118
|
+
|
|
119
|
+
expect(failures).toEqual([])
|
|
120
|
+
// The import's own canonical id is carried forward, not the pasted ref, and the flag flips so
|
|
121
|
+
// `linkPending` links rather than re-fetching.
|
|
122
|
+
expect(resolved.map((c) => [c.externalId, c.needsImport])).toEqual([
|
|
123
|
+
['resolved:acme/repo:docs/x.md', false],
|
|
124
|
+
['acme/repo:docs/done.md', false],
|
|
125
|
+
])
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('reports EVERY failure and keeps the failed item staged', async () => {
|
|
129
|
+
stub(async (_source, ref) => {
|
|
130
|
+
throw new Error(`no access to ${ref}`)
|
|
131
|
+
})
|
|
132
|
+
const a = item({ externalId: 'acme/repo:a.md' })
|
|
133
|
+
const b = item({ externalId: 'acme/repo:b.md' })
|
|
134
|
+
|
|
135
|
+
const { resolved, failures } = await useContextLinking().resolvePending([a, b])
|
|
136
|
+
|
|
137
|
+
// Both, not just the first: fixing them one round-trip at a time is the failure mode.
|
|
138
|
+
expect(failures.map((f) => f.item.externalId)).toEqual(['acme/repo:a.md', 'acme/repo:b.md'])
|
|
139
|
+
expect(failures[0]!.message).toContain('no access to acme/repo:a.md')
|
|
140
|
+
// Still staged and still unresolved: the host aborts the create, so dropping them here would
|
|
141
|
+
// silently discard attachments the user asked for while they are fixing them.
|
|
142
|
+
expect(resolved.map((c) => c.needsImport)).toEqual([true, true])
|
|
143
|
+
// And MARKED, so the form the user is still looking at names which chip refused. The toast
|
|
144
|
+
// names them too, but the toast is gone by the time they go looking for the one to remove.
|
|
145
|
+
expect(resolved.map((c) => c.unreadable)).toEqual([
|
|
146
|
+
'no access to acme/repo:a.md',
|
|
147
|
+
'no access to acme/repo:b.md',
|
|
148
|
+
])
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
it('clears a stale unreadable mark once the item does resolve', async () => {
|
|
152
|
+
// A prior failure is not a standing verdict: leaving the mark on a page that has just been
|
|
153
|
+
// fetched accuses a good attachment (and the retry is the whole point of keeping it staged).
|
|
154
|
+
stub(async (_source, ref) => ({ externalId: `resolved:${ref}` }))
|
|
155
|
+
const previouslyFailed = item({ unreadable: 'GitHub denied access (HTTP 403).' })
|
|
156
|
+
|
|
157
|
+
const { resolved } = await useContextLinking().resolvePending([previouslyFailed])
|
|
158
|
+
|
|
159
|
+
expect(resolved[0]!.unreadable).toBeUndefined()
|
|
160
|
+
expect(resolved[0]!.needsImport).toBe(false)
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
it("carries an imported issue's description forward, not just its id", async () => {
|
|
164
|
+
// The add-task form composes the saved description from these items on the very next statement
|
|
165
|
+
// (`linkedIssueBodies`), so an import that fetched the body and dropped it produced a task
|
|
166
|
+
// silently missing the issue text it was created from, with the bytes in hand at that moment.
|
|
167
|
+
stub(
|
|
168
|
+
async (_source, ref) => ({ externalId: ref }),
|
|
169
|
+
async () => ({ externalId: 'ENG-42', description: 'Steps to reproduce: …' }),
|
|
170
|
+
)
|
|
171
|
+
const issue = item({ kind: 'task', externalId: 'ENG-42', title: 'ENG-42 · Crash' })
|
|
172
|
+
|
|
173
|
+
const { resolved } = await useContextLinking().resolvePending([issue])
|
|
174
|
+
|
|
175
|
+
expect(resolved[0]).toMatchObject({
|
|
176
|
+
externalId: 'ENG-42',
|
|
177
|
+
needsImport: false,
|
|
178
|
+
description: 'Steps to reproduce: …',
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
|
|
88
183
|
describe('presentLinkFailures', () => {
|
|
89
184
|
// Stub the Nuxt auto-imports `useContextLinking` pulls in, so the toast-orchestration
|
|
90
185
|
// side of the composable can be exercised without a full Nuxt runtime.
|
|
@@ -29,6 +29,17 @@ export interface PendingContext {
|
|
|
29
29
|
description?: string
|
|
30
30
|
/** True when the item must be imported before it can be linked. */
|
|
31
31
|
needsImport: boolean
|
|
32
|
+
/**
|
|
33
|
+
* Why this item could not be FETCHED, when an attempt has already failed (the server's own
|
|
34
|
+
* message). Set by {@link useContextLinking.resolvePending} and by the add-task form's body
|
|
35
|
+
* pre-fetch; cleared the moment a later attempt succeeds.
|
|
36
|
+
*
|
|
37
|
+
* It exists because the fetch moved ahead of the create: a failure now costs the user the
|
|
38
|
+
* create, so the item that caused it has to be identifiable ON the form they are still looking
|
|
39
|
+
* at, not only in the toast that named it. A tracker issue has no pre-flight of its own, so this
|
|
40
|
+
* is the whole of its warning.
|
|
41
|
+
*/
|
|
42
|
+
unreadable?: string
|
|
32
43
|
}
|
|
33
44
|
|
|
34
45
|
/**
|
|
@@ -114,6 +125,70 @@ export function useContextLinking() {
|
|
|
114
125
|
const { t } = useI18n()
|
|
115
126
|
const { copyAction } = useCopyToClipboard()
|
|
116
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Import every pending item that still needs it, BEFORE the block exists.
|
|
130
|
+
*
|
|
131
|
+
* The fetch against the external source is the half of attaching that actually fails (a page
|
|
132
|
+
* that moved, a token without access, a source that is down), and it needs no block id. Running
|
|
133
|
+
* it after the block was created therefore bought nothing and cost the user their chance to fix
|
|
134
|
+
* it: the task existed, carrying context it had not got. Run here, a failure is a correction
|
|
135
|
+
* the host can ask for with the form still open and the reference still editable.
|
|
136
|
+
*
|
|
137
|
+
* Returns the items with what succeeded folded in (`needsImport: false`, so the later
|
|
138
|
+
* {@link linkPending} links them directly), alongside the failures. The batch is NOT aborted on
|
|
139
|
+
* the first failure: one unreachable page must not hide a second one, or the user fixes them
|
|
140
|
+
* one round-trip at a time.
|
|
141
|
+
*
|
|
142
|
+
* What "folded in" covers is the whole point of running this before the create, so it is more
|
|
143
|
+
* than the id: a tracker issue's own DESCRIPTION arrives with the import, and the add-task form
|
|
144
|
+
* composes the saved description from exactly these items on the next statement. Keeping only
|
|
145
|
+
* the id dropped a body the platform had in hand at the one moment it was needed.
|
|
146
|
+
*/
|
|
147
|
+
async function resolvePending(
|
|
148
|
+
items: PendingContext[],
|
|
149
|
+
): Promise<{ resolved: PendingContext[]; failures: LinkFailure[] }> {
|
|
150
|
+
const failures: LinkFailure[] = []
|
|
151
|
+
const resolved: PendingContext[] = []
|
|
152
|
+
for (const item of items) {
|
|
153
|
+
if (!item.needsImport) {
|
|
154
|
+
resolved.push(item)
|
|
155
|
+
continue
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
resolved.push(await importPending(item))
|
|
159
|
+
} catch (e) {
|
|
160
|
+
const failure = describeLinkFailure(item, e)
|
|
161
|
+
failures.push(failure)
|
|
162
|
+
// Kept in the list, still unresolved: the host aborts on any failure, and dropping the
|
|
163
|
+
// item here would silently discard an attachment the user asked for while they fix it.
|
|
164
|
+
// Marked, so the form the user is still looking at names WHICH attachment refused.
|
|
165
|
+
resolved.push({ ...item, unreadable: failure.message })
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return { resolved, failures }
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Fetch one pending item, folding everything the import answers back onto it. */
|
|
172
|
+
async function importPending(item: PendingContext): Promise<PendingContext> {
|
|
173
|
+
// `unreadable` is dropped rather than preserved: a prior failure is not a standing verdict, and
|
|
174
|
+
// leaving the mark on a page that has just been fetched would accuse a good attachment.
|
|
175
|
+
const { unreadable: _cleared, ...rest } = item
|
|
176
|
+
if (item.kind === 'document') {
|
|
177
|
+
const doc = await documents.importDocument(item.source as DocumentSourceKind, item.externalId)
|
|
178
|
+
return { ...rest, externalId: doc.externalId, needsImport: false }
|
|
179
|
+
}
|
|
180
|
+
const task = await tasks.importTask(item.source as TaskSourceKind, item.externalId)
|
|
181
|
+
return {
|
|
182
|
+
...rest,
|
|
183
|
+
externalId: task.externalId,
|
|
184
|
+
needsImport: false,
|
|
185
|
+
// The body reaches the created task through the host's description composition, which reads
|
|
186
|
+
// `description` off these items: an import that fetched it and did not carry it forward is a
|
|
187
|
+
// task silently missing the issue text it was created from.
|
|
188
|
+
...(task.description.trim() ? { description: task.description } : {}),
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
117
192
|
/**
|
|
118
193
|
* Import (when needed) then link every pending item to `blockId`. Each failure
|
|
119
194
|
* is captured with its actual cause rather than aborting the batch, so one bad
|
|
@@ -137,25 +212,31 @@ export function useContextLinking() {
|
|
|
137
212
|
await tasks.linkToBlock(blockId, source, externalId)
|
|
138
213
|
}
|
|
139
214
|
} catch (e) {
|
|
140
|
-
|
|
141
|
-
// so the toast can name the specific reason and the copy affordance can carry the
|
|
142
|
-
// full context (incl. the upstream GitHub status the backend puts on `details`).
|
|
143
|
-
const envelope = apiErrorEnvelope(e)
|
|
144
|
-
failures.push({
|
|
145
|
-
item,
|
|
146
|
-
message: e instanceof Error ? e.message : String(e),
|
|
147
|
-
status: apiErrorStatus(e),
|
|
148
|
-
code: envelope?.code,
|
|
149
|
-
details:
|
|
150
|
-
envelope?.details && typeof envelope.details === 'object'
|
|
151
|
-
? (envelope.details as Record<string, unknown>)
|
|
152
|
-
: undefined,
|
|
153
|
-
})
|
|
215
|
+
failures.push(describeLinkFailure(item, e))
|
|
154
216
|
}
|
|
155
217
|
}
|
|
156
218
|
return failures
|
|
157
219
|
}
|
|
158
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Never swallow the cause: capture the server's own message + status/code/details so the toast
|
|
223
|
+
* can name the specific reason and the copy affordance can carry the full context (incl. the
|
|
224
|
+
* upstream GitHub status the backend puts on `details`).
|
|
225
|
+
*/
|
|
226
|
+
function describeLinkFailure(item: PendingContext, e: unknown): LinkFailure {
|
|
227
|
+
const envelope = apiErrorEnvelope(e)
|
|
228
|
+
return {
|
|
229
|
+
item,
|
|
230
|
+
message: e instanceof Error ? e.message : String(e),
|
|
231
|
+
status: apiErrorStatus(e),
|
|
232
|
+
code: envelope?.code,
|
|
233
|
+
details:
|
|
234
|
+
envelope?.details && typeof envelope.details === 'object'
|
|
235
|
+
? (envelope.details as Record<string, unknown>)
|
|
236
|
+
: undefined,
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
159
240
|
/**
|
|
160
241
|
* Surface link failures as a single actionable toast: the specific per-item
|
|
161
242
|
* reasons as the body, and a "Copy details" action that puts the full diagnostic
|
|
@@ -209,5 +290,5 @@ export function useContextLinking() {
|
|
|
209
290
|
})
|
|
210
291
|
}
|
|
211
292
|
|
|
212
|
-
return { linkPending, presentLinkFailures }
|
|
293
|
+
return { resolvePending, linkPending, presentLinkFailures }
|
|
213
294
|
}
|
package/app/pages/index.vue
CHANGED
|
@@ -191,10 +191,16 @@ const autoOpenedPreset = ref(false)
|
|
|
191
191
|
// availability reflects that workspace's keys/subscriptions). This populates the AI-readiness
|
|
192
192
|
// signals regardless of which lazy picker happens to mount, so the onboarding prompts below
|
|
193
193
|
// can fire. Credential edits re-fetch via `models.refresh()` in the provider panels.
|
|
194
|
+
//
|
|
195
|
+
// Through `prefetchForBoard` because the FIRST run reads the persisted pin, which `init()` has
|
|
196
|
+
// not validated yet: a board that was deleted, or whose access was revoked while the browser
|
|
197
|
+
// held the pin, 404s here exactly as it does for init's own speculative snapshot fetch. That
|
|
198
|
+
// board is not this watcher's last word (init re-points the pin and it fires again), so the
|
|
199
|
+
// miss is dropped rather than left to surface as an uncaught rejection in the page.
|
|
194
200
|
watch(
|
|
195
201
|
() => workspace.workspaceId,
|
|
196
202
|
(id, prev) => {
|
|
197
|
-
if (id) void models.
|
|
203
|
+
if (id) void models.prefetchForBoard(id)
|
|
198
204
|
// Switching workspaces resets the per-session AI-onboarding state: dismissals and the
|
|
199
205
|
// auto-open guards are scoped to one workspace, so a prompt dismissed in workspace A must
|
|
200
206
|
// not suppress the (independent) prompt for workspace B that also lacks a usable source.
|
package/app/stores/documents.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
DocumentOrigin,
|
|
10
10
|
DocumentSourceDescriptor,
|
|
11
11
|
DocumentSourceKind,
|
|
12
|
+
ResolvedDocumentRef,
|
|
12
13
|
SourceDocument,
|
|
13
14
|
} from '~/types/domain'
|
|
14
15
|
import { isConnectableSource } from '@cat-factory/contracts'
|
|
@@ -82,6 +83,16 @@ export const useDocumentsStore = defineStore('documents', () => {
|
|
|
82
83
|
documents.value = await api.listDocuments(workspace.requireId())
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Canonicalise a pasted URL/id into the reference this source would store it under, WITHOUT
|
|
88
|
+
* importing it. The backend's providers own the rule, so the picker validates against the same
|
|
89
|
+
* parse the import will run rather than a second copy of it that can drift; a ref the source
|
|
90
|
+
* cannot read comes back as a 422 whose `details.reason` says which correction it needs.
|
|
91
|
+
*/
|
|
92
|
+
function resolveRef(source: DocumentSourceKind, ref: string): Promise<ResolvedDocumentRef> {
|
|
93
|
+
return api.resolveDocumentRef(workspace.requireId(), source, { ref })
|
|
94
|
+
}
|
|
95
|
+
|
|
85
96
|
/** Import (fetch + persist) a page by id or URL from a source. */
|
|
86
97
|
async function importDocument(source: DocumentSourceKind, ref: string): Promise<SourceDocument> {
|
|
87
98
|
loading.value = true
|
|
@@ -211,6 +222,7 @@ export const useDocumentsStore = defineStore('documents', () => {
|
|
|
211
222
|
connect,
|
|
212
223
|
disconnect,
|
|
213
224
|
loadDocuments,
|
|
225
|
+
resolveRef,
|
|
214
226
|
importDocument,
|
|
215
227
|
search,
|
|
216
228
|
plan,
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest'
|
|
2
|
+
import type { ModelOption } from '~/types/domain'
|
|
3
|
+
import { useModelsStore } from '~/stores/models'
|
|
4
|
+
|
|
5
|
+
/** Minimal catalog entry: only the fields the store's own reads touch. */
|
|
6
|
+
function model(over: Partial<ModelOption> = {}): ModelOption {
|
|
7
|
+
return {
|
|
8
|
+
id: 'qwen3',
|
|
9
|
+
label: 'Qwen3',
|
|
10
|
+
description: '',
|
|
11
|
+
flavor: 'cloudflare',
|
|
12
|
+
providerLabel: 'Cloudflare',
|
|
13
|
+
provider: 'cloudflare',
|
|
14
|
+
model: 'qwen3',
|
|
15
|
+
available: true,
|
|
16
|
+
...over,
|
|
17
|
+
} as ModelOption
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// The boot-time catalog load runs against the PERSISTED PIN, before `workspace.init()` has
|
|
21
|
+
// validated it against the board list. A pin can name a board that was deleted, or one whose
|
|
22
|
+
// access was revoked while the browser held it, and the RBAC gate answers both with a 404, so
|
|
23
|
+
// the load has to tolerate a miss. Left bare it was an uncaught rejection in the page (the
|
|
24
|
+
// `Workspace not found` a removed member's browser threw on their next visit).
|
|
25
|
+
describe('models store: the speculative load of an unvalidated pin', () => {
|
|
26
|
+
it('drops a pin that 404s and leaves the catalog retryable for the board init resolves', async () => {
|
|
27
|
+
const get = vi
|
|
28
|
+
.fn<(workspaceId: string) => Promise<ModelOption[]>>()
|
|
29
|
+
.mockRejectedValueOnce(Object.assign(new Error('Workspace not found'), { statusCode: 404 }))
|
|
30
|
+
.mockResolvedValueOnce([model()])
|
|
31
|
+
vi.stubGlobal('useApi', () => ({ getWorkspaceModels: get }))
|
|
32
|
+
|
|
33
|
+
const store = useModelsStore()
|
|
34
|
+
// The revoked pin. Resolves rather than rejects: nothing in the page catches it.
|
|
35
|
+
await expect(store.prefetchForBoard('ws_revoked')).resolves.toBeUndefined()
|
|
36
|
+
|
|
37
|
+
// Nothing was latched, so this reads as UNRESOLVED rather than as a board with no models
|
|
38
|
+
// (`useAiReadiness().ready` is `loaded && loadedWorkspaceId === workspaceId`, which is what
|
|
39
|
+
// keeps the no-AI onboarding prompt from firing off a catalog that never landed).
|
|
40
|
+
expect(store.loaded).toBe(false)
|
|
41
|
+
expect(store.loadedWorkspaceId).toBeNull()
|
|
42
|
+
expect(store.models).toEqual([])
|
|
43
|
+
|
|
44
|
+
// ...and the board `init()` resolves instead still loads, on the same store.
|
|
45
|
+
await store.ensureLoaded('ws_reachable')
|
|
46
|
+
expect(store.loaded).toBe(true)
|
|
47
|
+
expect(store.loadedWorkspaceId).toBe('ws_reachable')
|
|
48
|
+
expect(store.models).toHaveLength(1)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('a pin that IS reachable loads the catalog once, and the later caller reuses it', async () => {
|
|
52
|
+
const get = vi.fn(() => Promise.resolve([model()]))
|
|
53
|
+
vi.stubGlobal('useApi', () => ({ getWorkspaceModels: get }))
|
|
54
|
+
|
|
55
|
+
const store = useModelsStore()
|
|
56
|
+
await store.prefetchForBoard('ws1')
|
|
57
|
+
// What the cold open pays for: `init()` hydrating the same board finds the catalog already
|
|
58
|
+
// there, so the prefetch is one request rather than a duplicate of the one that follows it.
|
|
59
|
+
await store.ensureLoaded('ws1')
|
|
60
|
+
|
|
61
|
+
expect(get).toHaveBeenCalledTimes(1)
|
|
62
|
+
expect(store.hasUsableModel).toBe(true)
|
|
63
|
+
})
|
|
64
|
+
})
|
package/app/stores/models.ts
CHANGED
|
@@ -122,6 +122,26 @@ export const useModelsStore = defineStore('models', () => {
|
|
|
122
122
|
loaded.value = true
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Load the catalog for a board the app has NOT yet validated: the persisted pin at boot,
|
|
127
|
+
* fetched in parallel with the workspace list rather than after it.
|
|
128
|
+
*
|
|
129
|
+
* A pin can name a board that was deleted, or one whose access has since been revoked, and the
|
|
130
|
+
* gate answers both with a 404 (`workspace.init()` guards the same speculative read of the same
|
|
131
|
+
* id with `.catch(() => null)`). So a failure here is an expected outcome rather than a fault,
|
|
132
|
+
* and dropping it is safe in both directions: `loaded` stays false, so this leaves the catalog
|
|
133
|
+
* RETRYABLE for the next `ensureLoaded` caller, and `useAiReadiness().ready` stays false, so a
|
|
134
|
+
* catalog that never landed reads as unresolved instead of as a board with no AI configured.
|
|
135
|
+
*/
|
|
136
|
+
async function prefetchForBoard(workspaceId: string): Promise<void> {
|
|
137
|
+
try {
|
|
138
|
+
await ensureLoaded(workspaceId)
|
|
139
|
+
} catch {
|
|
140
|
+
// Deliberate: see above. `init()` re-points the board it resolved, which loads the catalog
|
|
141
|
+
// that counts; anything else retries on the next caller.
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
125
145
|
/** Force a re-fetch of the per-workspace catalog (e.g. after adding an API key). */
|
|
126
146
|
async function refresh(workspaceId: string) {
|
|
127
147
|
models.value = await api.getWorkspaceModels(workspaceId)
|
|
@@ -180,6 +200,7 @@ export const useModelsStore = defineStore('models', () => {
|
|
|
180
200
|
loaded,
|
|
181
201
|
loadedWorkspaceId,
|
|
182
202
|
ensureLoaded,
|
|
203
|
+
prefetchForBoard,
|
|
183
204
|
refresh,
|
|
184
205
|
byId,
|
|
185
206
|
getModel,
|
package/app/types/documents.ts
CHANGED
package/i18n/locales/de.json
CHANGED
|
@@ -2818,7 +2818,8 @@
|
|
|
2818
2818
|
"derivedTitleFallback": "Pull Request prüfen",
|
|
2819
2819
|
"prNotFound": "Pull Request #{number} wurde im Repository dieses Service nicht gefunden. Prüfe die Nummer, oder verknüpfe den Service mit dem Repository, in dem der Pull Request liegt.",
|
|
2820
2820
|
"prRepoMismatch": "Dieser Pull Request liegt in einem anderen Repository. Dieser Service prüft {repo}; lege die Prüfaufgabe unter dem Service an, der mit dem Repository des Pull Requests verknüpft ist."
|
|
2821
|
-
}
|
|
2821
|
+
},
|
|
2822
|
+
"contextFailed": "Aufgabe nicht erstellt: {count} Anhang konnte nicht gelesen werden | Aufgabe nicht erstellt: {count} Anhänge konnten nicht gelesen werden"
|
|
2822
2823
|
},
|
|
2823
2824
|
"recurring": {
|
|
2824
2825
|
"title": "Eine wiederkehrende Pipeline hinzufügen",
|
|
@@ -3004,7 +3005,8 @@
|
|
|
3004
3005
|
"attachDocDisabledEnable": "Aktivieren Sie zuerst die Dokumente-Integration",
|
|
3005
3006
|
"attachIssueDisabledConnect": "Verbinden Sie zuerst einen Issue-Tracker (Integrationen)",
|
|
3006
3007
|
"attachIssueDisabledEnable": "Aktivieren Sie zuerst die Issue-Tracker-Integration",
|
|
3007
|
-
"importsOnAdd": "importiert beim Hinzufügen"
|
|
3008
|
+
"importsOnAdd": "importiert beim Hinzufügen",
|
|
3009
|
+
"unreadable": "Konnte nicht abgerufen werden: {error}"
|
|
3008
3010
|
},
|
|
3009
3011
|
"providers": {
|
|
3010
3012
|
"presetMismatch": {
|
|
@@ -3783,7 +3785,15 @@
|
|
|
3783
3785
|
"attachByReference": "{ref} per Referenz anhängen",
|
|
3784
3786
|
"noMatches": "Keine passenden Seiten.",
|
|
3785
3787
|
"emptySearchable": "Nach Titel suchen oder ein importiertes Dokument auswählen.",
|
|
3786
|
-
"emptyRefOnly": "Fügen Sie eine Seiten-URL oder -ID ein, um sie anzuhängen."
|
|
3788
|
+
"emptyRefOnly": "Fügen Sie eine Seiten-URL oder -ID ein, um sie anzuhängen.",
|
|
3789
|
+
"refChecking": "Referenz wird geprüft…",
|
|
3790
|
+
"refUnrecognized": "Keine {source}-Referenz. Erwartet: {expected}",
|
|
3791
|
+
"refOtherSource": "Das ist ein {claimed}-Link, kein {source}-Link.",
|
|
3792
|
+
"refSwitchSource": "Stattdessen {source} verwenden",
|
|
3793
|
+
"refTrimmed": "Auf die unterstützte Form gekürzt",
|
|
3794
|
+
"refWidened": "Nennt einen Frame, den diese Quelle nicht lesen kann ({scope}); daher wird die gesamte Datei angehängt.",
|
|
3795
|
+
"refAlreadyAttached": "Diese Referenz ist bereits angehängt.",
|
|
3796
|
+
"refCheckFailed": "Referenz konnte nicht geprüft werden: {error}"
|
|
3787
3797
|
},
|
|
3788
3798
|
"repoPicker": {
|
|
3789
3799
|
"searchRepoPlaceholder": "Repositorys suchen…",
|
|
@@ -5040,7 +5050,8 @@
|
|
|
5040
5050
|
"failedTitle": "Die Initiative konnte nicht erstellt werden",
|
|
5041
5051
|
"contextDocsHint": "Hänge eine Anforderung, ein RFC oder ein PRD an, damit die Planungsagenten es beim Abstecken und Entwerfen des Plans lesen.",
|
|
5042
5052
|
"contextIssuesHint": "Hänge ein Tracker-Issue an, damit die Planungsagenten beim Entwerfen des Plans seine Beschreibung und Kommentare sehen.",
|
|
5043
|
-
"linkFailed": "Initiative erstellt, aber {count} Anhang konnte nicht verknüpft werden | Initiative erstellt, aber {count} Anhänge konnten nicht verknüpft werden"
|
|
5053
|
+
"linkFailed": "Initiative erstellt, aber {count} Anhang konnte nicht verknüpft werden | Initiative erstellt, aber {count} Anhänge konnten nicht verknüpft werden",
|
|
5054
|
+
"contextFailed": "Initiative nicht erstellt: {count} Anhang konnte nicht gelesen werden | Initiative nicht erstellt: {count} Anhänge konnten nicht gelesen werden"
|
|
5044
5055
|
},
|
|
5045
5056
|
"status": {
|
|
5046
5057
|
"planning": "Planung",
|
package/i18n/locales/en.json
CHANGED
|
@@ -347,6 +347,10 @@
|
|
|
347
347
|
"derivedTitleFallback": "Review pull request",
|
|
348
348
|
"prNotFound": "Pull request #{number} was not found in this service's repository. Check the number, or link the service to the repository that pull request is on.",
|
|
349
349
|
"prRepoMismatch": "That pull request is on a different repository. This service reviews {repo}, so create the review task under the service linked to the pull request's repository."
|
|
350
|
+
},
|
|
351
|
+
"contextFailed": "Task not created: {count} attachment could not be read | Task not created: {count} attachments could not be read",
|
|
352
|
+
"@contextFailed": {
|
|
353
|
+
"description": "Count-based: how many context attachments (docs/issues) could not be fetched, which is why nothing was created (count is always >= 1). Provide ALL plural forms your language needs (English has 2; Polish/Ukrainian need 3 - one/few/many - via the custom pluralRules in i18n.config.ts)."
|
|
350
354
|
}
|
|
351
355
|
},
|
|
352
356
|
"recurring": {
|
|
@@ -548,7 +552,8 @@
|
|
|
548
552
|
"attachDocDisabledEnable": "Enable the documents integration first",
|
|
549
553
|
"attachIssueDisabledConnect": "Connect an issue tracker first (Integrations)",
|
|
550
554
|
"attachIssueDisabledEnable": "Enable the issue-tracker integration first",
|
|
551
|
-
"importsOnAdd": "imports on add"
|
|
555
|
+
"importsOnAdd": "imports on add",
|
|
556
|
+
"unreadable": "Could not be fetched: {error}"
|
|
552
557
|
},
|
|
553
558
|
"errors": {
|
|
554
559
|
"generic": {
|
|
@@ -4300,7 +4305,15 @@
|
|
|
4300
4305
|
"attachByReference": "Attach {ref} by reference",
|
|
4301
4306
|
"noMatches": "No matching pages.",
|
|
4302
4307
|
"emptySearchable": "Search by title, or pick an imported document.",
|
|
4303
|
-
"emptyRefOnly": "Paste a page URL or ID to attach it."
|
|
4308
|
+
"emptyRefOnly": "Paste a page URL or ID to attach it.",
|
|
4309
|
+
"refChecking": "Checking the reference…",
|
|
4310
|
+
"refUnrecognized": "Not a {source} reference. Expected {expected}",
|
|
4311
|
+
"refOtherSource": "That is a {claimed} link, not a {source} one.",
|
|
4312
|
+
"refSwitchSource": "Use {source} instead",
|
|
4313
|
+
"refTrimmed": "Trimmed to the supported form",
|
|
4314
|
+
"refWidened": "Names a frame this source cannot read ({scope}), so the whole file is attached.",
|
|
4315
|
+
"refAlreadyAttached": "This reference is already attached.",
|
|
4316
|
+
"refCheckFailed": "Could not check the reference: {error}"
|
|
4304
4317
|
},
|
|
4305
4318
|
"repoPicker": {
|
|
4306
4319
|
"searchRepoPlaceholder": "Search repositories…",
|
|
@@ -6515,6 +6528,10 @@
|
|
|
6515
6528
|
"linkFailed": "Initiative created, but {count} attachment could not be linked | Initiative created, but {count} attachments could not be linked",
|
|
6516
6529
|
"@linkFailed": {
|
|
6517
6530
|
"description": "Count-based: how many context attachments (docs/issues) failed to link after the initiative was created (count is always >= 1). Provide ALL plural forms your language needs (English has 2; Polish/Ukrainian need 3 - one/few/many - via the custom pluralRules in i18n.config.ts)."
|
|
6531
|
+
},
|
|
6532
|
+
"contextFailed": "Initiative not created: {count} attachment could not be read | Initiative not created: {count} attachments could not be read",
|
|
6533
|
+
"@contextFailed": {
|
|
6534
|
+
"description": "Count-based: how many context attachments (docs/issues) could not be fetched, which is why nothing was created (count is always >= 1). Provide ALL plural forms your language needs (English has 2; Polish/Ukrainian need 3 - one/few/many - via the custom pluralRules in i18n.config.ts)."
|
|
6518
6535
|
}
|
|
6519
6536
|
},
|
|
6520
6537
|
"status": {
|
package/i18n/locales/es.json
CHANGED
|
@@ -311,7 +311,8 @@
|
|
|
311
311
|
"derivedTitleFallback": "Revisar la pull request",
|
|
312
312
|
"prNotFound": "No se encontró la pull request n.º {number} en el repositorio de este servicio. Comprueba el número, o vincula el servicio al repositorio en el que está esa pull request.",
|
|
313
313
|
"prRepoMismatch": "Esa pull request está en otro repositorio. Este servicio revisa {repo}, así que crea la tarea de revisión en el servicio vinculado al repositorio de la pull request."
|
|
314
|
-
}
|
|
314
|
+
},
|
|
315
|
+
"contextFailed": "Tarea no creada: no se pudo leer {count} adjunto | Tarea no creada: no se pudieron leer {count} adjuntos"
|
|
315
316
|
},
|
|
316
317
|
"recurring": {
|
|
317
318
|
"title": "Añadir una pipeline recurrente",
|
|
@@ -497,7 +498,8 @@
|
|
|
497
498
|
"attachDocDisabledEnable": "Activa primero la integración de documentos",
|
|
498
499
|
"attachIssueDisabledConnect": "Conecta primero un gestor de incidencias (Integraciones)",
|
|
499
500
|
"attachIssueDisabledEnable": "Activa primero la integración del gestor de incidencias",
|
|
500
|
-
"importsOnAdd": "se importa al añadir"
|
|
501
|
+
"importsOnAdd": "se importa al añadir",
|
|
502
|
+
"unreadable": "No se pudo obtener: {error}"
|
|
501
503
|
},
|
|
502
504
|
"errors": {
|
|
503
505
|
"generic": {
|
|
@@ -4166,7 +4168,15 @@
|
|
|
4166
4168
|
"attachByReference": "Adjuntar {ref} por referencia",
|
|
4167
4169
|
"noMatches": "No hay páginas que coincidan.",
|
|
4168
4170
|
"emptySearchable": "Busca por título o elige un documento importado.",
|
|
4169
|
-
"emptyRefOnly": "Pega la URL o el ID de una página para adjuntarla."
|
|
4171
|
+
"emptyRefOnly": "Pega la URL o el ID de una página para adjuntarla.",
|
|
4172
|
+
"refChecking": "Comprobando la referencia…",
|
|
4173
|
+
"refUnrecognized": "No es una referencia de {source}. Se esperaba {expected}",
|
|
4174
|
+
"refOtherSource": "Es un enlace de {claimed}, no de {source}.",
|
|
4175
|
+
"refSwitchSource": "Usar {source} en su lugar",
|
|
4176
|
+
"refTrimmed": "Recortado al formato admitido",
|
|
4177
|
+
"refWidened": "Nombra un marco que esta fuente no puede leer ({scope}), así que se adjunta el archivo completo.",
|
|
4178
|
+
"refAlreadyAttached": "Esta referencia ya está adjunta.",
|
|
4179
|
+
"refCheckFailed": "No se pudo comprobar la referencia: {error}"
|
|
4170
4180
|
},
|
|
4171
4181
|
"repoPicker": {
|
|
4172
4182
|
"searchRepoPlaceholder": "Buscar repositorios…",
|
|
@@ -6296,7 +6306,8 @@
|
|
|
6296
6306
|
"failedTitle": "No se pudo crear la iniciativa",
|
|
6297
6307
|
"contextDocsHint": "Adjunta un requisito, RFC o PRD para que los agentes de planificación lo lean al delimitar y redactar el plan.",
|
|
6298
6308
|
"contextIssuesHint": "Adjunta una incidencia para que los agentes de planificación vean su descripción y comentarios al redactar el plan.",
|
|
6299
|
-
"linkFailed": "Iniciativa creada, pero no se pudo vincular {count} adjunto | Iniciativa creada, pero no se pudieron vincular {count} adjuntos"
|
|
6309
|
+
"linkFailed": "Iniciativa creada, pero no se pudo vincular {count} adjunto | Iniciativa creada, pero no se pudieron vincular {count} adjuntos",
|
|
6310
|
+
"contextFailed": "Iniciativa no creada: no se pudo leer {count} adjunto | Iniciativa no creada: no se pudieron leer {count} adjuntos"
|
|
6300
6311
|
},
|
|
6301
6312
|
"status": {
|
|
6302
6313
|
"planning": "Planificando",
|
package/i18n/locales/fr.json
CHANGED
|
@@ -311,7 +311,8 @@
|
|
|
311
311
|
"derivedTitleFallback": "Examiner la pull request",
|
|
312
312
|
"prNotFound": "La pull request n° {number} est introuvable dans le dépôt de ce service. Vérifiez le numéro, ou reliez le service au dépôt qui héberge cette pull request.",
|
|
313
313
|
"prRepoMismatch": "Cette pull request se trouve dans un autre dépôt. Ce service examine {repo} : créez la tâche de revue sous le service relié au dépôt de la pull request."
|
|
314
|
-
}
|
|
314
|
+
},
|
|
315
|
+
"contextFailed": "Tâche non créée : {count} pièce jointe illisible | Tâche non créée : {count} pièces jointes illisibles"
|
|
315
316
|
},
|
|
316
317
|
"recurring": {
|
|
317
318
|
"title": "Ajouter une pipeline récurrente",
|
|
@@ -497,7 +498,8 @@
|
|
|
497
498
|
"attachDocDisabledEnable": "Activez d’abord l’intégration de documents",
|
|
498
499
|
"attachIssueDisabledConnect": "Connectez d’abord un suivi de tickets (Intégrations)",
|
|
499
500
|
"attachIssueDisabledEnable": "Activez d’abord l’intégration du suivi de tickets",
|
|
500
|
-
"importsOnAdd": "importé à l’ajout"
|
|
501
|
+
"importsOnAdd": "importé à l’ajout",
|
|
502
|
+
"unreadable": "Récupération impossible : {error}"
|
|
501
503
|
},
|
|
502
504
|
"errors": {
|
|
503
505
|
"generic": {
|
|
@@ -4166,7 +4168,15 @@
|
|
|
4166
4168
|
"attachByReference": "Joindre {ref} par référence",
|
|
4167
4169
|
"noMatches": "Aucune page correspondante.",
|
|
4168
4170
|
"emptySearchable": "Recherchez par titre ou choisissez un document importé.",
|
|
4169
|
-
"emptyRefOnly": "Collez l'URL ou l'ID d'une page pour la joindre."
|
|
4171
|
+
"emptyRefOnly": "Collez l'URL ou l'ID d'une page pour la joindre.",
|
|
4172
|
+
"refChecking": "Vérification de la référence…",
|
|
4173
|
+
"refUnrecognized": "Ce n'est pas une référence {source}. Format attendu : {expected}",
|
|
4174
|
+
"refOtherSource": "C'est un lien {claimed}, pas un lien {source}.",
|
|
4175
|
+
"refSwitchSource": "Utiliser {source} à la place",
|
|
4176
|
+
"refTrimmed": "Réduit au format pris en charge",
|
|
4177
|
+
"refWidened": "Désigne un cadre que cette source ne peut pas lire ({scope}) : le fichier entier est donc joint.",
|
|
4178
|
+
"refAlreadyAttached": "Cette référence est déjà jointe.",
|
|
4179
|
+
"refCheckFailed": "Impossible de vérifier la référence : {error}"
|
|
4170
4180
|
},
|
|
4171
4181
|
"repoPicker": {
|
|
4172
4182
|
"searchRepoPlaceholder": "Rechercher des dépôts…",
|
|
@@ -6296,7 +6306,8 @@
|
|
|
6296
6306
|
"failedTitle": "Impossible de creer l'initiative",
|
|
6297
6307
|
"contextDocsHint": "Joignez une exigence, une RFC ou un PRD pour que les agents de planification la lisent en cadrant et en rédigeant le plan.",
|
|
6298
6308
|
"contextIssuesHint": "Joignez un ticket pour que les agents de planification voient sa description et ses commentaires en rédigeant le plan.",
|
|
6299
|
-
"linkFailed": "Initiative créée, mais {count} pièce jointe n’a pas pu être liée | Initiative créée, mais {count} pièces jointes n’ont pas pu être liées"
|
|
6309
|
+
"linkFailed": "Initiative créée, mais {count} pièce jointe n’a pas pu être liée | Initiative créée, mais {count} pièces jointes n’ont pas pu être liées",
|
|
6310
|
+
"contextFailed": "Initiative non créée : {count} pièce jointe illisible | Initiative non créée : {count} pièces jointes illisibles"
|
|
6300
6311
|
},
|
|
6301
6312
|
"status": {
|
|
6302
6313
|
"planning": "Planification",
|