oficina / equipo Public

Add Needs you Today groups and stable task completion time

Paul Campbell pushed by claude agent, operated by paul@keymail.dev 5f507fb93f99739b8dbfadc2fd8a04a48a56acf4 parent eb36731
25 files changed, +842 −57
  • .rastrillo/budgets.txt +2 −2
  • docs/api/equipo-v1.openapi.json +4 −0
  • docs/superpowers/plans/CONTROLLER-REPORT-native-needs-you.md +143 −0
  • internal/equipo/chat/task_done_at_test.go +102 −0
  • internal/equipo/chat/tasks.go +4 −0
  • internal/wire/tasks.go +2 −0
  • native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings +44 −0
  • native/apple/Sources/EquipoKit/API/Thin.swift +2 −0
  • native/apple/Sources/EquipoKit/Presentation/NeedsToday.swift +31 −0
  • native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings +44 −0
  • native/apple/Sources/EquipoKit/Session/EquipoSession.swift +2 −0
  • native/apple/Sources/EquipoKit/UI/NeedsViewFixture.swift +90 −0
  • native/apple/Sources/EquipoKit/UI/Screens/NeedsScreen.swift +47 −0
  • native/apple/Sources/EquipoKit/UI/Screens/PhoneRoot.swift +2 −2
  • native/apple/Sources/EquipoKit/UI/Screens/TaskScreens.swift +0 −43
  • native/apple/Sources/EquipoKit/UI/Screens/TodaySection.swift +55 −0
  • native/apple/Sources/EquipoMac/EquipoMacApp.swift +4 −3
  • native/apple/Sources/EquipoMac/MacMainView.swift +3 −3
  • native/apple/Sources/EquipoMac/MacNeedsFixture.swift +37 −0
  • native/apple/Tests/EquipoKitTests/NeedsTodayTests.swift +160 −0
  • native/ios/Sources/EquipoPhoneApp.swift +2 −1
  • native/ios/UITests/NeedsYouUITests.swift +35 −0
  • native/ios/project.yml +21 −1
  • native/scripts/check-parity.py +1 −1
  • native/scripts/strings.json +5 −1
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index f898bde0..3c8aabe1 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -15,7 +15,7 @@ time internal/equipo/team 60s Plan 3 loaded CI measured 45.985s; niced serial re
time internal/equipotest 300s Final fix package rerun measured 187.035s (review 172.4s); 300s gives 60 percent headroom for HTTP, sandbox, authority and final regression coverage.
size internal/equipo 22598 - Stuck tasks: the task page Retry on a failed preview and the coordinator's retried attempt on the timeline (2026-11-25); measured 22598 source lines.
-size internal/wire 7060 - Protocol 30: the runner's tool health, offer_retry and retry_step, a step's retried_by (2026-11-25); measured 7060 source lines.
+size internal/wire 7062 - Native Today adds optional done_at to the device task (2026-11-26); measured 7062 source lines, no runner protocol change.
size internal/equipotest - 12017 Task 21 repairs historical migration and conversation fixtures after Plan 3, and the Rastrillo upgrade contract comparing served assets with what Assets serves; measured 0/12017 source/test lines.
time internal/runner/checks 90s CI worker measured 44.553s (44.6s rounded);
time internal/runner 330s Plan 3 CI repair measured 292.120s for the full package (controller CI 472.184s).
@@ -56,7 +56,7 @@ perf GET /api/v1/tasks/{id} skip Thin v1 person API: bearer-only JSON for device
perf GET /api/v1/assistant/snapshot skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen.
perf GET /api/v1/assistant/messages skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen.
perf GET /api/v1/assistant/events skip Assistant event stream (Server-Sent Events), bearer-only and long-lived; not a screen.
-size internal/equipo/chat 34823 9539 Stopped work: step logs resolve the parent task read shape; missing task/project and revoked-member regressions (2026-11-25); measured 34823/9539.
+size internal/equipo/chat 34827 9641 Native Today adds stable DoneAt projection and completion/note/reopen regressions (2026-11-26); measured 34827/9641.
perf GET /api/v1/questions/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads questions on /tasks/{id}.
perf GET /api/v1/steps/{id}/log skip Thin v1 person API: bearer-only JSON for devices; the browser shows the log tail on /tasks/{id}.
perf GET /api/v1/connections/preference skip Connections slice 1 person API: bearer-only JSON for devices; the browser shows the preference on /conversation/connections.
diff --git a/docs/api/equipo-v1.openapi.json b/docs/api/equipo-v1.openapi.json
index 83cc183e..786beeed 100644
--- a/docs/api/equipo-v1.openapi.json
+++ b/docs/api/equipo-v1.openapi.json
@@ -22790,6 +22790,10 @@
"type": "string",
"format": "date-time"
},
+ "done_at": {
+ "type": "string",
+ "format": "date-time"
+ },
"candidate_sha": {
"type": "string"
},
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-native-needs-you.md b/docs/superpowers/plans/CONTROLLER-REPORT-native-needs-you.md
new file mode 100644
index 00000000..7461aed6
--- /dev/null
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-native-needs-you.md
@@ -0,0 +1,143 @@
+# Native Needs you and Today
+
+Branch: `native/needs-you`, created from `origin/main` at `eb367315` in an
+isolated worktree under the physical TMPDIR. Slice 3 is still in review;
+its action helpers will be reused after it lands and main is merged here.
+No merge to main, deployment or release is authorized.
+
+## Source rules and scope
+
+Needs you comes from `GET /needs-you`; it remains the badge source, including
+set-aside tasks. Today is separate from that count. The existing foreground
+event stream reconciles task and card events through session.refresh, which
+reads `/snapshot`, `/tasks`, and `/needs-you`. Pull to refresh uses that same
+path.
+
+The Today projection uses the existing `/tasks` response. Tasks with live
+running or queued steps and no pending decision appear under Running now.
+Done tasks whose stable `done_at` falls on the person's local calendar day
+appear under Finished today; cancelled and reopened tasks are excluded.
+Finished rows sort by done_at then id, newest first; active rows use updated_at.
+A later note cannot move a task's completion day. Older server payloads without
+done_at still decode, but are not assigned a guessed completion day.
+
+The controller approved optional `wire.Task.done_at` on 2026-11-26 after the
+store review showed that PostThread updates updated_at on completed tasks.
+The existing DoneAt is mapped to UTC, omitted when unset, and documented in
+the generated Task OpenAPI schema. Reopening retains the old DoneAt in the
+store; completing again replaces it, following existing transition semantics.
+No transition behavior, migration, route, or runner protocol changes.
+
+The server returns the newest 100 tasks by created_at, with no pagination.
+The controller accepted this existing web-list window for slice 4 on
+2026-11-26. Older active tasks or older tasks completed today can fall outside
+it. Follow-up: a bounded device query for active tasks or tasks finished
+since a supplied date. No server route is added in this slice.
+
+## Reviewed copy
+
+Approved by Luna through the controller, 2026-11-26:
+
+- `native.needs.running_now`: Running now. Today subsection heading.
+- `native.needs.finished_today`: Finished today. Today subsection heading.
+
+`chat.day.today` and `work.needs_empty` are copied byte-identical from the
+reviewed web catalog and covered by parity. Native catalog entries use the
+existing manual/translated convention; this report and source comments
+record the approval provenance.
+
+## Verification
+
+Test-first and mutation results will be recorded here as each guard is built.
+
+Initial list/Today commands:
+
+- `swift test --package-path native/apple --filter NeedsTodayTests`: with
+ empty projection/selector stubs, 4 tests failed with 5 assertion issues
+ (`needs-you-today-red.log`). Implementation then passed all four
+ (`needs-you-today-green.log`).
+- `swift test --package-path native/apple --filter NeedsInboxTests`: with
+ the badge returning nil, two tests failed with five assertion issues
+ (`needs-you-inbox-red.log`). Implementing the optional server inbox count
+ passed; the final focused run also covers task-event refresh.
+- `swift test --package-path native/apple --filter
+ 'NeedsTodayTests|NeedsInboxTests'`: 7 tests passed after source restoration
+ (`needs-you-list-restored.log`). The event test verifies a refresh updates
+ the badge and Today together. The 100-task test verifies the exact returned
+ IDs, no inferred older task, the existing `/tasks` route, and bearer use.
+
+The isolated mutation runner (`$TMPDIR/needs-you-mutate.py`) applied each
+change separately, ran the focused suites, required a failing assertion
+rather than a compile error, and restored the source in `finally`.
+All 16 mutations were killed:
+
+- Allow done or cancelled work into Running now (separate mutations).
+- Drop the pending-decision exclusion or live-step requirement.
+- Ignore running steps, ignore queued steps, or choose the first live step.
+- Include non-done tasks in Finished today or ignore the calendar day.
+- Use UTC instead of the person's time zone.
+- Reverse date order or the stable id tie-break.
+- Count all tasks for the badge; add one to the inbox count; turn unknown
+ into zero; omit set-aside tasks from the count.
+
+Approved copy is present in both generated catalogs. `check-parity.py`
+includes the two newly imported web keys and passes (223 strings at this
+pre-slice-3 stage).
+
+Action integration plan (waiting for slice 3): a row derives one action from
+its current task/card. Question opens the existing native card; Merge opens
+the shared confirmation; retry uses only the row's retry decision (not every
+retry option in the full task menu); Resume/Run now use the existing pause
+rules and connection revision. Other decisions open the task. Today offers
+Undo only through slice 3's receipt, creator, merge provenance and age guards,
+with its existing confirmation. No new action authority is inferred from a
+row appearing in a list.
+
+## Stable completion time verification
+
+- Before mapping the field, `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test
+ ./internal/equipo/chat -run '^TestTaskDoneAt' -count=1` failed with
+ `completed task has no done_at` (`needs-you-done-red.log`). The store test
+ exercises first completion, a note 48 hours later, reopening, and a second
+ completion through the existing saveTask transitions. A separate direct
+ projection test checks an offset timestamp is encoded with a UTC Z suffix.
+- Before changing Today, the focused Swift suites failed the regression
+ contrasting completion time with later notes (`needs-you-done-native-red.log`).
+ The native regression also decodes an older payload without done_at and a
+ payload with an explicit done_at field, and checks ordering uses completion.
+- The implementation passes both focused suites and
+ `go test ./internal/plan3test -run '^TestPersonAPIDeviceContract$' -count=1`.
+ OpenAPI Task was regenerated from wire schemas; only the optional date-time
+ property changed.
+- The list checkpoint native gate passed: 275 tests, string parity, both apps.
+ Final gates will be repeated after action integration.
+
+Completion-time mutations (each restored; Go command above or the focused
+Swift suites): all 15 killed by assertion failures. Remove the field mapping;
+map updated_at instead; omit UTC conversion; serialize an unset field; rewrite
+DoneAt for a later note; keep the first completion on a second completion;
+filter by activity day; sort by activity time; guess a missing completion from
+updated_at; drop the done stage; drop the local-day restriction; force UTC day
+boundaries; reverse completion ordering; reverse the id tie-break; ignore the
+native done_at field. The UTC mutation initially survived because SQLite
+normalizes loaded timestamps; the direct projection test now kills it. A
+malformed closure mutation was rejected as a compile failure and rerun with a
+valid closure; it then failed the intended calendar assertions.
+
+The existing package size exemptions increase by exactly the approved device
+field, its projection, and its regressions (wire +2 source lines; chat +4 source
+and +102 test lines). No new GET route or performance exemption is needed.
+
+## Paused for slice 3 review fixes
+
+Controller requested pausing slice 4 on 2026-11-26. All source mutations are
+restored. Completion-time native checkpoint passed 276 tests and both builds;
+the added running-order regression and its two mutations also passed (9 focused
+tests after restoration). Linux-targeted make build/vet, staticcheck v0.7.0,
+govulncheck v1.8.0, copy release, reference scan, lane check, fmt, spacing,
+gitleaks, and corrected size budgets passed. macOS build/vet/staticcheck/
+govulncheck hit the existing unix.O_PATH toolproxy compile failure. The full
+local make test run was interrupted on the controller's pause request; later
+Go targets in that loop have not run. No Linux hub verdict is claimed yet.
+The Mac fixture and slice 4 simulator were stopped. Slice 4 remains uncommitted
+in its own worktree, awaiting slice 3 integration and final validation.
diff --git a/internal/equipo/chat/task_done_at_test.go b/internal/equipo/chat/task_done_at_test.go
new file mode 100644
index 00000000..def19f83
--- /dev/null
+++ b/internal/equipo/chat/task_done_at_test.go
@@ -0,0 +1,102 @@
+package chat
+
+import (
+ "context"
+ "encoding/json"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/wire"
+)
+
+func TestTaskDoneAtSurvivesNotesAndTracksLatestCompletion(t *testing.T) {
+ r := newMeteredRig(t)
+ ctx := context.Background()
+ clock := time.Date(2026, 11, 24, 23, 30, 0, 0, time.FixedZone("west", -8*60*60))
+ r.s.SetClock(func() time.Time { return clock })
+ must := func(err error) {
+ t.Helper()
+ if err != nil {
+ t.Fatal(err)
+ }
+ }
+ must(r.s.db.G.Create(&projectRecord{ID: "p_done", Title: "Done", TitleSet: true}).Error)
+ must(r.s.db.G.Create(&taskRecord{ID: "tk_done", ProjectID: "p_done", Creator: hkOwner, Stage: wire.StageInProgress, CreatedAt: clock, UpdatedAt: clock}).Error)
+ read := func(want *time.Time) {
+ t.Helper()
+ v, err := r.s.Task(ctx, hkOwner, "tk_done")
+ must(err)
+ raw, err := json.Marshal(v)
+ must(err)
+ var body map[string]json.RawMessage
+ must(json.Unmarshal(raw, &body))
+ if want == nil {
+ if _, exists := body["done_at"]; exists {
+ t.Fatalf("unset done_at must be omitted: %s", body["done_at"])
+ }
+ return
+ }
+ if _, exists := body["done_at"]; !exists {
+ t.Fatal("completed task has no done_at")
+ }
+ var got string
+ must(json.Unmarshal(body["done_at"], &got))
+ if got != want.UTC().Format(time.RFC3339) {
+ t.Fatalf("done_at = %q, want stable UTC completion %q", got, want.UTC().Format(time.RFC3339))
+ }
+ }
+ transition := func(stage string) {
+ t.Helper()
+ must(r.s.tx(ctx, func(tx *txn) error {
+ k, err := tx.loadTask("tk_done")
+ if err != nil {
+ return err
+ }
+ k.Stage = stage
+ return tx.saveTask(&k)
+ }))
+ }
+ read(nil)
+ transition(wire.StageDone)
+ first := clock
+ read(&first)
+ clock = clock.Add(48 * time.Hour)
+ _, err := r.s.PostThread(ctx, hkOwner, "tk_done", wire.PostThread{Text: "A note after completion", IdempotencyKey: "later-note"})
+ must(err)
+ read(&first)
+ clock = clock.Add(time.Hour)
+ transition(wire.StageInProgress)
+ // The store retains the former completion while reopened. The native
+ // projection also requires stage done, so it cannot show this as finished.
+ read(&first)
+ clock = clock.Add(24 * time.Hour)
+ transition(wire.StageDone)
+ latest := clock
+ read(&latest)
+}
+
+func TestTaskDoneAtNormalizesWireTimeToUTC(t *testing.T) {
+ r := newMeteredRig(t)
+ if err := r.s.db.G.Create(&projectRecord{ID: "p_zone", Title: "Zone", TitleSet: true}).Error; err != nil {
+ t.Fatal(err)
+ }
+ // SQLite normalizes stored times on reads. Exercise the view's contract
+ // directly as well, with a non-UTC stable timestamp supplied by the store.
+ done := time.Date(2026, 11, 26, 1, 2, 3, 0, time.FixedZone("west", -8*60*60))
+ if err := r.s.tx(context.Background(), func(tx *txn) error {
+ v, err := tx.taskView(taskRecord{ID: "tk_zone", ProjectID: "p_zone", Creator: hkOwner, Stage: wire.StageDone, DoneAt: &done})
+ if err != nil {
+ return err
+ }
+ raw, err := json.Marshal(v.DoneAt)
+ if err != nil {
+ return err
+ }
+ if string(raw) != `"2026-11-26T09:02:03Z"` {
+ t.Fatalf("done_at must be UTC: %s", raw)
+ }
+ return nil
+ }); err != nil {
+ t.Fatal(err)
+ }
+}
diff --git a/internal/equipo/chat/tasks.go b/internal/equipo/chat/tasks.go
index ac5219b2..041a1bff 100644
--- a/internal/equipo/chat/tasks.go
+++ b/internal/equipo/chat/tasks.go
@@ -495,6 +495,10 @@ func stepViewSwitched(s stepRecord) wire.Step {
// taskView is the task with its project, findings, steps and thread.
func (t *txn) taskView(k taskRecord) (wire.Task, error) {
v := wire.Task{Stopping: k.MoveAbandoned && k.CancelRequested && !wire.FinalStage(k.Stage), PreparingProject: strings.HasPrefix(k.MoveProject, "new:"), Moving: k.MoveProject != "", CopyHold: k.CopyHold, ID: k.ID, Revision: k.Revision, ProjectID: k.ProjectID, Title: k.Title, Brief: k.Brief, Stage: k.Stage, Branch: k.Branch, BaseSHA: k.BaseSHA, Creator: k.Creator, TurnID: k.TurnID, Findings: []wire.Finding{}, Steps: []wire.Step{}, Thread: []wire.ThreadEntry{}, CreatedAt: k.CreatedAt, UpdatedAt: k.UpdatedAt}
+ if k.DoneAt != nil {
+ done := k.DoneAt.UTC()
+ v.DoneAt = &done
+ }
var p projectRecord
if err := t.db.Where("id = ?", k.ProjectID).First(&p).Error; err != nil {
return v, err
diff --git a/internal/wire/tasks.go b/internal/wire/tasks.go
index 3cd955cf..805b9e2c 100644
--- a/internal/wire/tasks.go
+++ b/internal/wire/tasks.go
@@ -354,6 +354,8 @@ type Task struct {
Thread []ThreadEntry `json:"thread"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
+ // DoneAt is the most recent transition to done, stable across later notes.
+ DoneAt *time.Time `json:"done_at,omitempty"`
// CandidateSHA is the newest pushed Engineering candidate. Checks,
// ChecksReason, Verdict and ReviewLabel are the judgements stored
// beside that SHA ("" until they exist); a new candidate clears them.
diff --git a/native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings b/native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings
index f32fe8ad..b887cc04 100644
--- a/native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings
+++ b/native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings
@@ -794,6 +794,17 @@
}
}
},
+ "chat.day.today": {
+ "extractionState": "manual",
+ "localizations": {
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Today"
+ }
+ }
+ }
+ },
"chat.held.budget": {
"extractionState": "manual",
"localizations": {
@@ -1256,6 +1267,28 @@
}
}
},
+ "native.needs.finished_today": {
+ "extractionState": "manual",
+ "localizations": {
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Finished today"
+ }
+ }
+ }
+ },
+ "native.needs.running_now": {
+ "extractionState": "manual",
+ "localizations": {
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Running now"
+ }
+ }
+ }
+ },
"native.step.log_tail": {
"extractionState": "manual",
"localizations": {
@@ -2917,6 +2950,17 @@
}
}
},
+ "work.needs_empty": {
+ "extractionState": "manual",
+ "localizations": {
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Nothing needs you right now."
+ }
+ }
+ }
+ },
"work.pause.check_machine": {
"extractionState": "manual",
"localizations": {
diff --git a/native/apple/Sources/EquipoKit/API/Thin.swift b/native/apple/Sources/EquipoKit/API/Thin.swift
index df16c7d6..a7aab50a 100644
--- a/native/apple/Sources/EquipoKit/API/Thin.swift
+++ b/native/apple/Sources/EquipoKit/API/Thin.swift
@@ -170,6 +170,8 @@ public struct ThinTask: Codable, Sendable, Identifiable, Equatable {
public var thread: [ThreadEntry]?
public var createdAt: Date
public var updatedAt: Date
+ /// Most recent transition to done; absent on older servers and unfinished tasks.
+ public var doneAt: Date? = nil
public var kind: String?
}
diff --git a/native/apple/Sources/EquipoKit/Presentation/NeedsToday.swift b/native/apple/Sources/EquipoKit/Presentation/NeedsToday.swift
new file mode 100644
index 00000000..5bc575ad
--- /dev/null
+++ b/native/apple/Sources/EquipoKit/Presentation/NeedsToday.swift
@@ -0,0 +1,31 @@
+import Foundation
+
+/// Today is a projection of the existing /tasks list, not another inbox.
+struct NeedsToday {
+ var running: [ThinTask]
+ var finished: [ThinTask]
+
+ init(tasks: [ThinTask], now: Date, zone: TimeZone) {
+ var calendar = Calendar(identifier: .gregorian)
+ calendar.timeZone = zone
+ running = tasks.filter {
+ !["done", "cancelled"].contains($0.stage) && $0.needsYou.isEmpty && Self.liveStep($0) != nil
+ }.sorted(by: Self.newestFirst)
+ finished = tasks.filter {
+ $0.stage == "done" && $0.doneAt.map { calendar.isDate($0, inSameDayAs: now) } == true
+ }.sorted {
+ let lhs = $0.doneAt ?? .distantPast, rhs = $1.doneAt ?? .distantPast
+ if lhs != rhs { return lhs > rhs }
+ return $0.id > $1.id
+ }
+ }
+
+ static func liveStep(_ task: ThinTask) -> ThinStep? {
+ task.steps?.last { $0.state == "running" || $0.state == "queued" }
+ }
+
+ private static func newestFirst(_ lhs: ThinTask, _ rhs: ThinTask) -> Bool {
+ if lhs.updatedAt != rhs.updatedAt { return lhs.updatedAt > rhs.updatedAt }
+ return lhs.id > rhs.id
+ }
+}
diff --git a/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings b/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings
index f32fe8ad..b887cc04 100644
--- a/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings
+++ b/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings
@@ -794,6 +794,17 @@
}
}
},
+ "chat.day.today": {
+ "extractionState": "manual",
+ "localizations": {
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Today"
+ }
+ }
+ }
+ },
"chat.held.budget": {
"extractionState": "manual",
"localizations": {
@@ -1256,6 +1267,28 @@
}
}
},
+ "native.needs.finished_today": {
+ "extractionState": "manual",
+ "localizations": {
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Finished today"
+ }
+ }
+ }
+ },
+ "native.needs.running_now": {
+ "extractionState": "manual",
+ "localizations": {
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Running now"
+ }
+ }
+ }
+ },
"native.step.log_tail": {
"extractionState": "manual",
"localizations": {
@@ -2917,6 +2950,17 @@
}
}
},
+ "work.needs_empty": {
+ "extractionState": "manual",
+ "localizations": {
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Nothing needs you right now."
+ }
+ }
+ }
+ },
"work.pause.check_machine": {
"extractionState": "manual",
"localizations": {
diff --git a/native/apple/Sources/EquipoKit/Session/EquipoSession.swift b/native/apple/Sources/EquipoKit/Session/EquipoSession.swift
index c9fc5bf9..bcb792f2 100644
--- a/native/apple/Sources/EquipoKit/Session/EquipoSession.swift
+++ b/native/apple/Sources/EquipoKit/Session/EquipoSession.swift
@@ -51,6 +51,8 @@ public final class EquipoSession {
public private(set) var tasks: [ThinTask] = []
/// nil until loaded: an unknown count is not zero.
public private(set) var needsYou: [ThinTask]?
+ /// The server inbox count, including set-aside rows. Unknown stays unknown.
+ public var needsYouCount: Int? { needsYou?.count }
public let attachments: AttachmentDraft
public let projectCatalog: ProjectCatalog
public var projects: [String: ThinProject] { projectCatalog.projects }
diff --git a/native/apple/Sources/EquipoKit/UI/NeedsViewFixture.swift b/native/apple/Sources/EquipoKit/UI/NeedsViewFixture.swift
new file mode 100644
index 00000000..dbf26812
--- /dev/null
+++ b/native/apple/Sources/EquipoKit/UI/NeedsViewFixture.swift
@@ -0,0 +1,90 @@
+#if DEBUG
+import SwiftUI
+
+/// In-memory fixture through the real session and device wire decoder.
+public enum NeedsViewFixture {
+ @MainActor public static func makeModel() -> EquipoAppModel {
+ let transport = NeedsFixtureTransport()
+ let store = MemorySecretStore()
+ let accounts = DeviceAccounts(store: store)
+ var account = DeviceAccount.new(origin: transport.origin, label: "Fixture")
+ account.credential = DeviceCredential(id: "fixture", token: "fixture", audience: "equipo.person.v1", instanceId: "fixture", expiresAt: .distantFuture)
+ account.teamName = "Oficina"; account.address = "paul@example.com"
+ try! accounts.commit(.save(account), lifetime: accounts.lifetimes.current)
+ let model = EquipoAppModel(store: store, makeTransport: { _ in transport })
+ model.destination = Destination(pane: .needs)
+ return model
+ }
+}
+
+#if os(iOS)
+public struct PhoneNeedsFixture: View {
+ @State private var model = NeedsViewFixture.makeModel()
+ public init() {}
+ public var body: some View {
+ if let session = model.session {
+ PhoneTabs(model: model, session: session)
+ .tint(Palette.accent)
+ .preferredColorScheme(.light)
+ .task { await session.refresh() }
+ }
+ }
+}
+#endif
+
+private struct NeedsFixtureTransport: EquipoTransport {
+ let origin = URL(string: "https://fixture.invalid")!
+ private var scenario: String { ProcessInfo.processInfo.environment["EQUIPO_NEEDS_FIXTURE"] ?? "list" }
+ private var needs: [[String: Any]] { scenario == "empty" || scenario == "today" ? [] : [retry, merge, question] }
+ private var tasks: [[String: Any]] { scenario == "empty" ? [] : needs + [running, finished] }
+ func send(_ request: APIRequest) async throws -> APIResponse {
+ let value: [String: Any]
+ switch request.path {
+ case "/snapshot":
+ value = ["me": ["id": "fixture", "address": "paul@example.com", "role": "owner", "team_id": "fixture", "team_name": "Oficina", "revision": 1], "cursor": 1, "tasks": tasks, "messages": [], "turns": [], "cards": scenario == "empty" ? [] : cards, "projects": []]
+ case "/tasks": value = ["items": tasks]
+ case "/needs-you": value = ["items": needs]
+ default:
+ value = tasks.first { request.path == "/tasks/" + ($0["id"] as! String) } ?? [:]
+ }
+ return APIResponse(status: 200, data: try JSONSerialization.data(withJSONObject: value))
+ }
+ func lines(_ request: APIRequest) async throws -> AsyncThrowingStream<String, Error> { AsyncThrowingStream { $0.finish() } }
+
+ private var at: String {
+ ISO8601DateFormatter().string(from: Calendar.current.startOfDay(for: Date()).addingTimeInterval(20 * 60))
+ }
+ private func task(_ id: String, _ title: String, stage: String, need: String = "", steps: [[String: Any]] = []) -> [String: Any] {
+ ["id": id, "revision": 1, "project_id": "project", "project": "Equipo", "repo": "oficina/equipo", "title": title, "brief": title, "stage": stage, "needs_you": need, "creator": "paul@example.com", "branch": "equipo/" + id, "url": "", "candidate_sha": "3f9c2a167de8", "checks": "", "checks_reason": "", "verdict": "", "review_label": "", "created_at": at, "updated_at": at, "steps": steps]
+ }
+ private func step(_ id: String, specialist: String = "engineering", state: String = "done", reason: String = "", headline: String = "") -> [String: Any] {
+ ["id": id, "specialist": specialist, "state": state, "reason": reason, "headline": headline, "summary": "", "verdict": "", "review_label": "", "checks": "", "gate": "", "terminated": true, "started_at": at, "finished_at": at]
+ }
+ private var retry: [String: Any] {
+ task("retry", "Clear the badge after sign-out", stage: "in_progress", need: "retry", steps: [step("failed", state: "failed", reason: "push_failed")])
+ }
+ private var merge: [String: Any] {
+ var task = task("merge", "Keep the sign-in button visible", stage: "ready_to_merge", need: "merge")
+ task["checks"] = "passed"; task["verdict"] = "approve"; task["review_label"] = "other_family"
+ return task
+ }
+ private var question: [String: Any] {
+ task("question", "Name the team in sign-in emails", stage: "in_review", need: "fix_rounds", steps: [step("review", specialist: "review", headline: "The subject still needs a decision")])
+ }
+ private var running: [String: Any] {
+ task("running", "Keep the task list up to date", stage: "in_progress", steps: [step("live", state: "running", headline: "Updating the list after a task finishes")])
+ }
+ private var finished: [String: Any] {
+ var task = task("finished", "Explain why the upload stopped", stage: "done", steps: [step("merged", specialist: "merge", headline: "Merged into main")])
+ task["done_at"] = at
+ return task
+ }
+ private var cards: [[String: Any]] {
+ [card("merge-card", task: "merge", kind: "merge", question: "Merge this fix?", options: ["merge", "not_now"]),
+ card("question-card", task: "question", kind: "question", question: "Should the subject name the team?", options: ["Yes, name the team", "Keep it short"])]
+ }
+ private func card(_ id: String, task: String, kind: String, question: String, options: [String]) -> [String: Any] {
+ ["id": id, "revision": 1, "kind": kind, "state": "open", "turn_id": "", "project_id": "project", "name": "", "question": question, "options": options, "choice": "", "task_id": task, "created_at": at, "updated_at": at]
+ }
+}
+#endif
diff --git a/native/apple/Sources/EquipoKit/UI/Screens/NeedsScreen.swift b/native/apple/Sources/EquipoKit/UI/Screens/NeedsScreen.swift
new file mode 100644
index 00000000..bd0888e4
--- /dev/null
+++ b/native/apple/Sources/EquipoKit/UI/Screens/NeedsScreen.swift
@@ -0,0 +1,47 @@
+import SwiftUI
+
+/// Needs you: every task waiting on this person, with its question or
+/// decision card where the conversation has one.
+public struct NeedsScreen: View {
+ let session: EquipoSession
+ var openTask: (String) -> Void
+ public init(session: EquipoSession, openTask: @escaping (String) -> Void) { self.session = session; self.openTask = openTask }
+ public var body: some View {
+ ScrollView {
+ VStack(alignment: .leading, spacing: 20) {
+ if let needs = session.needsYou {
+ if session.refreshFailed { ReadFailed { Task { await session.refresh() } } }
+ if needs.isEmpty {
+ ContentUnavailableView(EquipoStrings.text("work.needs_empty"), systemImage: "checkmark.circle")
+ .padding(.vertical, 12)
+ }
+ let groups = Feed.needsGroups(needs: needs, cards: session.cards)
+ ForEach(groups.waiting) { task in item(task) }
+ if !groups.setAside.isEmpty {
+ // Still waiting on you, and still counted: only out of the way.
+ SectionTitle(text: String(localized: "roster.set_aside", bundle: .module)).padding(.top, 8)
+ ForEach(groups.setAside) { task in item(task) }
+ }
+ TimelineView(.periodic(from: .now, by: 60)) { context in
+ TodaySection(tasks: session.tasks, now: context.date, openTask: openTask)
+ }
+ } else if session.refreshFailed {
+ ReadFailed { Task { await session.refresh() } }
+ } else {
+ ProgressView().accessibilityLabel(EquipoStrings.text("tab.needs")).frame(maxWidth: .infinity).padding(.top, 40)
+ }
+ }
+ .padding(16).frame(maxWidth: 760).frame(maxWidth: .infinity)
+ }
+ .refreshable { await session.refresh() }
+ .background(Palette.background)
+ }
+
+ private func item(_ task: ThinTask) -> some View {
+ VStack(alignment: .leading, spacing: 8) {
+ TaskRowButton(task: task, needsYou: session.waitsOnYou(task)) { openTask(task.id) }
+ TaskCards(session: session, task: task)
+ }
+ }
+}
+
diff --git a/native/apple/Sources/EquipoKit/UI/Screens/PhoneRoot.swift b/native/apple/Sources/EquipoKit/UI/Screens/PhoneRoot.swift
index 86bf0d9d..abb89761 100644
--- a/native/apple/Sources/EquipoKit/UI/Screens/PhoneRoot.swift
+++ b/native/apple/Sources/EquipoKit/UI/Screens/PhoneRoot.swift
@@ -35,7 +35,7 @@ public struct PhoneRoot: View {
.tint(Palette.accent)
.onChange(of: phase) { _, now in now == .active ? model.foreground() : model.background() }
.onChange(of: model.session?.status) { _, status in if status == .signedOut { model.sessionEnded() } }
- .onChange(of: model.session?.needsYou?.count) { _, count in model.needsYouChanged(count) }
+ .onChange(of: model.session?.needsYouCount) { _, count in model.needsYouChanged(count) }
.onChange(of: model.session?.tasks) { _, tasks in
// A task that ended while its end push was lost leaves the Lock Screen.
guard let tasks else { return }
@@ -72,7 +72,7 @@ struct PhoneTabs: View {
NeedsScreen(session: session) { needsPath.append($0) }
}
}
- .badge(session.needsYou?.count ?? 0)
+ .badge(session.needsYouCount ?? 0)
Tab(String(localized: "nav.projects", bundle: .module), systemImage: "folder", value: .projects) {
NavigationStack(path: $projectsPath) {
ProjectsScreen(session: session) { projectsPath.append(.project($0)) }
diff --git a/native/apple/Sources/EquipoKit/UI/Screens/TaskScreens.swift b/native/apple/Sources/EquipoKit/UI/Screens/TaskScreens.swift
index 900f4955..81612ab1 100644
--- a/native/apple/Sources/EquipoKit/UI/Screens/TaskScreens.swift
+++ b/native/apple/Sources/EquipoKit/UI/Screens/TaskScreens.swift
@@ -1,48 +1,5 @@
import SwiftUI
-/// Needs you: every task waiting on this person, with its question or
-/// decision card where the conversation has one.
-public struct NeedsScreen: View {
- let session: EquipoSession
- var openTask: (String) -> Void
- public init(session: EquipoSession, openTask: @escaping (String) -> Void) { self.session = session; self.openTask = openTask }
- public var body: some View {
- ScrollView {
- VStack(alignment: .leading, spacing: 20) {
- if let needs = session.needsYou {
- if needs.isEmpty {
- ContentUnavailableView {
- Label(String(localized: "needs.empty_title", bundle: .module), systemImage: "checkmark.circle")
- } description: { Text(String(localized: "needs.empty", bundle: .module)) }
- .padding(.top, 40)
- }
- let groups = Feed.needsGroups(needs: needs, cards: session.cards)
- ForEach(groups.waiting) { task in item(task) }
- if !groups.setAside.isEmpty {
- // Still waiting on you, and still counted: only out of the way.
- SectionTitle(text: String(localized: "roster.set_aside", bundle: .module)).padding(.top, 8)
- ForEach(groups.setAside) { task in item(task) }
- }
- } else if session.refreshFailed {
- ReadFailed { Task { await session.refresh() } }
- } else {
- ProgressView().frame(maxWidth: .infinity).padding(.top, 40)
- }
- }
- .padding(16).frame(maxWidth: 760).frame(maxWidth: .infinity)
- }
- .refreshable { await session.refresh() }
- .background(Palette.background)
- }
-
- private func item(_ task: ThinTask) -> some View {
- VStack(alignment: .leading, spacing: 8) {
- TaskRowButton(task: task, needsYou: session.waitsOnYou(task)) { openTask(task.id) }
- TaskCards(session: session, task: task)
- }
- }
-}
-
/// Tasks, grouped as the web groups them.
public struct TasksScreen: View {
let session: EquipoSession
diff --git a/native/apple/Sources/EquipoKit/UI/Screens/TodaySection.swift b/native/apple/Sources/EquipoKit/UI/Screens/TodaySection.swift
new file mode 100644
index 00000000..f3ef6cae
--- /dev/null
+++ b/native/apple/Sources/EquipoKit/UI/Screens/TodaySection.swift
@@ -0,0 +1,55 @@
+import SwiftUI
+
+struct TodaySection: View {
+ let tasks: [ThinTask]
+ let now: Date
+ var openTask: (String) -> Void
+
+ var body: some View {
+ let today = NeedsToday(tasks: tasks, now: now, zone: .current)
+ if !today.running.isEmpty || !today.finished.isEmpty {
+ VStack(alignment: .leading, spacing: 12) {
+ Text(EquipoStrings.text("chat.day.today")).font(.title2.bold())
+ if !today.running.isEmpty {
+ // COPY APPROVED: Luna, 2026-11-26.
+ SectionTitle(text: EquipoStrings.text("native.needs.running_now"))
+ ForEach(today.running) { task in
+ TodayTaskRow(task: task, now: now, running: true) { openTask(task.id) }
+ }
+ }
+ if !today.finished.isEmpty {
+ // COPY APPROVED: Luna, 2026-11-26.
+ SectionTitle(text: EquipoStrings.text("native.needs.finished_today"))
+ ForEach(today.finished) { task in
+ TodayTaskRow(task: task, now: now, running: false) { openTask(task.id) }
+ }
+ }
+ }
+ }
+ }
+}
+
+private struct TodayTaskRow: View {
+ let task: ThinTask
+ let now: Date
+ let running: Bool
+ var open: () -> Void
+
+ var body: some View {
+ Panel(padding: 14, spacing: 10) {
+ TaskRowButton(task: task, needsYou: false, action: open)
+ if running {
+ if let pause = TaskPause(task, mine: false, now: now) { PauseLead(pause: pause) }
+ else if let step = NeedsToday.liveStep(task) {
+ VStack(alignment: .leading, spacing: 4) {
+ Text(Specialist(category: step.specialist).name).font(Typo.captionStrong)
+ if !step.headline.isEmpty { Text(step.headline).font(Typo.secondary).fixedSize(horizontal: false, vertical: true) }
+ }.foregroundStyle(Palette.secondary)
+ }
+ } else if let doneAt = task.doneAt {
+ Text(doneAt, format: .dateTime.hour().minute())
+ .font(Typo.secondary).foregroundStyle(Palette.secondary)
+ }
+ }
+ }
+}
diff --git a/native/apple/Sources/EquipoMac/EquipoMacApp.swift b/native/apple/Sources/EquipoMac/EquipoMacApp.swift
index 9fd262c9..4bc250c5 100644
--- a/native/apple/Sources/EquipoMac/EquipoMacApp.swift
+++ b/native/apple/Sources/EquipoMac/EquipoMacApp.swift
@@ -19,7 +19,7 @@ import SwiftUI
#if DEBUG
// Offline fixture captures must run this build, without an updater
// replacing it with a published app during the capture.
- if ProcessInfo.processInfo.environment["EQUIPO_STOPPED_FIXTURE"] != nil || ProcessInfo.processInfo.environment["EQUIPO_ATTACHMENTS_FIXTURE"] != nil { return nil }
+ if ProcessInfo.processInfo.environment["EQUIPO_NEEDS_FIXTURE"] != nil || ProcessInfo.processInfo.environment["EQUIPO_STOPPED_FIXTURE"] != nil || ProcessInfo.processInfo.environment["EQUIPO_ATTACHMENTS_FIXTURE"] != nil { return nil }
#endif
return NativeUpdater(policy: .quiet)
}()
@@ -29,7 +29,8 @@ import SwiftUI
WindowGroup(EquipoStrings.text("app.name")) {
Group {
#if DEBUG
- if ProcessInfo.processInfo.environment["EQUIPO_STOPPED_FIXTURE"]?.hasPrefix("conversation-") == true { StoppedConversationFixture() }
+ if ProcessInfo.processInfo.environment["EQUIPO_NEEDS_FIXTURE"] != nil { MacNeedsFixture() }
+ else if ProcessInfo.processInfo.environment["EQUIPO_STOPPED_FIXTURE"]?.hasPrefix("conversation-") == true { StoppedConversationFixture() }
else if ProcessInfo.processInfo.environment["EQUIPO_STOPPED_FIXTURE"] != nil { StoppedWorkFixture() }
else if ProcessInfo.processInfo.environment["EQUIPO_ATTACHMENTS_FIXTURE"] != nil { MacAttachmentsFixture() }
else { MacRoot(model: model) }
@@ -101,7 +102,7 @@ struct MacRoot: View {
NSApp.occlusionState.contains(.visible) ? model.foreground() : model.background()
}
.onChange(of: model.session?.status) { _, status in if status == .signedOut { model.sessionEnded() } }
- .onChange(of: model.session?.needsYou?.count) { _, count in model.needsYouChanged(count) }
+ .onChange(of: model.session?.needsYouCount) { _, count in model.needsYouChanged(count) }
}
}
diff --git a/native/apple/Sources/EquipoMac/MacMainView.swift b/native/apple/Sources/EquipoMac/MacMainView.swift
index 2d974e44..0c2f633f 100644
--- a/native/apple/Sources/EquipoMac/MacMainView.swift
+++ b/native/apple/Sources/EquipoMac/MacMainView.swift
@@ -77,7 +77,7 @@ struct MacMainView: View {
}
@ViewBuilder private var needsRow: some View {
- if let count = session.needsYou?.count, count > 0 {
+ if let count = session.needsYouCount, count > 0 {
Label(EquipoStrings.text("tab.needs"), systemImage: "tray").badge(count)
} else {
Label(EquipoStrings.text("tab.needs"), systemImage: "tray")
@@ -89,11 +89,11 @@ struct MacMainView: View {
Button { pane = .needs } label: {
HStack(spacing: 6) {
Image(systemName: "tray")
- if let count = session.needsYou?.count { Text(count.formatted()).monospacedDigit() }
+ if let count = session.needsYouCount { Text(count.formatted()).monospacedDigit() }
}
}
.help(EquipoStrings.text("tab.needs"))
- .accessibilityLabel(session.needsYou.map { EquipoStrings.text("needs.count \($0.count)") } ?? EquipoStrings.text("tab.needs"))
+ .accessibilityLabel(session.needsYouCount.map { count in EquipoStrings.text("needs.count \(count)") } ?? EquipoStrings.text("tab.needs"))
}
private func title(for pane: Pane) -> String {
diff --git a/native/apple/Sources/EquipoMac/MacNeedsFixture.swift b/native/apple/Sources/EquipoMac/MacNeedsFixture.swift
new file mode 100644
index 00000000..2b2d3fa6
--- /dev/null
+++ b/native/apple/Sources/EquipoMac/MacNeedsFixture.swift
@@ -0,0 +1,37 @@
+#if DEBUG
+import AppKit
+import EquipoKit
+import SwiftUI
+
+struct MacNeedsFixture: View {
+ @State private var model = NeedsViewFixture.makeModel()
+ var body: some View {
+ if let session = model.session {
+ MacMainView(model: model, session: session)
+ .modifier(NeedsCapture())
+ .preferredColorScheme(.light)
+ .task { await session.refresh() }
+ }
+ }
+}
+
+private struct NeedsCapture: ViewModifier {
+ func body(content: Content) -> some View {
+ content.task {
+ guard let path = ProcessInfo.processInfo.environment["EQUIPO_FIXTURE_CAPTURE"] else { return }
+ try? await Task.sleep(for: .seconds(2))
+ guard let window = NSApp.windows.first(where: { $0.isVisible && !$0.isSheet }), let view = window.contentView else { return }
+ window.appearance = NSAppearance(named: .aqua)
+ window.setContentSize(NSSize(width: 1100, height: 1000))
+ try? await Task.sleep(for: .milliseconds(300))
+ view.layoutSubtreeIfNeeded(); window.displayIfNeeded()
+ _ = FileManager.default.createFile(atPath: path + ".window", contents: Data(String(window.windowNumber).utf8))
+ _ = FileManager.default.createFile(atPath: path + ".pid", contents: Data(String(ProcessInfo.processInfo.processIdentifier).utf8))
+ if let bitmap = view.bitmapImageRepForCachingDisplay(in: view.bounds) {
+ view.cacheDisplay(in: view.bounds, to: bitmap)
+ _ = FileManager.default.createFile(atPath: path, contents: bitmap.representation(using: .png, properties: [:]))
+ }
+ }
+ }
+}
+#endif
diff --git a/native/apple/Tests/EquipoKitTests/NeedsTodayTests.swift b/native/apple/Tests/EquipoKitTests/NeedsTodayTests.swift
new file mode 100644
index 00000000..5bf78520
--- /dev/null
+++ b/native/apple/Tests/EquipoKitTests/NeedsTodayTests.swift
@@ -0,0 +1,160 @@
+import Foundation
+import Testing
+@testable import EquipoKit
+
+@Suite struct NeedsTodayTests {
+ static func task(_ id: String, stage: String = "in_progress", need: String = "", at: String = "2026-11-26T12:00:00Z") throws -> ThinTask {
+ var task: ThinTask = try Fixture.decode("thin/task")
+ task.id = id; task.stage = stage; task.needsYou = need
+ task.updatedAt = ISO8601DateFormatter().date(from: at)!
+ task.doneAt = task.updatedAt
+ var step = task.steps![0]; step.state = "running"; step.specialist = "engineering"
+ task.steps = [step]
+ return task
+ }
+ static let now = ISO8601DateFormatter().date(from: "2026-11-26T12:00:00Z")!
+ static let utc = TimeZone(secondsFromGMT: 0)!
+
+ @Test func completionDaySurvivesLaterNotesAndOldPayloads() throws {
+ let old: ThinTask = try Fixture.decode("thin/task")
+ #expect(old.doneAt == nil)
+ var legacy = try Self.task("legacy", stage: "done")
+ legacy.doneAt = nil
+ var yesterday = try Self.task("yesterday", stage: "done", at: "2026-11-25T12:00:00Z")
+ yesterday.updatedAt = Self.now
+ var today = try Self.task("today", stage: "done")
+ today.updatedAt = Self.now.addingTimeInterval(86_400)
+ var later = try Self.task("later", stage: "done", at: "2026-11-26T13:00:00Z")
+ later.updatedAt = Self.now
+ var reopened = today; reopened.id = "reopened"; reopened.stage = "in_progress"
+ let result = NeedsToday(tasks: [legacy, yesterday, today, later, reopened], now: Self.now, zone: Self.utc)
+ #expect(result.finished.map(\.id) == ["later", "today"])
+ // Exercise wire decoding independently of the test helper's property assignment.
+ let encoder = EquipoJSON.encoder; encoder.dateEncodingStrategy = .iso8601
+ var body = try JSONSerialization.jsonObject(with: encoder.encode(old)) as! [String: Any]
+ body["done_at"] = "2026-11-26T12:00:00Z"
+ let decoded = try EquipoJSON.decoder.decode(ThinTask.self, from: JSONSerialization.data(withJSONObject: body))
+ #expect(decoded.doneAt == Self.now)
+ }
+
+ @Test func runningRequiresLiveWorkAndNoDecision() throws {
+ let live = try Self.task("live", at: "2026-11-20T12:00:00Z")
+ var queued = live; queued.id = "queued"; queued.steps![0].state = "queued"
+ var finishedStep = live; finishedStep.id = "ended-step"; finishedStep.steps![0].state = "done"
+ var missing = live; missing.id = "missing"; missing.steps = nil
+ var stopped = live; stopped.id = "stopped"; stopped.steps![0].state = "failed"
+ let done = try Self.task("done", stage: "done")
+ let cancelled = try Self.task("cancelled", stage: "cancelled")
+ let needs = try Self.task("needs", need: "held")
+ let result = NeedsToday(tasks: [live, queued, finishedStep, missing, stopped, done, cancelled, needs], now: Self.now, zone: Self.utc)
+ #expect(Set(result.running.map(\.id)) == ["live", "queued"])
+ #expect(result.finished.map(\.id) == ["done"])
+ }
+ @Test func runningUsesLatestActivityAndStableIdentityOrder() throws {
+ let earlier = try Self.task("earlier", at: "2026-11-25T12:00:00Z")
+ let later = try Self.task("later")
+ var tie = later; tie.id = "z-tie"
+ let result = NeedsToday(tasks: [earlier, later, tie], now: Self.now, zone: Self.utc)
+ #expect(result.running.map(\.id) == ["z-tie", "later", "earlier"])
+ }
+
+ @Test func latestLiveStepWins() throws {
+ var task = try Self.task("live")
+ var old = task.steps![0]; old.id = "older"
+ var latest = old; latest.id = "latest"; latest.specialist = "checks"
+ var ended = latest; ended.id = "ended"; ended.state = "done"
+ task.steps = [old, latest, ended]
+ #expect(NeedsToday.liveStep(task)?.id == "latest")
+ task.steps = [ended]
+ #expect(NeedsToday.liveStep(task) == nil)
+ }
+ @Test func finishedUsesLocalCalendarDayNotUTCOrLast24Hours() throws {
+ let zone = TimeZone(identifier: "America/Los_Angeles")!
+ let now = ISO8601DateFormatter().date(from: "2026-11-26T09:00:00Z")!
+ let previous = try Self.task("previous", stage: "done", at: "2026-11-26T07:59:59Z")
+ let midnight = try Self.task("midnight", stage: "done", at: "2026-11-26T08:00:00Z")
+ let end = try Self.task("end", stage: "done", at: "2026-11-27T07:59:59Z")
+ let tomorrow = try Self.task("tomorrow", stage: "done", at: "2026-11-27T08:00:00Z")
+ let result = NeedsToday(tasks: [previous, midnight, end, tomorrow], now: now, zone: zone)
+ #expect(result.finished.map(\.id) == ["end", "midnight"])
+ }
+ @Test func daylightSavingDayAndStableOrdering() throws {
+ let zone = TimeZone(identifier: "Europe/Dublin")!
+ let now = ISO8601DateFormatter().date(from: "2026-10-25T12:00:00Z")!
+ let first = try Self.task("first", stage: "done", at: "2026-10-24T23:00:00Z")
+ let last = try Self.task("last", stage: "done", at: "2026-10-25T23:59:59Z")
+ let outside = try Self.task("outside", stage: "done", at: "2026-10-26T00:00:00Z")
+ var tie = last; tie.id = "z-tie"
+ let result = NeedsToday(tasks: [first, last, outside, tie], now: now, zone: zone)
+ #expect(result.finished.map(\.id) == ["z-tie", "last", "first"])
+ #expect(NeedsToday(tasks: [], now: now, zone: zone).finished.isEmpty)
+ }
+}
+
+
+@MainActor @Suite struct NeedsInboxTests {
+ private func session(_ transport: ScriptedTransport) -> EquipoSession {
+ var account = DeviceAccount.new(origin: transport.origin, label: "Test")
+ account.credential = DeviceCredential(id: "test", token: "test-token", audience: "equipo.person.v1", instanceId: "test", expiresAt: .distantFuture)
+ return EquipoSession(account: account, accounts: DeviceAccounts(store: MemorySecretStore()), transport: transport)
+ }
+ private func response(_ tasks: [ThinTask]) throws -> APIResponse {
+ let encoder = EquipoJSON.encoder; encoder.dateEncodingStrategy = .iso8601
+ return APIResponse(status: 200, data: try encoder.encode(["items": tasks]))
+ }
+ @Test func badgeCountsOnlyNeedsIncludingSetAsideAndPreservesUnknown() async throws {
+ let transport = ScriptedTransport()
+ var snapshot: Snapshot = try Fixture.decode("thin/snapshot")
+ for index in snapshot.cards!.indices { snapshot.cards![index].aside = true }
+ let encoder = EquipoJSON.encoder; encoder.dateEncodingStrategy = .iso8601
+ transport.on("GET /snapshot", .success(APIResponse(status: 200, data: try encoder.encode(snapshot))))
+ transport.on("GET /tasks", fixture: "thin/tasks")
+ let first = try NeedsTodayTests.task("tkqsrho7oq3n", need: "retry")
+ let second = try NeedsTodayTests.task("second", need: "merge")
+ transport.on("GET /needs-you", .success(try response([first, second])), .success(try response([first])), .failure(.offline), .success(try response([])))
+ let session = session(transport)
+ #expect(session.needsYouCount == nil)
+ await session.refresh(); #expect(session.needsYouCount == 2)
+ #expect(Feed.needsGroups(needs: session.needsYou!, cards: session.cards).setAside.count == 1)
+ await session.refresh(); #expect(session.needsYouCount == 1)
+ await session.refresh(); #expect(session.needsYouCount == 1)
+ #expect(session.refreshFailed)
+ await session.refresh(); #expect(session.needsYouCount == 0)
+ #expect(!session.tasks.isEmpty)
+ }
+ @Test func todayUsesOnlyTheReturnedTaskWindow() async throws {
+ let transport = ScriptedTransport()
+ transport.on("GET /snapshot", fixture: "thin/snapshot")
+ transport.on("GET /needs-you", .success(try response([])))
+ let window = try (0..<100).map { try NeedsTodayTests.task("returned-\($0)", stage: "done") }
+ transport.on("GET /tasks", .success(try response(window)))
+ let session = session(transport); await session.refresh()
+ let today = NeedsToday(tasks: session.tasks, now: NeedsTodayTests.now, zone: NeedsTodayTests.utc)
+ #expect(Set(today.finished.map(\.id)) == Set(window.map(\.id)))
+ #expect(today.finished.count == 100)
+ #expect(session.needsYouCount == 0)
+ #expect(transport.requests.filter { $0.path.hasPrefix("/tasks") }.map(\.path) == ["/tasks"])
+ #expect(!transport.requests.contains { $0.path.hasPrefix("/journey") })
+ #expect(transport.sent("GET /tasks").first?.bearer == "test-token")
+ }
+ @Test func taskEventsRefreshInboxAndTodayTogether() async throws {
+ let transport = ScriptedTransport()
+ transport.on("GET /snapshot", fixture: "thin/snapshot")
+ let pending = try NeedsTodayTests.task("event-task", need: "retry")
+ let done = try NeedsTodayTests.task("event-task", stage: "done")
+ transport.on("GET /tasks", .success(try response([pending])), .success(try response([done])))
+ transport.on("GET /needs-you", .success(try response([pending])), .success(try response([])))
+ let session = session(transport); await session.refresh()
+ #expect(session.needsYouCount == 1)
+ await session.handle(#"data: {"cursor":100,"type":"task","resource":"task","id":"event-task","revision":2,"data":{}}"#)
+ for _ in 0..<200 {
+ if session.needsYouCount == 0 { break }
+ try await Task.sleep(for: .milliseconds(5))
+ }
+ #expect(session.needsYouCount == 0)
+ let today = NeedsToday(tasks: session.tasks, now: NeedsTodayTests.now, zone: NeedsTodayTests.utc)
+ #expect(today.finished.map(\.id) == ["event-task"])
+ #expect(transport.sent("GET /needs-you").count == 2)
+ }
+
+}
diff --git a/native/ios/Sources/EquipoPhoneApp.swift b/native/ios/Sources/EquipoPhoneApp.swift
index 06e8d6f6..955ef71e 100644
--- a/native/ios/Sources/EquipoPhoneApp.swift
+++ b/native/ios/Sources/EquipoPhoneApp.swift
@@ -7,7 +7,8 @@ struct EquipoPhoneApp: App {
var body: some Scene {
WindowGroup {
#if DEBUG
- if ProcessInfo.processInfo.environment["EQUIPO_STOPPED_FIXTURE"] != nil { StoppedWorkFixture() }
+ if ProcessInfo.processInfo.environment["EQUIPO_NEEDS_FIXTURE"] != nil { PhoneNeedsFixture() }
+ else if ProcessInfo.processInfo.environment["EQUIPO_STOPPED_FIXTURE"] != nil { StoppedWorkFixture() }
else { PhoneRoot(model: delegate.model) }
#else
PhoneRoot(model: delegate.model)
diff --git a/native/ios/UITests/NeedsYouUITests.swift b/native/ios/UITests/NeedsYouUITests.swift
new file mode 100644
index 00000000..8b8d7607
--- /dev/null
+++ b/native/ios/UITests/NeedsYouUITests.swift
@@ -0,0 +1,35 @@
+import XCTest
+
+final class NeedsYouUITests: XCTestCase {
+ @MainActor func testTodayShowsRunningAndFinishedWithoutAnInboxBadge() {
+ let app = launch("today")
+ XCTAssertTrue(app.staticTexts["Running now"].waitForExistence(timeout: 15))
+ XCTAssertTrue(app.staticTexts["Keep the task list up to date"].exists)
+ for _ in 0..<3 {
+ if app.staticTexts["Explain why the upload stopped"].isHittable { break }
+ app.swipeUp()
+ }
+ XCTAssertTrue(app.staticTexts["Finished today"].isHittable)
+ XCTAssertTrue(app.staticTexts["Explain why the upload stopped"].isHittable)
+ XCTAssertTrue(app.staticTexts["Updating the list after a task finishes"].exists)
+ let tab = app.tabBars.buttons.matching(NSPredicate(format: "label BEGINSWITH %@", "Needs you")).firstMatch
+ XCTAssertFalse((tab.value as? String ?? "").contains("2"))
+ capture("iphone-today")
+ }
+ @MainActor func testEmptyUsesReviewedWords() {
+ let app = launch("empty")
+ XCTAssertTrue(app.staticTexts["Nothing needs you right now."].waitForExistence(timeout: 15))
+ XCTAssertFalse(app.staticTexts["Running now"].exists)
+ XCTAssertFalse(app.staticTexts["Finished today"].exists)
+ capture("iphone-empty")
+ }
+ @MainActor private func launch(_ fixture: String) -> XCUIApplication {
+ let app = XCUIApplication()
+ app.launchEnvironment["EQUIPO_NEEDS_FIXTURE"] = fixture
+ app.launch(); return app
+ }
+ @MainActor private func capture(_ name: String) {
+ let attachment = XCTAttachment(screenshot: XCUIScreen.main.screenshot())
+ attachment.name = name; attachment.lifetime = .keepAlways; add(attachment)
+ }
+}
diff --git a/native/ios/project.yml b/native/ios/project.yml
index 1759e072..e7fa4b4a 100644
--- a/native/ios/project.yml
+++ b/native/ios/project.yml
@@ -100,7 +100,7 @@ targets:
AttachmentSourceUITests:
type: bundle.ui-testing
platform: iOS
- sources: [UITests]
+ sources: [UITests/AttachmentSourceUITests.swift]
dependencies:
- target: EquipoPhone
settings:
@@ -108,6 +108,18 @@ targets:
PRODUCT_BUNDLE_IDENTIFIER: works.oficina.equipo.attachment-tests
GENERATE_INFOPLIST_FILE: true
TEST_TARGET_NAME: EquipoPhone
+ NeedsYouUITests:
+ type: bundle.ui-testing
+ platform: iOS
+ sources: [UITests/NeedsYouUITests.swift]
+ dependencies:
+ - target: EquipoPhone
+ settings:
+ base:
+ PRODUCT_BUNDLE_IDENTIFIER: works.oficina.equipo.needs-tests
+ GENERATE_INFOPLIST_FILE: true
+ TEST_TARGET_NAME: EquipoPhone
+
schemes:
EquipoPhone:
build:
@@ -120,3 +132,11 @@ schemes:
AttachmentSourceUITests: [test]
test:
targets: [AttachmentSourceUITests]
+
+ NeedsYouUI:
+ build:
+ targets:
+ EquipoPhone: all
+ NeedsYouUITests: [test]
+ test:
+ targets: [NeedsYouUITests]
diff --git a/native/scripts/check-parity.py b/native/scripts/check-parity.py
index 1a90115f..363658dc 100755
--- a/native/scripts/check-parity.py
+++ b/native/scripts/check-parity.py
@@ -22,7 +22,7 @@ for key in sorted(set(re.findall(r'"(work\.reason\.[^"]+)":', copy))):
if key not in strings:
problems.append(f'{key}: native must carry every reviewed stop reason')
for key, text in sorted(strings.items()):
- if not key.startswith(('chat.card.', 'chat.paste.', 'chat.attach.', 'work.tl.', 'roster.', 'projects.', 'work.star.', 'api.', 'nav.projects', 'chat.connections.connected', 'counts.unavailable', 'team.close', 'work.pause.', 'work.reason.', 'work.needs.', 'chat.held.', 'work.hold.', 'work.stage.', 'time.', 'work.hold.run_now', 'work.recover')):
+ if not key.startswith(('chat.card.', 'chat.paste.', 'chat.attach.', 'work.tl.', 'roster.', 'projects.', 'work.star.', 'api.', 'nav.projects', 'chat.connections.connected', 'counts.unavailable', 'team.close', 'work.pause.', 'work.reason.', 'work.needs.', 'chat.held.', 'work.hold.', 'work.stage.', 'time.', 'work.hold.run_now', 'work.recover', 'chat.day.today', 'work.needs_empty')):
continue
found = re.findall(r'"' + re.escape(key) + r'":\s*"((?:[^"\\]|\\.)*)"', copy)
if len(found) != 1:
diff --git a/native/scripts/strings.json b/native/scripts/strings.json
index 0bc02699..07bdaa70 100644
--- a/native/scripts/strings.json
+++ b/native/scripts/strings.json
@@ -370,5 +370,9 @@
"native.attach.camera": "Camera",
"native.attach.files": "Files",
"native.attach.paste": "Paste",
- "native.attach.camera_usage": "Use your camera to take a photo to attach to your message."
+ "native.attach.camera_usage": "Use your camera to take a photo to attach to your message.",
+ "chat.day.today": "Today",
+ "work.needs_empty": "Nothing needs you right now.",
+ "native.needs.running_now": "Running now",
+ "native.needs.finished_today": "Finished today"
}