From 308d2c5effff498f0db5748d87079192945003b1 Mon Sep 17 00:00:00 2001 From: Wolf Date: Tue, 29 Sep 2026 16:53:46 +0200 Subject: [PATCH 1/5] Say in the Where block that its lines add up Co-Authored-By: Claude Fable 5.1 --- app/static/agents.js | 18 +++++++++++------- app/templates/settings/agents.html | 10 +++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/static/agents.js b/app/static/agents.js index dc630d2..611a714 100644 --- a/app/static/agents.js +++ b/app/static/agents.js @@ -198,21 +198,25 @@ } // The Where block in words, one sentence of the lines a role may match, - // with the one-of rows among them since they are the same group: "Roles in - // Denmark, in Malmö, Lund or Helsingborg, or remote within Europe." + // with the one-of rows among them since they are the same group: "Keeps + // roles anywhere in Denmark, in Malmö, Lund or Helsingborg, or remote within + // Europe, and leaves out the rest." The lines add up, which the first + // wording ("Roles in ...") left the owner to guess. function whereSentence(where, others) { const parts = []; - if (where.countries) parts.push(phrase(where.countries)); + if (where.countries) parts.push(`anywhere ${phrase(where.countries)}`); if (where.places) parts.push(phrase(where.places)); if (where.remote) parts.push(where.europe ? "remote within Europe" : "remote"); parts.push(...others.map(phrase)); if (!parts.length) return ""; - return `Roles ${parts.length < 2 ? parts[0] : `${parts.slice(0, -1).join(", ")}, or ${parts[parts.length - 1]}`}.`; + const list = parts.length < 2 ? parts[0] : `${parts.slice(0, -1).join(", ")}, or ${parts[parts.length - 1]}`; + return `Keeps roles ${list}, and leaves out the rest.`; } // The gates in words: where a role may be, then what it must meet, then - // what lifts it. "Roles in Denmark, or remote within Europe. Only roles - // with seniority senior. Prefers hybrid." + // what lifts it. "Keeps roles anywhere in Denmark, or remote within Europe, + // and leaves out the rest. Only roles with seniority senior. Prefers + // hybrid." function rulesLine(gates) { const { where, rest } = distribute(gates); const of = (mode) => rest.filter((g) => g.mode === mode); @@ -604,7 +608,7 @@ const view = () => { offerScope(); $("#a-gates", f).value = JSON.stringify(gates(), null, 2); - $("#a-where-sum", f).textContent = rulesLine(gates()) || "Roles anywhere."; + $("#a-where-sum", f).textContent = rulesLine(gates()) || "Keeps roles anywhere."; }; view(); diff --git a/app/templates/settings/agents.html b/app/templates/settings/agents.html index b07a7f8..784cb42 100644 --- a/app/templates/settings/agents.html +++ b/app/templates/settings/agents.html @@ -28,18 +28,18 @@
Where can the role be? - A role passes when it matches any line; with none filled in, it can be anywhere. A role whose location is not known yet ranks until extract reads the posting. + Each line adds places. A role is kept when it fits at least one line, so a line more means more roles, never fewer. With every line empty a role can be anywhere. A role whose location is not known yet ranks until extract reads the posting.
- In these countries + Anywhere in
- In these towns + or in the towns
- A town matches as part of the location, so Lund matches "Lund, Sweden": it is for towns outside the countries above. + Towns are for places outside the countries above: with Denmark above, Malmö here adds Malmö to all of Denmark. A town inside a country above changes nothing, since the whole country is in already.
- + + {# The options and their counts are drawn by watchlist.js, which also + remembers the choice. #} + + + +

+
+{% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/app/web/api.py b/app/web/api.py index 229f8b6..b458c0b 100644 --- a/app/web/api.py +++ b/app/web/api.py @@ -304,7 +304,8 @@ class CompanyOut(BaseModel): while it answers. `from_search` marks a row that exists only because a search listed its roles and somebody judged it (`Store.set_affinity`): no board, not even a detached one, and no `ats`, `careers_url` or - `domain`, which every way of following a company writes one of.""" + `domain`, which every way of following a company writes one of. + `watch` and `careers_opened_at` are the Watchlist's (`Company`'s).""" key: str name: str @@ -317,6 +318,10 @@ class CompanyOut(BaseModel): ats_slug: str = "" careers_url: str = "" country: str = "" + city: str = "" + domain: str = "" + watch: int | None = None + careers_opened_at: str = "" failing_since: str = "" failing_reason: str = "" from_search: bool = False @@ -353,7 +358,8 @@ def list_companies(store: StoreDep, agent: int | None = None) -> list[CompanyOut subscription_id=sub_id, on=on, affinity=c.affinity, open_roles=counts.get(c.key, 0), ats=c.ats, ats_slug=c.ats_slug, careers_url=c.careers_url, - country=c.country, + country=c.country, city=c.city, domain=c.domain, + watch=c.watch, careers_opened_at=c.careers_opened_at, failing_since=since, failing_reason=reason, from_search=not (c.key in ever_boarded or c.ats or c.careers_url or c.domain))) @@ -459,6 +465,50 @@ def set_affinity(key: str, body: AffinityBody, store: StoreDep, return AffinityOut(**company.model_dump(), score_job=job.id if job else None) +class WatchBody(BaseModel): + #: True on the Watchlist's list, False not on it, None clears the rating. + watch: bool | None + + +@router.post("/companies/{key}/watch") +def set_watch(key: str, body: WatchBody, store: StoreDep) -> Company: + """Rate a company for the Watchlist: 1 worth checking by hand, 0 not, + null back to unrated. Global, and apart from affinity. 404 for an + unknown key.""" + watch = None if body.watch is None else int(body.watch) + try: + return store.update_company(key, watch=watch) + except KeyError: + raise HTTPException(404, f"no such company: {key}") from None + + +class CareersBody(BaseModel): + careers_url: str + + +@router.post("/companies/{key}/careers") +def set_careers_url(key: str, body: CareersBody, store: StoreDep) -> Company: + """Set or correct where a company's careers page is; "" clears it. 422 + for anything but an http(s) URL, 404 for an unknown key.""" + url = body.careers_url.strip() + if url and not url.lower().startswith(("http://", "https://")): + raise HTTPException(422, "careers_url must start with http:// or https://") + try: + return store.update_company(key, careers_url=url) + except KeyError: + raise HTTPException(404, f"no such company: {key}") from None + + +@router.post("/companies/{key}/opened") +def mark_careers_opened(key: str, store: StoreDep) -> Company: + """Stamp that the company's careers page was just opened from the + Watchlist. 404 for an unknown key.""" + try: + return store.update_company(key, careers_opened_at=store.now()) + except KeyError: + raise HTTPException(404, f"no such company: {key}") from None + + # ----------------------------------------------------------------- sources class SourceOut(BaseModel): diff --git a/app/web/pages.py b/app/web/pages.py index f586ebf..476a18a 100644 --- a/app/web/pages.py +++ b/app/web/pages.py @@ -1,6 +1,6 @@ -"""The pages: two tabs, a cog, and three settings pages behind it. +"""The pages: three tabs, a cog, and three settings pages behind it. -`TABS` is the top bar, Roles and Applications, and `SETTINGS` is the rail +`TABS` is the top bar, Roles, Applications and Watchlist, and `SETTINGS` is the rail beside every page under the cog at `/settings/`: Search agents, Sources, Account. `base.html` renders the first, `settings/_rail.html` the second, every page marks itself active by its own `path`, and adding one is @@ -68,6 +68,7 @@ class Tab: TABS: tuple[Tab, ...] = ( Tab("/", "Roles", "roles.html"), Tab("/applications", "Applications", "applications.html"), + Tab("/watchlist", "Watchlist", "watchlist.html"), ) #: The pages under the cog, in order; `settings/_rail.html` renders them. @@ -155,6 +156,11 @@ def applications(request: Request) -> HTMLResponse: return page(request, "applications.html", status_options=STATUS_OPTIONS) +@router.get("/watchlist", response_class=HTMLResponse) +def watchlist(request: Request) -> HTMLResponse: + return page(request, "watchlist.html") + + @router.get("/settings", response_class=RedirectResponse) def settings() -> RedirectResponse: return RedirectResponse(SETTINGS[0].path, status_code=302) diff --git a/tests/test_pages.py b/tests/test_pages.py index 73645d3..d0b6a6e 100644 --- a/tests/test_pages.py +++ b/tests/test_pages.py @@ -85,6 +85,17 @@ def test_a_role_address_is_the_same_page_with_its_reader_open( assert missing.status_code == 404 and "text/html" in missing.headers["content-type"] +def test_the_watchlist_is_the_third_tab_and_a_shell(client: TestClient) -> None: + page = client.get("/watchlist") + assert page.status_code == 200 + assert 'href="/watchlist"\n class="active" aria-current="page">Watchlist' in page.text + assert 'id="watchlist-list"' in page.text and "/static/watchlist.js" in page.text + nav = page.text[page.text.index("")] + tabs = [t for t in ("Roles", "Applications", "Watchlist") if f">{t}" in nav] + assert tabs == ["Roles", "Applications", "Watchlist"] + assert nav.count('aria-current="page"') == 1 + + def test_the_read_page_of_its_own_is_gone(client: TestClient) -> None: assert client.get("/static/role.js").status_code == 404 other = client.get("/applications").text diff --git a/tests/test_storage.py b/tests/test_storage.py index 210fb36..2da1a9d 100644 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -69,7 +69,7 @@ def test_schema_creates_on_an_empty_file(tmp_path: Path) -> None: "application_events", "agents", "scores", "state"} <= tables assert "idx_roles_cluster" in indexes assert store.migrations_applied == [] - assert LATEST == 14 + assert LATEST == 15 # A second open finds it current and applies nothing. assert Store(path).migrations_applied == [] @@ -88,10 +88,19 @@ def _columns(path: Path, table: str) -> list[tuple[str, str, int, str]]: return [(r[1], r[2], r[3], r[4]) for r in conn.execute(f"PRAGMA table_info({table})")] +def _undo_v15(conn: sqlite3.Connection) -> None: + """A fresh file put back to the v14 shape: no Watchlist columns on a + company.""" + conn.execute("ALTER TABLE companies DROP COLUMN watch") + conn.execute("ALTER TABLE companies DROP COLUMN careers_opened_at") + + def _undo_v14(conn: sqlite3.Connection) -> None: """A fresh file put back to the v13 shape: an agent's intent and its cached vector on the agent row, no prompts, no prompt on a score. Every - downgrade below starts here, since v14 is the last migration.""" + downgrade below starts here, after `_undo_v15`, since v15 is the last + migration.""" + _undo_v15(conn) conn.execute("DROP TABLE agent_prompts") conn.execute("ALTER TABLE scores DROP COLUMN prompt") conn.execute("ALTER TABLE agents ADD COLUMN intent TEXT NOT NULL DEFAULT ''") @@ -127,6 +136,23 @@ def test_a_v1_file_migrates_to_the_shape_a_new_file_has(tmp_path: Path) -> None: assert sorted(_columns(old, table)) == sorted(_columns(fresh, table)) +def test_a_v14_file_gains_the_watchlist_columns_and_leaves_companies_unrated( + tmp_path: Path) -> None: + path = tmp_path / "v14.db" + Store(path).add_company("Acme", ats="teamtailor", country="DK", careers_url="https://a.example") + with sqlite3.connect(path) as conn: + _undo_v15(conn) + conn.execute("PRAGMA user_version = 14") + + migrated = Store(path) + + assert migrated.migrations_applied == [15] + acme = migrated.company("acme") + assert acme is not None + assert (acme.ats, acme.careers_url) == ("teamtailor", "https://a.example") + assert (acme.watch, acme.careers_opened_at) == (None, "") + + def test_a_v8_file_gains_ats_slug_and_keeps_its_companies(tmp_path: Path) -> None: path = tmp_path / "v8.db" Store(path).add_company("Acme", ats="teamtailor", country="DK") @@ -325,7 +351,7 @@ def test_v14_makes_each_intent_the_agents_one_prompt_with_its_vector(tmp_path: P migrated = Store(path) - assert migrated.migrations_applied == [14] + assert migrated.migrations_applied == [14, 15] assert migrated.agent(backend.id).prompts == [ # type: ignore[union-attr] Prompt(name="Backend", text="python backend")] assert migrated.agent(blank.id).prompts == [] # type: ignore[union-attr] diff --git a/tests/test_web.py b/tests/test_web.py index 975b72a..f1363ec 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -430,7 +430,8 @@ def test_companies_lists_board_and_open_role_count( assert row == {"key": "acme", "name": "Acme", "board": "greenhouse", "subscription_id": sub.id, "on": True, "affinity": 0, "open_roles": 1, "ats": "greenhouse", "ats_slug": "", "careers_url": "", - "country": "DK", "failing_since": "", "failing_reason": "", + "country": "DK", "city": "", "domain": "", "watch": None, + "careers_opened_at": "", "failing_since": "", "failing_reason": "", "from_search": False} [other] = [c for c in res.json() if c["key"] == "other"] assert (other["board"], other["subscription_id"], other["on"], other["ats"]) == ( @@ -552,6 +553,53 @@ def test_post_score_answers_with_the_job_to_wait_for(client: TestClient, queue: assert queue.jobs.get(res.json()["id"]).kind == "score" +# ------------------------------------------------------------- watchlist + +def test_the_watchlist_rating_is_global_and_leaves_affinity_alone( + client: TestClient, store: Store) -> None: + store.add_company("Acme", ats="workday") + agent = store.save_agent("A") + store.set_affinity(agent.id, "acme", 1) + + for watch, stored in ((True, 1), (False, 0), (None, None)): + res = client.post("/api/companies/acme/watch", json={"watch": watch}) + assert res.status_code == 200 and res.json()["watch"] == stored + listed = client.get("/api/companies").json()[0] + assert (listed["watch"], listed["affinity"]) == (stored, 1) + + +def test_the_careers_page_is_set_cleared_and_must_be_a_web_address( + client: TestClient, store: Store) -> None: + store.add_company("Acme") + + res = client.post("/api/companies/acme/careers", json={"careers_url": "https://a.example/jobs"}) + assert res.status_code == 200 and res.json()["careers_url"] == "https://a.example/jobs" + for bad in ("javascript:alert(1)", "a.example/jobs", "ftp://a.example"): + assert client.post("/api/companies/acme/careers", + json={"careers_url": bad}).status_code == 422 + assert store.company("acme").careers_url == "https://a.example/jobs" + cleared = client.post("/api/companies/acme/careers", json={"careers_url": ""}) + assert cleared.status_code == 200 and store.company("acme").careers_url == "" + + +def test_opening_the_careers_page_stamps_the_time(client: TestClient, store: Store) -> None: + store.add_company("Acme") + assert client.get("/api/companies").json()[0]["careers_opened_at"] == "" + + res = client.post("/api/companies/acme/opened") + + assert res.status_code == 200 + assert res.json()["careers_opened_at"] == store.company("acme").careers_opened_at != "" + assert client.get("/api/companies").json()[0]["careers_opened_at"] != "" + + +def test_the_watchlist_endpoints_404_for_an_unknown_company(client: TestClient) -> None: + assert client.post("/api/companies/nope/watch", json={"watch": True}).status_code == 404 + assert client.post("/api/companies/nope/careers", + json={"careers_url": "https://a.example"}).status_code == 404 + assert client.post("/api/companies/nope/opened").status_code == 404 + + # ----------------------------------------------------------- applications def test_save_creates_an_application_with_a_saved_event( @@ -629,7 +677,7 @@ def test_the_applications_page_has_no_next_column(client: TestClient) -> None: # -------------------------------------------------------------------- tabs def test_every_page_renders_with_the_whole_nav(client: TestClient) -> None: - assert [t.label for t in TABS] == ["Roles", "Applications"] + assert [t.label for t in TABS] == ["Roles", "Applications", "Watchlist"] assert [t.label for t in SETTINGS] == ["Search agents", "Sources", "Account"] assert all(t.path.startswith("/settings/") for t in SETTINGS) for tab in (*TABS, *SETTINGS): From 51d2537d733ed23018291f0336a4919f2c7d2e52 Mon Sep 17 00:00:00 2001 From: Wolf Date: Tue, 29 Sep 2026 16:58:51 +0200 Subject: [PATCH 4/5] Search roles by company too, link the careers page in the reader, widen the list and reader Co-Authored-By: Claude Opus 5.5 --- app/static/app.css | 11 ++++++----- app/static/roles.js | 3 +++ app/storage/store.py | 13 +++++++------ app/templates/roles.html | 2 +- tests/test_storage.py | 3 +++ 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/app/static/app.css b/app/static/app.css index 49ebaeb..144a20e 100644 --- a/app/static/app.css +++ b/app/static/app.css @@ -477,11 +477,11 @@ body[data-rail="shut"] #rail { display: none; } /* Reading opens a third column and the shell goes full width: the list keeps a narrow lane on the left, the role takes the rest. */ body[data-reader="open"] .shell { - grid-template-columns: 15rem 21rem minmax(0, 1fr); + grid-template-columns: 15rem 29rem minmax(0, 1fr); max-width: none; gap: 1.2rem; } body[data-reader="open"][data-rail="shut"] .shell { - grid-template-columns: 21rem minmax(0, 1fr); + grid-template-columns: 29rem minmax(0, 1fr); } /* -- the rail -- */ @@ -842,12 +842,13 @@ tr.muted { opacity: .55; } padding: 1.6rem 2rem 4rem; overflow-wrap: anywhere; } -/* ~68 characters a line at the reading size -- past that the eye loses the - start of the next line and has to hunt for it. */ -.reader-body > * { max-width: 36rem; margin-inline: auto; } +/* ~90 characters a line at the reading size: newsdesk's 36rem wrapped a + posting's short lines and lists too early. */ +.reader-body > * { max-width: 48rem; margin-inline: auto; } .reader-meta { margin-top: 0; } .reader-meta b { font-weight: 600; color: var(--dim); } +.reader-meta .reader-careers { color: var(--dim); } .reader-meta .affinity { font-size: .85rem; } .reader-meta .affinity:empty { display: none; } diff --git a/app/static/roles.js b/app/static/roles.js index 34a16b8..4cb3b05 100644 --- a/app/static/roles.js +++ b/app/static/roles.js @@ -798,6 +798,7 @@ : text ? paragraphs(text) : `

The board gave no description for this one.

`; const pay = payDisplay(r); + const careers = safeUrl(companies.get(r.company_key)?.careers_url); const waiting = state.summarising === state.readingUid; const teaser = loaded && !r.article_text && out && (r.description || "").length < TEASER; @@ -813,6 +814,8 @@
${r.company ? `${esc(r.company)}` : ""} + ${careers ? `Careers ↗` : ""} ${r.place ? `${esc(r.place)}` : ""} ${r.first_seen ? `${ago(r.first_seen)}` : ""} diff --git a/app/storage/store.py b/app/storage/store.py index 1f7d22d..6a5fc28 100644 --- a/app/storage/store.py +++ b/app/storage/store.py @@ -496,10 +496,11 @@ class Store: """Newest first by `posted_at`. `company` and `place` are case-insensitive substrings of the columns a board wrote — not the key, so a search does not have to know the exact slug a company folds - to. `q` is matched word by word against `title`; a role must match - every word. `function` and `remote` match a gate column exactly. - `days` keeps only roles posted within that many days of now. `pay` - (a key of `PAY`) filters on `salary_state`. + to. `q` is matched word by word against `title` and `company`; a + role must match every word in one or the other. `function` and + `remote` match a gate column exactly. `days` keeps only roles posted + within that many days of now. `pay` (a key of `PAY`) filters on + `salary_state`. `agent` says whose votes, hidden companies and scores are meant. Each row carries that agent's `vote` and `voted_at`; `judged` (a key of @@ -653,8 +654,8 @@ class Store: where.append("posted_at >= ?") params.append(_iso(self.clock() - timedelta(days=days))) for word in (q or "").split(): - where.append("title LIKE ? ESCAPE '\\'") - params.append(_like(word)) + where.append("(title LIKE ? ESCAPE '\\' OR company LIKE ? ESCAPE '\\')") + params += [_like(word)] * 2 if judged: if judged not in JUDGED: raise ValueError(f"judged is {', '.join(JUDGED)}, not {judged!r}") diff --git a/app/templates/roles.html b/app/templates/roles.html index 44a67d7..cd1e6dd 100644 --- a/app/templates/roles.html +++ b/app/templates/roles.html @@ -28,7 +28,7 @@ - {% endblock %} diff --git a/tests/test_storage.py b/tests/test_storage.py index 210fb36..7b7b196 100644 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -668,6 +668,9 @@ def test_roles_filters_q_function_remote_and_days(store: Store, clock: Clock) -> function="sales")) assert [r.source_id for r in store.roles(q="senior engineer")] == ["2", "1"] assert [r.source_id for r in store.roles(q="backend nonsense")] == [] + # A word may match the company instead of the title, each on its own. + assert [r.source_id for r in store.roles(q="acme engineer")] == ["2", "1"] + assert [r.source_id for r in store.roles(q="acme nonsense")] == [] assert [r.source_id for r in store.roles(function="engineering")] == ["1"] assert [r.source_id for r in store.roles(remote="remote")] == ["1"] assert [r.source_id for r in store.roles(company="ac")] == ["2", "1"] From d98ec0feb29c12d863ceedf9828ec67332556495 Mon Sep 17 00:00:00 2001 From: Wolf Date: Tue, 29 Sep 2026 16:59:01 +0200 Subject: [PATCH 5/5] Fit three tabs in the phone top bar Co-Authored-By: Claude Sonnet 5.5 --- app/static/app.css | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/static/app.css b/app/static/app.css index 49ebaeb..82569c1 100644 --- a/app/static/app.css +++ b/app/static/app.css @@ -1339,3 +1339,18 @@ table.list select { padding: .25rem .4rem; } .affinity button { min-width: 2.75rem; } .check input { width: 1.25rem; height: 1.25rem; } } + +/* Three tabs and the cog, at 390px: the phone block's padding and size leave + the bar 37px too wide, and a nowrap bar that is too wide scrolls the whole + page sideways. Tighter tabs, still touch-high (see the coarse block). */ +@media (max-width: 640px) { + .top { gap: .4rem; } + .top nav a { padding-inline: .25rem; font-size: .9rem; } + .top nav a.icon { padding-inline: .55rem; } +} +/* On Roles the search field is what gives way, not the tabs: the nav keeps + the width its tabs need and the field takes what is left. */ +@media (max-width: 640px) { + .top:has(#search) nav { flex: 0 0 auto; } + .top:has(#search) nav a:not(.icon) { padding-inline: .2rem; } +}