Remove the MOVED redirects

MOVED and _moved answered 301 for twelve paths the settings cog moved
off of a few days ago. A browser caches a 301 indefinitely, so a path
reused later would be unreachable through no fault of that page, and
a one-person app has no outstanding bookmark to protect. Drop the
table, the routes, its export from app.web, and the tests that pinned
it; the old paths now answer plain 404. Keep the test that every
section of the Sources page exists, rewritten without MOVED.

Co-Authored-By: Claude Sonnet <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Sonnet committed 2026-09-29 14:50:18 +02:00
1 parent 706b127bc0
commit 92ff2bc069
5 files changed
+24 -78

No files matched your search

+2 -2
View File
@@ -208,8 +208,8 @@
// Sources shows one section: the one the fragment names or contains, or the // Sources shows one section: the one the fragment names or contains, or the
// first when there is none or it names none, so `/settings/sources#runs` (a // first when there is none or it names none, so `/settings/sources#runs` (a
// rail link, an old path's 301, the Search agents page's "follow it under // rail link, or the Search agents page's "follow it under Runs") opens
// Runs") opens Runs, and so does `#messages`, the log at its end. The rest // Runs, and so does `#messages`, the log at its end. The rest
// are hidden, not removed, so their scripts still find their roots. It runs // are hidden, not removed, so their scripts still find their roots. It runs
// as the script loads rather than on DOMContentLoaded, so the page never // as the script loads rather than on DOMContentLoaded, so the page never
// paints all three first. // paints all three first.
+2 -2
View File
@@ -7,8 +7,8 @@ from __future__ import annotations
from app.web.api import router as api_router from app.web.api import router as api_router
from app.web.pages import ( from app.web.pages import (
MOVED, SETTINGS, STATIC_DIR, TABS, router as pages_router, templates, SETTINGS, STATIC_DIR, TABS, router as pages_router, templates,
) )
__all__ = ["MOVED", "SETTINGS", "STATIC_DIR", "TABS", "api_router", "pages_router", __all__ = ["SETTINGS", "STATIC_DIR", "TABS", "api_router", "pages_router",
"templates"] "templates"]
-44
View File
@@ -23,13 +23,6 @@ contains; the others stay in the page, hidden, so each section's script (the
ones they had as pages of their own, each guarding on its own root element) ones they had as pages of their own, each guarding on its own root element)
keeps working. keeps working.
Every path a page has had before (`/agents`, `/companies`, `/sources`,
`/jobs`, `/schedules`, `/messages`, `/account`, and the six sub-tabs the
settings shell started with) answers 301 to its place now, query string
kept, so a bookmark still lands. A merged page's old path lands on its
section's anchor; the old Messages paths land on `#messages`, the log's
block at the end of Runs.
`FUNCTIONS` and `HOSTS` are `plugins.ats`'s, not `app`'s: the nine job `FUNCTIONS` and `HOSTS` are `plugins.ats`'s, not `app`'s: the nine job
functions are the classifier's vocabulary and the hosts are what it parses, functions are the classifier's vocabulary and the hosts are what it parses,
and this reaches `plugins/` the same way `app.cli` does, since a plugin is and this reaches `plugins/` the same way `app.cli` does, since a plugin is
@@ -41,7 +34,6 @@ Jobindex areas and Adzuna countries on the Sources page come from
from __future__ import annotations from __future__ import annotations
import sys import sys
from collections.abc import Callable
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
@@ -94,24 +86,6 @@ SECTIONS: dict[str, tuple[tuple[str, str], ...]] = {
), ),
} }
#: Where each page that used to be a tab or a sub-tab lives now. The fragment
#: is the section on the merged page, or an element in one (`#messages`, in
#: Runs); a browser keeps it across the 301.
MOVED: dict[str, str] = {
"/agents": "/settings/agents",
"/settings/ranking": "/settings/agents",
"/companies": "/settings/sources#company-boards",
"/settings/companies": "/settings/sources#company-boards",
"/sources": "/settings/sources#job-boards",
"/settings/searches": "/settings/sources#job-boards",
"/jobs": "/settings/sources#runs",
"/schedules": "/settings/sources#runs",
"/settings/pulls": "/settings/sources#runs",
"/messages": "/settings/sources#messages",
"/settings/messages": "/settings/sources#messages",
"/account": "/settings/account",
}
#: `value, label` for each select option. `FUNCTIONS` is already the value a #: `value, label` for each select option. `FUNCTIONS` is already the value a
#: role's `function` column holds; only the label is dressed up. #: role's `function` column holds; only the label is dressed up.
FUNCTION_OPTIONS = [(f, f.replace("/", " / ").capitalize()) for f in FUNCTIONS] FUNCTION_OPTIONS = [(f, f.replace("/", " / ").capitalize()) for f in FUNCTIONS]
@@ -192,21 +166,3 @@ def sources(request: Request) -> HTMLResponse:
@router.get("/settings/account", response_class=HTMLResponse) @router.get("/settings/account", response_class=HTMLResponse)
def account(request: Request) -> HTMLResponse: def account(request: Request) -> HTMLResponse:
return page(request, "settings/account.html") return page(request, "settings/account.html")
def _moved(to: str) -> Callable[[Request], RedirectResponse]:
"""A 301 to `to`, carrying the query string, so `/agents?x=1` keeps it.
The query goes before `to`'s fragment, if it has one, or the browser
would read `#runs?x=1` as one fragment."""
path, _, fragment = to.partition("#")
def redirect(request: Request) -> RedirectResponse:
query = request.url.query
target = f"{path}?{query}" if query else path
return RedirectResponse(f"{target}#{fragment}" if fragment else target,
status_code=301)
return redirect
for _old, _new in MOVED.items():
router.add_api_route(_old, _moved(_new), methods=["GET"],
response_class=RedirectResponse)
+5 -3
View File
@@ -126,15 +126,17 @@ What was decided for roledesk and the one reason for each. The longer reasoning
## The phone ## The phone
**Two tabs and a cog.** `TABS` in `app/web/pages.py` becomes Roles and Applications; the other six pages (Agents, Companies, Sources, Jobs, Schedules, Messages, Account) move behind a settings cog at `/settings/<name>`, because nine tabs wrapped to three rows on a phone and six of them were setup or system pages. The old paths answer 301 to their new place, query string kept, so a bookmark or a `?agent=` link still lands. **Two tabs and a cog.** `TABS` in `app/web/pages.py` becomes Roles and Applications; the other six pages (Agents, Companies, Sources, Jobs, Schedules, Messages, Account) move behind a settings cog at `/settings/<name>`, because nine tabs wrapped to three rows on a phone and six of them were setup or system pages.
**Settings are three sub-tabs: Search agents, Sources, Account.** Six sub-tabs were three setup pages and three system pages for two things, what the app ranks by and where roles come from, so each is one page now and Account stays its own. The old paths answer 301 to the section they became. **Settings are three sub-tabs: Search agents, Sources, Account.** Six sub-tabs were three setup pages and three system pages for two things, what the app ranks by and where roles come from, so each is one page now and Account stays its own.
**The old paths' 301s are gone.** `MOVED` answered 301 for the twelve paths above, kept for the few days between the move and this cut, on the assumption that a bookmark should still land. A browser caches a 301 indefinitely, so a path a future page reused would be unreachable through no fault of that page; a one-person app with no outstanding bookmarks does not need to carry that risk.
**Sources is one page, one section per plugin.** Job boards are the `search` plugin's queries, company boards are `ats`'s, and the runs that read both end the page with the message log. A source's section says which plugin it is, and following a company, hiding it and switching its board off are one list. The UI says "job board" for what the API and CLI call a search, since "search agent" already means something else. **Sources is one page, one section per plugin.** Job boards are the `search` plugin's queries, company boards are `ats`'s, and the runs that read both end the page with the message log. A source's section says which plugin it is, and following a company, hiding it and switching its board off are one list. The UI says "job board" for what the API and CLI call a search, since "search agent" already means something else.
**Search agents are back in the UI as a list.** One person may run several: their own hunt, and one that monitors roles for someone else, each with its own intent and gates. The list has New and Delete; a delete takes the agent's votes, liked companies and scores with it. **Search agents are back in the UI as a list.** One person may run several: their own hunt, and one that monitors roles for someone else, each with its own intent and gates. The list has New and Delete; a delete takes the agent's votes, liked companies and scores with it.
**Settings pages sit beside a rail, and Sources shows one section at a time, chosen by the URL fragment.** The company boards list runs to 50 or 60 companies, so Runs at the end of a stacked page was out of reach and jump links still meant scrolling back up. The rail (`settings/_rail.html`, from `SETTINGS` and `SECTIONS` in `app/web/pages.py`) is sticky beside the content, and a strip under the header below 60rem. The fragment rather than a path per section, because the old paths already 301 to `/settings/sources#runs` and the like, and a hidden section stays in the DOM, so each section's script runs unchanged. **Settings pages sit beside a rail, and Sources shows one section at a time, chosen by the URL fragment.** The company boards list runs to 50 or 60 companies, so Runs at the end of a stacked page was out of reach and jump links still meant scrolling back up. The rail (`settings/_rail.html`, from `SETTINGS` and `SECTIONS` in `app/web/pages.py`) is sticky beside the content, and a strip under the header below 60rem. The fragment rather than a path per section, because a hidden section stays in the DOM, so each section's script runs unchanged.
**Runs is the queue's own elements plus a Problems log.** `<desk-jobs>` and `<desk-schedules>` draw what is running and when the pull runs next, the app adds only "Run the pull now", disabled while a pull cascade is live, and the message log is the section's last block rather than a section of its own; `#messages` still lands on it. "Run one stage" went because the cascade is the unit of work: a stage run alone is a partial pull whose result the next stage never sees. `app job <stage>` and `POST /api/jobs` keep the per-stage entry points, which is what "Save and score" uses. **Runs is the queue's own elements plus a Problems log.** `<desk-jobs>` and `<desk-schedules>` draw what is running and when the pull runs next, the app adds only "Run the pull now", disabled while a pull cascade is live, and the message log is the section's last block rather than a section of its own; `#messages` still lands on it. "Run one stage" went because the cascade is the unit of work: a stage run alone is a partial pull whose result the next stage never sees. `app job <stage>` and `POST /api/jobs` keep the per-stage entry points, which is what "Save and score" uses.
+15 -27
View File
@@ -17,7 +17,7 @@ from fastapi.testclient import TestClient
from app.config import Config, ServerConfig from app.config import Config, ServerConfig
from app.main import create_app from app.main import create_app
from app.storage import Store from app.storage import Store
from app.web import MOVED, SETTINGS, TABS from app.web import SETTINGS, TABS
from app.web.pages import SECTIONS from app.web.pages import SECTIONS
from auth import AuthConfig from auth import AuthConfig
from desk.models import Item from desk.models import Item
@@ -575,11 +575,10 @@ def test_every_settings_page_has_the_rail_and_not_the_tab_row(client: TestClient
< rail.index('href="/settings/account"') < rail.index('href="/settings/account"')
def test_a_moved_section_is_one_the_sources_page_shows(client: TestClient) -> None: def test_every_section_of_the_sources_page_exists(client: TestClient) -> None:
"""Every old path that lands on a fragment of Sources names a section of """Each entry of `SECTIONS["/settings/sources"]` is a `<section
`SECTIONS` or an element inside one, and each section is a `<section data-section>` on the page, which is what sources.js shows one of, and
data-section>` on the page, which is what sources.js shows one of. The the log at the end of Runs still answers `#messages`."""
old Messages paths land on `#messages`, the log at the end of Runs."""
anchors = [anchor for anchor, _ in SECTIONS["/settings/sources"]] anchors = [anchor for anchor, _ in SECTIONS["/settings/sources"]]
assert anchors == ["job-boards", "company-boards", "runs"] assert anchors == ["job-boards", "company-boards", "runs"]
page = client.get("/settings/sources").text page = client.get("/settings/sources").text
@@ -587,12 +586,7 @@ def test_a_moved_section_is_one_the_sources_page_shows(client: TestClient) -> No
for anchor in anchors: for anchor in anchors:
assert f'<section class="card" id="{anchor}" data-section>' in page assert f'<section class="card" id="{anchor}" data-section>' in page
runs = page[page.index('id="runs"'):] runs = page[page.index('id="runs"'):]
for to in MOVED.values(): assert 'id="messages"' in runs
path, _, anchor = to.partition("#")
if anchor:
assert path == "/settings/sources", to
assert anchor in anchors or f'id="{anchor}"' in runs, to
assert MOVED["/messages"] == MOVED["/settings/messages"] == "/settings/sources#messages"
def test_settings_is_search_agents(client: TestClient) -> None: def test_settings_is_search_agents(client: TestClient) -> None:
@@ -600,21 +594,15 @@ def test_settings_is_search_agents(client: TestClient) -> None:
assert res.status_code == 302 and res.headers["location"] == "/settings/agents" assert res.status_code == 302 and res.headers["location"] == "/settings/agents"
@pytest.mark.parametrize(("old", "new"), sorted(MOVED.items())) @pytest.mark.parametrize("old", ["/agents", "/settings/ranking", "/companies", "/sources",
def test_an_old_tab_moves_permanently_and_keeps_its_query( "/jobs", "/schedules", "/messages", "/settings/searches",
client: TestClient, old: str, new: str) -> None: "/settings/companies", "/settings/pulls",
"""A merged page's old path lands on its section: the query goes before "/settings/messages", "/account"])
the anchor, or the browser would take `#runs?q=` as one fragment.""" def test_an_old_tab_path_is_gone(client: TestClient, old: str) -> None:
assert {"/agents", "/settings/ranking", "/companies", "/sources", "/jobs", """The paths the settings cog moved off of answer 404 now, not a cached
"/schedules", "/messages", "/settings/searches", "/settings/companies", 301: a browser caches a 301 indefinitely, so a path reused later would be
"/settings/pulls", "/settings/messages", "/account"} <= set(MOVED) unreachable were the redirect still there."""
path, _, anchor = new.partition("#") assert client.get(old).status_code == 404
res = client.get(old, follow_redirects=False)
assert res.status_code == 301 and res.headers["location"] == new
res = client.get(f"{old}?agent=3&q=a+b", follow_redirects=False)
assert res.status_code == 301
assert res.headers["location"] == f"{path}?agent=3&q=a+b" + (f"#{anchor}" if anchor else "")
assert client.get(old).status_code == 200
def test_each_page_loads_only_its_own_script(client: TestClient) -> None: def test_each_page_loads_only_its_own_script(client: TestClient) -> None: