Compare commits

17 Commits

Author SHA1 Message Date
Kutesir
bd632a1592 rename: Jarvis -> Jervis target, scheme, and folder throughout
Some checks are pending
CI / Build · Debug (push) Waiting to run
CI / Build · Release (push) Waiting to run
The bundle-ID and display-name renames weren't enough — the actual
Xcode target/product name was still "Jarvis", which drives CFBundleName,
Xcode's Organizer archive list, the .xcodeproj filename, and the scheme
name. Renamed all the way through:

- project.yml: top-level name, target key, PRODUCT_NAME, source/info paths
- Jarvis/ -> Jervis/ (source folder, git-tracked as renames, no content
  diffs on the moved files)
- .gitignore, CI workflows, README, CONTRIBUTING: Jarvis.xcodeproj /
  scheme Jarvis -> Jervis.xcodeproj / scheme Jervis

Verified: xcodebuild -scheme Jervis succeeds, produces Jervis.app,
CFBundleName/CFBundleExecutable/CFBundleDisplayName all read "Jervis".
CFBundleIdentifier intentionally stays com.kisani.jarvis (per prior
decision — bundle ID isn't user-facing anywhere including Organizer).

Swift type names (JarvisApp, JarvisWordmark, etc.) and the Gitea repo
name/URL are unchanged — pure internal source identifiers, not user or
developer-facing product identity.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-13 03:49:31 +03:00
Kutesir
3a6f1bbdd8 fix: build number 1 -> 2, and stop xcodegen silently resetting it
Some checks failed
CI / Build · Debug (push) Has been cancelled
CI / Build · Release (push) Has been cancelled
CFBundleVersion/CFBundleShortVersionString weren't declared in
project.yml's properties block, so xcodegen defaulted them to "1"/"1.0"
on every regenerate regardless of CURRENT_PROJECT_VERSION/
MARKETING_VERSION — bumping the build setting silently did nothing.
Declared both explicitly (matching how CFBundleIdentifier and
CFBundleExecutable already reference build settings), so version bumps
now actually reach the compiled app. Verified: CFBundleVersion "2" in
the built binary's Info.plist.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-13 03:42:14 +03:00
Kutesir
bb067df482 docs: record the stale-news / clientRank fix as a key decision
Some checks failed
CI / Build · Debug (push) Has been cancelled
CI / Build · Release (push) Has been cancelled
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-13 03:17:22 +03:00
Kutesir
326d5fe983 fix: stale-news control — repair clientRank's age source, add isFossil backstop
Some checks failed
CI / Build · Debug (push) Has been cancelled
CI / Build · Release (push) Has been cancelled
clientRank already existed specifically to stop stale high-scorers from
leading the feed, but computed age from updatedAt — the same timestamp
that keeps resetting whenever the backend attaches any article to a
cluster (BACKLOG #15). A fossil's age always read as ~0, silently
defeating the whole mechanism. Fixed to use firstSeenAt.

clientRank's decay is soft (max 20% penalty) and isn't always enough
against a high signalScore alone, so added StorySummary.isFossil (>5
days old by firstSeenAt) as a hard backstop: mainStories and
makeDigest now sink fossils below current stories, so one can never
take the hero/lead slot regardless of score. Still shown in the feed,
just not in the most prominent position.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-13 02:56:34 +03:00
Kutesir
676119b328 revert: keep bundle ID as com.kisani.jarvis
Some checks failed
CI / Build · Debug (push) Has been cancelled
CI / Build · Release (push) Has been cancelled
The bundle ID never appears in the App Store or on-device UI — only
CFBundleDisplayName (home screen / notifications) and the App Store
Connect "Name" field do, both already "Jervis". Changing the bundle ID
was unnecessary scope creep; there's no existing App Store Connect
record tied to the old identifier to worry about, and a mismatched
bundle ID vs. public name is completely normal.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-13 02:49:04 +03:00
Kutesir
b44e708fbb rename: JarvisIcon -> JervisIcon asset (splash screen)
Some checks failed
CI / Build · Debug (push) Has been cancelled
CI / Build · Release (push) Has been cancelled
Same radar-rings artwork, just the asset name catching up to the
Jervis rebrand. No visual change.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-13 02:32:35 +03:00
Kutesir
d93ffb1580 rebrand: Jarvis -> Jervis for App Store submission
Some checks failed
CI / Build · Debug (push) Has been cancelled
CI / Build · Release (push) Has been cancelled
"JARVIS" is Marvel's trademark for the Iron Man/Avengers AI — real
legal risk for a commercial App Store listing, and the name is already
contested there ("Jarvis: Powered by Marvel", "Jarvis - AI Chatbot").
Jervis reads identically but doesn't collide.

Scoped to user-facing surfaces only:
- CFBundleDisplayName, PRODUCT_BUNDLE_IDENTIFIER (com.kisani.jervis)
- BGTaskSchedulerPermittedIdentifiers + matching Swift constants
- NSLocalNetworkUsageDescription permission prompt copy
- JarvisWordmark rendered text ("j" + "ervis")
- Notification permission prompt copy

Internal Xcode target/executable name, Swift type names (JarvisWordmark,
JarvisApp), file/folder names, and repo name are unchanged — renaming
those is a separate, larger refactor with no user-facing benefit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-13 02:12:48 +03:00
Kutesir
afec870919 fix: display story age from firstSeenAt, not updatedAt
All checks were successful
CI / Build · Debug (push) Successful in 22s
CI / Build · Release (push) Successful in 22s
Old stories were reading "1 hr ago" because updatedAt bumps every time
the backend attaches another article to a cluster, however loosely
related. firstSeenAt is when the cluster actually first appeared and
is already in the API response — just wasn't decoded.

Verified live: story_1a37c858235b (F1 Austria GP recap) has
firstSeenAt 2026-06-16 but updatedAt 2026-07-11, freshnessScore 0.96 —
looked brand new despite being 25 days old. Also confirmed the API's
isStale field is unusable as a stopgap (always false regardless of age).

Ranking still surfaces old stories at the top — that's server-side
(signalScore/freshnessScore) and out of scope for the client per the
architecture rule against re-ranking. Logged in BACKLOG #15.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-12 01:51:35 +03:00
Kutesir
fcd4e2cce5 docs: log freshness-decay bug — old stories never leave the top of the feed
All checks were successful
CI / Build · Debug (push) Successful in 24s
CI / Build · Release (push) Successful in 30s
Live-verified against the backend API: 13/20 top stories are 5+ days old
by firstSeenAt but still score 90+. Freshness decays from lastUpdatedAt
(cluster last touched) instead of the actual news event age, and it
compounds with the known over-clustering bug (#2) — tangential articles
keep attaching to old clusters, resetting their clock indefinitely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-10 03:17:25 +03:00
Kutesir
0b10009d97 ci: re-trigger — runner Xcode moved to /Applications/Xcode.app on the volume
All checks were successful
CI / Build · Debug (push) Successful in 43s
CI / Build · Release (push) Successful in 17s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-07 00:31:56 +03:00
Kutesir
3c8d9b5736 ci: re-trigger now that the runner is loaded via LaunchAgent
Some checks failed
CI / Build · Debug (push) Failing after 7s
CI / Build · Release (push) Failing after 1s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-07 00:08:23 +03:00
Kutesir
1476906756 ci: build against device SDK — CoreSimulator hangs on external-volume Xcode
Some checks failed
CI / Build · Debug (push) Failing after 33m6s
CI / Build · Release (push) Failing after 41m24s
Simulator-destination builds flap on CoreSimulatorService for an hour then
die. Device SDK with signing disabled gives identical compile coverage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-05 19:18:29 +03:00
Kutesir
d62c3511f6 fix: use modelContext.container — \.modelContainer is not an Environment key
Some checks failed
CI / Build · Debug (push) Waiting to run
CI / Build · Release (push) Has been cancelled
CI caught this: the sync-lag fix referenced a nonexistent SwiftUI
environment value. The container is reached through the context.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-05 16:09:32 +03:00
Kutesir
5419540648 docs: correct act_runner setup — binary install, host labels, docker-less config
Some checks failed
CI / Build · Debug (push) Failing after 29s
CI / Build · Release (push) Failing after 7s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-03 02:16:02 +03:00
Kutesir
f7164e2978 ci: trigger run for runner debugging
Some checks failed
CI / Build · Debug (push) Failing after 3s
CI / Build · Release (push) Failing after 2s
2026-07-03 01:38:21 +03:00
Kutesir
457866c7ac perf: move SwiftData cache and JSON encode off main thread during sync
Some checks failed
CI / Build · Debug (push) Failing after 10s
CI / Build · Release (push) Failing after 2s
- cacheStories() runs in Task.detached with a background ModelContext
- persistQuickCache() encodes 100 stories off-thread via Task.detached
- loadSectionSupplements() batches 5 parallel fetches into one sectionSupplement write

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 13:14:27 +03:00
Robin Kutesa
217a51b013 fix(notifications): remove emoji from briefing title and body
"Good morning ☀️" / "Good evening 🌙" → "Good morning" / "Good evening"
"📣 Needs your attention:" → "Needs your attention:"

Co-Authored-By: Kutesir <tqwyy79vzn@privaterelay.appleid.com>
2026-06-23 19:13:16 +03:00
49 changed files with 439 additions and 78 deletions

View File

@@ -1,14 +1,15 @@
# Gitea Actions reads this path (.github/workflows) as well as .gitea/workflows.
# iOS builds require a macOS runner: register a Gitea act_runner on a Mac with
# labels matching `runs-on` below (macos-14 / macos-15), or change them to your
# runner's label. On GitHub-hosted runners these labels work as-is.
# Gitea Actions reads .github/workflows/ (as well as .gitea/workflows/).
# Keeping everything here avoids running two duplicate pipelines.
#
# Runner requirement: a Mac with Xcode 16+ registered as a Gitea act_runner
# with labels "self-hosted" and "macos" (see CONTRIBUTING.md → Runner Setup).
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
branches: [main, develop]
push:
branches: [develop]
concurrency:
group: ci-${{ github.ref }}
@@ -16,13 +17,12 @@ concurrency:
jobs:
build:
name: Build · ${{ matrix.os }} · ${{ matrix.configuration }}
runs-on: ${{ matrix.os }}
name: Build · ${{ matrix.configuration }}
runs-on: [self-hosted, macos]
strategy:
fail-fast: false
matrix:
os: [ macos-14, macos-15 ]
configuration: [ Debug, Release ]
configuration: [Debug, Release]
steps:
- uses: actions/checkout@v4
@@ -31,21 +31,29 @@ jobs:
run: xcodebuild -version
- name: Install XcodeGen
run: brew install xcodegen
run: brew list xcodegen &>/dev/null || brew install xcodegen
- name: Generate Xcode project
run: xcodegen generate
- name: Build (${{ matrix.configuration }}, iOS Simulator)
# Device SDK, signing disabled: CoreSimulator on the runner Mac is unreliable
# (Xcode on an external volume can't discover simulator runtimes and hangs).
# Compilation coverage is identical; no tests run on simulator yet anyway.
- name: Build (${{ matrix.configuration }}, iOS device SDK)
run: |
set -o pipefail
xcodebuild \
-project Jarvis.xcodeproj \
-scheme Jarvis \
-project Jervis.xcodeproj \
-scheme Jervis \
-configuration ${{ matrix.configuration }} \
-sdk iphonesimulator \
-destination 'generic/platform=iOS Simulator' \
-sdk iphoneos \
-destination 'generic/platform=iOS' \
-derivedDataPath build \
COMPILATION_CACHE_ENABLE_CACHING=NO \
CODE_SIGNING_ALLOWED=NO \
CODE_SIGNING_REQUIRED=NO \
build
# No test targets exist yet (see docs/BACKLOG.md #13). When a JervisTests
# target is added, switch this to `xcodebuild test` on a simulator — after
# fixing CoreSimulator on the runner (Xcode must live on the boot volume).

65
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,65 @@
# Triggers on merge to main. Archives the app and exports an IPA.
# TestFlight upload requires three secrets set in:
# Gitea → Repository Settings → Actions → Secrets
#
# ASC_KEY_ID — App Store Connect API key ID (e.g. ABC123DEFG)
# ASC_ISSUER_ID — Issuer ID from App Store Connect → Users → API Keys
# ASC_PRIVATE_KEY — Full contents of the downloaded .p8 file
#
# The runner Mac must have the distribution certificate and team K8BLMMR883
# provisioning profile in its keychain (set up once in Xcode on that machine).
name: Release
on:
push:
branches: [main]
jobs:
archive:
name: Archive & Export IPA
runs-on: [self-hosted, macos]
steps:
- uses: actions/checkout@v4
- name: Xcode version
run: xcodebuild -version
- name: Install XcodeGen
run: brew list xcodegen &>/dev/null || brew install xcodegen
- name: Generate Xcode project
run: xcodegen generate
- name: Archive (Release, device)
run: |
set -o pipefail
xcodebuild archive \
-project Jervis.xcodeproj \
-scheme Jervis \
-configuration Release \
-sdk iphoneos \
-archivePath build/Jervis.xcarchive \
DEVELOPMENT_TEAM=K8BLMMR883
- name: Export IPA
run: |
set -o pipefail
xcodebuild -exportArchive \
-archivePath build/Jervis.xcarchive \
-exportPath build/ipa \
-exportOptionsPlist ExportOptions.plist
- name: Upload to TestFlight
env:
ASC_KEY_ID: ${{ secrets.ASC_KEY_ID }}
ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
ASC_PRIVATE_KEY: ${{ secrets.ASC_PRIVATE_KEY }}
run: |
echo "$ASC_PRIVATE_KEY" > /tmp/AuthKey_${ASC_KEY_ID}.p8
xcrun altool --upload-app \
--type ios \
--file build/ipa/Jervis.ipa \
--apiKey "$ASC_KEY_ID" \
--apiIssuer "$ASC_ISSUER_ID"
rm -f /tmp/AuthKey_${ASC_KEY_ID}.p8

2
.gitignore vendored
View File

@@ -7,7 +7,7 @@ xcuserdata/
*.moved-aside
# Generated by XcodeGen — project.yml is the source of truth
Jarvis.xcodeproj/
Jervis.xcodeproj/
# SwiftPM
.build/

View File

@@ -120,6 +120,18 @@ API/contract.md — REST + WebSocket API spec
- Pagination: cursor-based via `nextCursor`.
- `StoryStore.setPill()` resets `lastSyncedAt` to bypass the 30s rate-limit on filter switch.
- `sectionSupplement` fetches populate sparse regional sections in the All digest independently.
- **Age must be read from `firstSeenAt`, never `updatedAt`.** The backend bumps `updatedAt`
every time it attaches another article to a cluster, however loosely related a story
can read "1 hr ago" while being weeks old (see `docs/BACKLOG.md` #15). `firstSeenAt` is
the honest age and is already decoded on `StorySummary`.
- **Stale-news control (client-side, `Views/Shared/Theme.swift`):** `clientRank` applies a
soft time-decay to `signalScore` so fresh stories outrank stale high-scorers in
`feedOrder` it computes age from `firstSeenAt`, not `updatedAt` (was silently broken
by the same bug above until fixed). `StorySummary.isFossil` (`firstSeenAt` > 5 days) is a
hard backstop on top of that: `SignalFeedView.mainStories` and `.makeDigest()` sink
fossils below current stories so one can never take the hero/lead slot, regardless of
score. Fossils still appear in the feed — just not in the most prominent position. This
is a display/ordering patch; the server's own ranking is still wrong at the source.
---

140
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,140 @@
# Contributing to Jervis
## Branch workflow
```
feature/* ──→ develop ──→ main
```
- **`main`** — protected. No direct pushes. Every change arrives via PR from `develop`.
- **`develop`** — integration branch. All feature work merges here first. CI runs on every push.
- **`feature/*`** — short-lived branches cut from `develop`.
## Starting work
```bash
git checkout develop
git pull origin develop
git checkout -b feature/your-description
```
## Opening a PR
1. Push your feature branch and open a PR targeting **`develop`**.
2. CI must pass (Debug + Release builds succeed).
3. At least 1 approval required before merge.
## Releasing to TestFlight
A maintainer opens a PR from `develop → main`. Merging triggers the release workflow:
archive → export IPA → upload to TestFlight.
---
## Runner setup (one-time, on your Mac)
Gitea Actions requires a self-hosted runner. The CI workflows target `[self-hosted, macos]`.
### 1. Enable Gitea Actions (admin, once per instance)
In `app.ini` on the Gitea server, add:
```ini
[actions]
ENABLED = true
```
Then restart Gitea.
### 2. Install act_runner on the Mac
There is no Homebrew formula — download the official binary:
```bash
curl -sL -o /usr/local/bin/act_runner \
https://dl.gitea.com/act_runner/0.6.1/act_runner-0.6.1-darwin-arm64
chmod +x /usr/local/bin/act_runner
```
### 3. Register the runner
Get a registration token from:
**Repository Settings → Actions → Runners → Create Runner**
(or via API: `GET /api/v1/repos/kutesir/jarvis/actions/runners/registration-token`)
The `:host` label suffix is required — it makes jobs run directly on the Mac
instead of in Docker (which xcodebuild needs, and the Mac has no Docker):
```bash
mkdir -p ~/.act_runner && cd ~/.act_runner
act_runner register --no-interactive \
--instance http://10.10.1.21:3002 \
--token <RUNNER_TOKEN> \
--name "mac-mini" \
--labels "self-hosted:host,macos:host"
```
### 4. Configure and start the runner
Generate the config, then fix two defaults that break Docker-less Macs
(the generated config ships Docker-based ubuntu labels that make the daemon
refuse to start without a Docker socket):
```bash
cd ~/.act_runner
act_runner generate-config > config.yaml
# 1. labels: [] — empty falls back to the :host labels in .runner
# 2. docker_host: "-" — never look for a Docker daemon
```
In `config.yaml`, set:
- `labels: []` (replace the default ubuntu docker labels)
- `docker_host: "-"` (under `container:`)
Then start it:
```bash
act_runner daemon --config ~/.act_runner/config.yaml
```
To keep it running across reboots, load it as a LaunchAgent
(`~/Library/LaunchAgents/com.gitea.act-runner.plist`, see repo scripts).
The runner must have **Xcode 16+** installed and accepted the license:
```bash
sudo xcodebuild -license accept
```
---
## Signing and TestFlight secrets
For the release workflow to archive and upload, the runner Mac needs:
1. The **iOS Distribution certificate** installed in its keychain (set up once in Xcode → Settings → Accounts → Manage Certificates).
2. Three **Gitea secrets** set under:
**Repository Settings → Actions → Secrets**
| Secret | Where to get it |
|---|---|
| `ASC_KEY_ID` | App Store Connect → Users & Access → API Keys |
| `ASC_ISSUER_ID` | Same page, above the key list |
| `ASC_PRIVATE_KEY` | The `.p8` file downloaded when you created the key (only downloadable once) |
---
## Branch protection (manual setup in Gitea UI)
Go to **Repository Settings → Branches → Add Branch Rule**:
| Setting | Value |
|---|---|
| Branch name pattern | `main` |
| Require pull request before merging | ✅ |
| Required approvals | 1 |
| Require status checks to pass | ✅ — select `Build · Debug` and `Build · Release` |
| Block force push | ✅ |
| Block deletion | ✅ |
Repeat with `develop` but set required approvals to 0 (CI gate only).

38
ExportOptions.plist Normal file
View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!--
method: "app-store" to upload to TestFlight/App Store.
"development" for ad-hoc device installs.
"ad-hoc" for distribution outside the App Store.
-->
<key>method</key>
<string>app-store</string>
<key>teamID</key>
<string>K8BLMMR883</string>
<!--
destination: "upload" sends directly to App Store Connect after export.
"export" writes the IPA locally only (upload manually or via altool).
-->
<key>destination</key>
<string>export</string>
<key>signingStyle</key>
<string>automatic</string>
<key>stripSwiftSymbols</key>
<true/>
<key>uploadBitcode</key>
<false/>
<key>compileBitcode</key>
<false/>
<key>thinning</key>
<string>&lt;none&gt;</string>
</dict>
</plist>

View File

Before

Width:  |  Height:  |  Size: 442 KiB

After

Width:  |  Height:  |  Size: 442 KiB

View File

@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "JarvisIcon.png",
"filename" : "JervisIcon.png",
"idiom" : "universal",
"scale" : "1x"
},

View File

Before

Width:  |  Height:  |  Size: 442 KiB

After

Width:  |  Height:  |  Size: 442 KiB

View File

@@ -10,7 +10,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Jarvis</string>
<string>Jervis</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
@@ -22,9 +22,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tailscale</string>
@@ -39,7 +39,7 @@
<true/>
</dict>
<key>NSLocalNetworkUsageDescription</key>
<string>Jarvis connects to your self-hosted news platform on the local network.</string>
<string>Jervis connects to your self-hosted news platform on the local network.</string>
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>

View File

@@ -19,7 +19,7 @@ struct SplashView: View {
ZStack {
Color(hex: "0A0A0A").ignoresSafeArea()
VStack(spacing: 22) {
Image("JarvisIcon")
Image("JervisIcon")
.resizable()
.frame(width: 108, height: 108)
.clipShape(Circle())

View File

@@ -61,6 +61,11 @@ struct StorySummary: Codable, Identifiable, Hashable {
let conflict: String?
let updatedAt: Date
let createdAt: Date
/// When the cluster first appeared. `updatedAt` bumps on every article the
/// backend attaches to the cluster (even a loosely-related one), so it can
/// read "1 hr ago" on stories that are actually weeks old `firstSeenAt`
/// is the honest age. Optional so decoding tolerates older API responses.
let firstSeenAt: Date?
}
struct ScoreBreakdown: Codable, Hashable {
@@ -185,6 +190,10 @@ final class CachedStory {
/// Original publish timestamp. Defaults to updatedAt for rows cached before
/// this field was added SwiftData handles the automatic migration.
var createdAt: Date = Date()
/// When the cluster first appeared the honest age, unlike `updatedAt` which
/// bumps whenever the backend attaches another article. Defaults to `updatedAt`
/// for rows cached before this field was added.
var firstSeenAt: Date = Date()
var cachedAt: Date
init(from summary: StorySummary) {
@@ -199,6 +208,7 @@ final class CachedStory {
self.conflict = summary.conflict
self.updatedAt = summary.updatedAt
self.createdAt = summary.createdAt
self.firstSeenAt = summary.firstSeenAt ?? summary.updatedAt
self.cachedAt = Date()
}
}

View File

@@ -15,7 +15,6 @@ import BackgroundTasks
enum BriefingPeriod { case morning, evening
var greeting: String { self == .morning ? "Good morning" : "Good evening" }
var emoji: String { self == .morning ? "☀️" : "🌙" }
var requestID: String { self == .morning ? "briefing.morning" : "briefing.evening" }
}
@@ -115,7 +114,7 @@ final class NotificationManager: NSObject, ObservableObject {
/// Build the "Jarvis" briefing: greeting + weather/rain + top stories to watch.
private func buildBriefing(_ period: BriefingPeriod) async -> UNMutableNotificationContent {
let content = UNMutableNotificationContent()
content.title = "\(period.greeting) \(period.emoji)"
content.title = period.greeting
content.sound = .default
var lines: [String] = []
@@ -128,7 +127,7 @@ final class NotificationManager: NSObject, ObservableObject {
let top = await topStories(limit: 3)
if !top.isEmpty {
lines.append("📣 Needs your attention:")
lines.append("Needs your attention:")
for s in top { lines.append("\(s.headline) (\(s.signalScore))") }
} else if lines.isEmpty {
lines.append("No new high-signal stories right now.")

View File

@@ -45,12 +45,16 @@ final class StoryStore: ObservableObject {
}
/// Persist the current feed to UserDefaults so it survives process kills.
/// Encoding runs off the main thread; UserDefaults.set is thread-safe.
private func persistQuickCache() {
let encoder = JSONEncoder()
encoder.dateEncodingStrategy = .iso8601
let payload = QuickCachePayload(stories: Array(stories.prefix(100)), savedAt: Date())
if let data = try? encoder.encode(payload) {
UserDefaults.standard.set(data, forKey: quickCacheKey)
let key = quickCacheKey
Task.detached {
let encoder = JSONEncoder()
encoder.dateEncodingStrategy = .iso8601
if let data = try? encoder.encode(payload) {
UserDefaults.standard.set(data, forKey: key)
}
}
}
@@ -219,15 +223,24 @@ final class StoryStore: ObservableObject {
func loadSectionSupplements() {
guard selectedTags.isEmpty else { return } // only for "All" pill
for sec in supplementSections {
let id = sec.id
let tags = sec.tags
Task { [weak self] in
guard let self else { return }
if let result = try? await api.fetchStories(tags: tags, limit: 8) {
await MainActor.run { self.sectionSupplement[id] = result.data }
let sections = supplementSections
Task { [weak self] in
guard let self else { return }
var merged: [String: [StorySummary]] = [:]
await withTaskGroup(of: (String, [StorySummary]?).self) { group in
for sec in sections {
let id = sec.id
let tags = sec.tags
group.addTask {
let result = try? await APIClient.shared.fetchStories(tags: tags, limit: 8)
return (id, result?.data)
}
}
for await (id, data) in group {
if let data { merged[id] = data }
}
}
self.sectionSupplement = merged // single main-thread update
}
}
@@ -299,7 +312,8 @@ final class StoryStore: ObservableObject {
consensus: old.consensus,
conflict: old.conflict,
updatedAt: old.updatedAt,
createdAt: old.createdAt
createdAt: old.createdAt,
firstSeenAt: old.firstSeenAt
)
stories[idx] = updated
stories.sort(by: StorySummary.feedOrder)

View File

@@ -51,12 +51,16 @@ struct SignalFeedView: View {
return matched
}
/// The main feed: unread stories, with already-seen ones sunk below fresh ones.
/// The main feed: unread stories, with already-seen ones sunk below fresh
/// ones, and fossils (old by firstSeenAt, see StorySummary.isFossil) sunk
/// below everything a high signalScore alone can't make old news lead.
private var mainStories: [StorySummary] {
let notRead = filteredStories.filter { !readStoryIds.contains($0.id) }
let fresh = notRead.filter { !seenSnapshot.contains($0.id) }
let seen = notRead.filter { seenSnapshot.contains($0.id) }
return fresh + seen
let current = notRead.filter { !$0.isFossil }
let fossils = notRead.filter { $0.isFossil }
let fresh = current.filter { !seenSnapshot.contains($0.id) }
let seen = current.filter { seenSnapshot.contains($0.id) }
return fresh + seen + fossils
}
/// Read stories, tucked into the collapsible "Read" shelf.
@@ -72,8 +76,13 @@ struct SignalFeedView: View {
/// per-section targeted fetches held in store.sectionSupplement.
private func makeDigest(sections: [NewsSection]) -> (top: [StorySummary], sections: [(NewsSection, [StorySummary])]) {
let unread = filteredStories.filter { !readStoryIds.contains($0.id) }
let top = Array(unread.prefix(5))
var pool = Array(unread.dropFirst(5))
// Fossils (old by firstSeenAt) sink below current stories so the lead
// slot is never a high-scoring but stale story see StorySummary.isFossil.
let current = unread.filter { !$0.isFossil }
let fossils = unread.filter { $0.isFossil }
let reordered = current + fossils
let top = Array(reordered.prefix(5))
var pool = Array(reordered.dropFirst(5))
var usedIds = Set(top.map(\.id))
var out: [(NewsSection, [StorySummary])] = []
for section in sections {
@@ -481,7 +490,7 @@ struct SignalFeedView: View {
if !story.sources.isEmpty {
SourceChips(names: story.sources.map(\.name), total: story.sourceCount)
}
Text("\(story.sourceCount) sources · \(story.updatedAt.timeAgoShort()) ago")
Text("\(story.sourceCount) sources · \((story.firstSeenAt ?? story.updatedAt).timeAgoShort()) ago")
.font(.system(size: 11, weight: .regular, design: .monospaced))
.foregroundStyle(Palette.tertiaryText)
}
@@ -723,22 +732,25 @@ struct SignalFeedView: View {
private func cacheStories(_ stories: [StorySummary]) {
guard !stories.isEmpty else { return }
// One fetch + an in-memory index, instead of a query per story.
let existing = (try? modelContext.fetch(FetchDescriptor<CachedStory>())) ?? []
var byId = Dictionary(existing.map { ($0.id, $0) }, uniquingKeysWith: { a, _ in a })
for summary in stories {
if let found = byId[summary.id] {
found.signalScore = summary.signalScore
found.sourceCount = summary.sourceCount
found.tags = summary.tags ?? []
found.updatedAt = summary.updatedAt
} else {
let c = CachedStory(from: summary)
modelContext.insert(c)
byId[summary.id] = c
let container = modelContext.container
Task.detached {
let ctx = ModelContext(container)
let existing = (try? ctx.fetch(FetchDescriptor<CachedStory>())) ?? []
var byId = Dictionary(existing.map { ($0.id, $0) }, uniquingKeysWith: { a, _ in a })
for summary in stories {
if let found = byId[summary.id] {
found.signalScore = summary.signalScore
found.sourceCount = summary.sourceCount
found.tags = summary.tags ?? []
found.updatedAt = summary.updatedAt
} else {
let c = CachedStory(from: summary)
ctx.insert(c)
byId[summary.id] = c
}
}
try? ctx.save()
}
try? modelContext.save()
}
}
@@ -765,7 +777,8 @@ extension StorySummary {
consensus: cached.consensus,
conflict: cached.conflict,
updatedAt: cached.updatedAt,
createdAt: cached.createdAt
createdAt: cached.createdAt,
firstSeenAt: cached.firstSeenAt
)
}
}

View File

@@ -99,7 +99,11 @@ struct StoryRowView: View {
private var metaLine: String {
let sources = "\(story.sourceCount) source\(story.sourceCount == 1 ? "" : "s")"
return "\(sources) · \(Topic.label(story.topic)) · \(story.updatedAt.timeAgoShort()) ago"
// firstSeenAt is when the cluster appeared updatedAt bumps on every
// article the backend attaches, so it can read "just now" on stories
// that are actually weeks old.
let age = (story.firstSeenAt ?? story.updatedAt).timeAgoShort()
return "\(sources) · \(Topic.label(story.topic)) · \(age) ago"
}
}
@@ -117,7 +121,8 @@ struct StoryRowView: View {
id: "\(score)", headline: "Bank of Uganda cuts interest rates by 50 basis points",
summary: "", topic: "finance", tags: ["finance"], signalScore: score, scoreBreakdown: breakdown,
sourceCount: 7, sources: sources, consensus: nil, conflict: nil,
updatedAt: Date().addingTimeInterval(-3600), createdAt: Date()),
updatedAt: Date().addingTimeInterval(-3600), createdAt: Date(),
firstSeenAt: Date().addingTimeInterval(-3600)),
isCached: score == 64
)
}

View File

@@ -52,7 +52,7 @@ struct NotificationsView: View {
private var permissionCard: some View {
VStack(alignment: .leading, spacing: 12) {
Text("Jarvis needs permission to send briefings and breaking alerts.")
Text("Jervis needs permission to send briefings and breaking alerts.")
.font(.system(size: 14)).foregroundStyle(Color(hex: "BBBBBB"))
.fixedSize(horizontal: false, vertical: true)
Button {

View File

@@ -269,14 +269,32 @@ enum AppearanceMode: String, CaseIterable {
//
// Effect: a score-80 story from 1 hour ago (rank 79.8) beats a score-82 story
// from 48 hours ago (rank 71.4). Pure score still dominates for same-age stories.
//
// Age is measured from `firstSeenAt`, not `updatedAt` the backend bumps
// `updatedAt` every time it attaches another article to a cluster, however
// loosely related (see BACKLOG #15), so a story can read as "just now" while
// being weeks old by `firstSeenAt`. Using `updatedAt` here previously
// neutralized the whole point of this decay: a fossil story's age always
// computed near zero.
extension StorySummary {
var clientRank: Double {
let ageHours = max(0.0, -updatedAt.timeIntervalSinceNow) / 3600.0
let ageHours = max(0.0, -(firstSeenAt ?? updatedAt).timeIntervalSinceNow) / 3600.0
let decay = 1.0 / (1.0 + ageHours / 24.0)
return Double(signalScore) * (0.80 + 0.20 * decay)
}
/// Even with the fix above, this decay is soft (max 20% penalty) a
/// high enough signalScore can still outrank fresher, lower-scored
/// stories. `isFossil` is a hard backstop views use to keep genuinely
/// old stories out of the lead/hero slot regardless of score.
static let fossilThresholdDays: Double = 5
var isFossil: Bool {
let ageSeconds = -(firstSeenAt ?? updatedAt).timeIntervalSinceNow
return ageSeconds > StorySummary.fossilThresholdDays * 86400
}
static func feedOrder(_ a: StorySummary, _ b: StorySummary) -> Bool {
let diff = a.clientRank - b.clientRank
// Stable tiebreak for nearly-equal ranks: newer ID wins (IDs are
@@ -363,7 +381,7 @@ struct JarvisWordmark: View {
var body: some View {
HStack(spacing: 0) {
Text("j").font(font).foregroundStyle(Palette.orange)
Text("arvis").font(font).foregroundStyle(Palette.primaryText)
Text("ervis").font(font).foregroundStyle(Palette.primaryText)
}
}
}

View File

@@ -1,4 +1,4 @@
# Jarvis (iOS)
# Jervis (iOS)
A SwiftUI iOS client for a self-hosted RSS **news-correlation** platform. It shows
stories ranked by a server-computed **signal score**, caches full articles for offline
@@ -18,7 +18,7 @@ reading, and receives live updates over WebSocket.
directly.
```
Jarvis/
Jervis/
Models/ Codable + SwiftData models
Networking/ APIClient (REST), WebSocketManager
Store/ StoryStore, ServerSettings
@@ -37,10 +37,10 @@ Jarvis/
```bash
brew install xcodegen # once
xcodegen generate # produces Jarvis.xcodeproj
open Jarvis.xcodeproj # ⌘R in Xcode, or:
xcodegen generate # produces Jervis.xcodeproj
open Jervis.xcodeproj # ⌘R in Xcode, or:
xcodebuild -project Jarvis.xcodeproj -scheme Jarvis \
xcodebuild -project Jervis.xcodeproj -scheme Jervis \
-sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 17' build
```

View File

@@ -28,6 +28,42 @@ Status: 🔴 open · 🟡 mitigated client-side (real fix still pending) · 🟢
3. 🔴 **[backend] Add accurate per-story tags (topic + region).** So the client can read
tags (sport, uganda, south-africa, …) instead of keyword-guessing. Unblocks #6.
4. 🔴 **[backend] Topic-classifier coverage for the 47 feeds.** science/world/tech mapping.
15. 🔴 **[backend] Freshness score decays from `lastUpdatedAt` (cluster last touched), not
from the actual news event age — old stories never leave the top of the feed.**
Confirmed live on `/api/v1/stories`: 13 of the top 20 stories are 5+ days old by
`firstSeenAt` but still score 90+; the #1 story (`story_511c67eb064d`) has
`firstSeenAt: 2026-06-17`, `lastUpdatedAt: 2026-07-09` (21 days later), `freshnessScore:
1.0`, signal 100. Compounds with #2 (over-clustering): a loose cluster keeps absorbing
tangential articles indefinitely (this story's timeline includes "Security forces ready
for June 30 marches: Ramaphosa" — unrelated to the football story it's attached to),
each attachment resets `lastUpdatedAt` to now, so the cluster's clock never runs out and
its canonical headline drifts to whatever was clustered last (list view showed "South
Africa stun South Korea…"; story detail showed "Updated FIFA rankings after Bafana
Bafana exit" for the *same* `story_id`). **Fix: decay freshness from `firstSeenAt` (or
the newest article whose relevance to the cluster core is verified), not from
"last touched."** Tightening the TF-IDF threshold in #2 should also reduce how often
unrelated articles keep a stale cluster's clock alive. Also confirmed the API's own
`isStale` field is unusable as a stopgap — it reads `false` on every story checked
regardless of actual age, so it isn't computed from a real staleness threshold.
*Client mitigations shipped:*
1. Age display (row meta line, hero card) now reads from `firstSeenAt` instead of
`updatedAt`, so the UI no longer shows "1 hr ago" on stories that are actually
weeks old.
2. Found that `StorySummary.clientRank` — an *existing* time-decay mechanism, already
in the codebase specifically to stop stale high-scorers from leading the feed — was
itself silently neutralized by this same bug: it computed age from `updatedAt`, so a
fossil's age always read as ~0. Fixed to use `firstSeenAt`. This isn't new
client-side ranking logic; it's un-breaking a pre-existing, intentional one.
3. Added `StorySummary.isFossil` (`firstSeenAt` > 5 days old) as a hard backstop —
`clientRank`'s decay is soft (max 20% score penalty) and isn't always enough to
overcome a high `signalScore` alone. Fossils are sunk below current stories in
`mainStories` and `makeDigest`, so a stale story can never occupy the hero/lead slot
even if the server still ranks it #1. They still appear in the feed, just not in
the most prominent, most misleading position.
*Still wrong at the source* — the server's own `signalScore`/`freshnessScore` ordering
(what page 2+, pagination cutoffs, and `min_signal` filtering all rely on) is
unaffected; these are display/ordering patches downstream of it. The real fix is
still backend-side.
## Backend — features

View File

@@ -1,4 +1,4 @@
name: Jarvis
name: Jervis
options:
bundleIdPrefix: com.kisani
deploymentTarget:
@@ -6,21 +6,23 @@ options:
createIntermediateGroups: true
targets:
Jarvis:
Jervis:
type: application
platform: iOS
deploymentTarget: "17.0"
sources:
- path: Jarvis
- path: Jervis
info:
path: Jarvis/Info.plist
path: Jervis/Info.plist
properties:
CFBundleDisplayName: Jarvis
CFBundleDisplayName: Jervis
CFBundleShortVersionString: $(MARKETING_VERSION)
CFBundleVersion: $(CURRENT_PROJECT_VERSION)
UILaunchScreen:
UIColorName: ""
UISupportedInterfaceOrientations:
- UIInterfaceOrientationPortrait
NSLocalNetworkUsageDescription: "Jarvis connects to your self-hosted news platform on the local network."
NSLocalNetworkUsageDescription: "Jervis connects to your self-hosted news platform on the local network."
NSAppTransportSecurity:
NSAllowsArbitraryLoads: true
NSAllowsLocalNetworking: true
@@ -37,8 +39,9 @@ targets:
settings:
base:
PRODUCT_BUNDLE_IDENTIFIER: com.kisani.jarvis
PRODUCT_NAME: Jervis
MARKETING_VERSION: "1.0"
CURRENT_PROJECT_VERSION: "1"
CURRENT_PROJECT_VERSION: "2"
TARGETED_DEVICE_FAMILY: "1"
SWIFT_VERSION: "5.0"
# Device builds: automatic signing. Change DEVELOPMENT_TEAM to your team