Skip to content

An open-source, faster Devin alternative

TypeScript

web: item_not_found reads "No item N" with a link back; other 404s read not available yet

Igor Zalutski via Computer3668470edec6
diff --git a/web/src/api/mock-work.ts b/web/src/api/mock-work.ts
index f59fa0b7..8e1248b2 100644
--- a/web/src/api/mock-work.ts
+++ b/web/src/api/mock-work.ts
@@ -416,7 +416,8 @@ export function workMock(
const m = rest.match(/^\/items\/(\d+)(\/history)?$/)
if (m) {
const it = [...open, ...closed].find((i) => i.number === Number(m[1]))
- if (!it || !current) throw new ApiError('Not found', 404)
+ if (!it || !current)
+ throw new ApiError('No such item.', 404, 'item_not_found')
if (m[2]) return { revisions: revisions(it), nextCursor: null }
return { item: it, body: body(it) }
}
diff --git a/web/src/managed-agents/work/Item.tsx b/web/src/managed-agents/work/Item.tsx
index c4501bbe..10eff71b 100644
--- a/web/src/managed-agents/work/Item.tsx
+++ b/web/src/managed-agents/work/Item.tsx
@@ -80,20 +80,37 @@ export function ItemView() {
})
if (!valid || item.isError) {
- const missing =
- !valid || (item.error instanceof ApiError && item.error.status === 404)
+ const status = item.error instanceof ApiError ? item.error.status : null
+ // The server's 404 for a number it does not track; any other 404 means
+ // the routes are not there yet, as on the board.
+ const noItem =
+ !valid ||
+ (status === 404 &&
+ item.error instanceof ApiError &&
+ item.error.type === 'item_not_found')
+ const { title, description } = noItem
+ ? {
+ title: valid ? `No item ${number}` : 'No such item',
+ description:
+ 'Nothing tracked has this number. It may have been removed from the working docs.',
+ }
+ : status === 404
+ ? {
+ title: 'The board is not available yet',
+ description: 'Tracked work is coming to this organization soon.',
+ }
+ : {
+ title: 'Could not load this item',
+ description: 'Try loading this page again.',
+ }
return (
<div>
<Breadcrumb number={valid ? number : null} />
<Panel>
<EmptyState
icon={FileText}
- title={missing ? 'No such item' : 'Could not load this item'}
- description={
- missing
- ? 'It may have been renamed, or tracked work is not available here yet.'
- : 'Try loading this page again.'
- }
+ title={title}
+ description={description}
action={
<Link
to="/computer/work"
diff --git a/web/src/managed-agents/work/screens.test.tsx b/web/src/managed-agents/work/screens.test.tsx
index b57f9a08..dce30c20 100644
--- a/web/src/managed-agents/work/screens.test.tsx
+++ b/web/src/managed-agents/work/screens.test.tsx
@@ -418,9 +418,22 @@ describe('item page', () => {
).toContain('abcdef1')
})
- it('says when there is no such item', async () => {
+ it('says when there is no such item, with a way back', async () => {
+ workApi.getItem.mockRejectedValue(
+ new ApiError('No such item.', 404, 'item_not_found'),
+ )
+ await render('/computer/work/123')
+ expect(container.textContent).toContain('No item 123')
+ const back = [...container.querySelectorAll('a')].find(
+ (a) => a.textContent === 'Back to the board',
+ )
+ expect(back?.getAttribute('href')).toBe('/computer/work')
+ })
+
+ it('reads any other 404 as not available yet', async () => {
workApi.getItem.mockRejectedValue(new ApiError('Not found', 404))
await render('/computer/work/99')
- expect(container.textContent).toContain('No such item')
+ expect(container.textContent).toContain('The board is not available yet')
+ expect(container.textContent).not.toContain('No item')
})
})