Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/CLOCK_SURFACES_ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Because they are components, regions are gated by **state/props**, not an `activ
### B6 — Button row + My Time preview

- **Location:** 1670–1852 (`loading` early return 1670–1676, `canClockIn` / `hasOpenSession` / `showMyTimeDayPreview` 1678–1681, `myTimePreviewButton` 1683–1717, `topRowContent` 1755–1841, wrapper 1843–1852).
- **Behavior:** open session → red `formatElapsed(totalSecondsToday) Clock Out` (hidden when `salaryUiActive`; "Checking…" while the tally gate loads) + **Break** (`BreakPress`, offered by `breakOffered` wherever Clock Out is; one press sends the clock out with no window and the row becomes `OnBreakRow` with **Back to work**, **Clock In…** and *Done for the day* until a session opens or the day turns; the rule is `lib/clock/clockBreak.ts`, the two presses `hooks/useClockBreak.ts`, the break in hand one `localStorage` entry by person; since v2.9203 the bar also tells **the break's door** what is true and hands it its three presses (`lib/clock/clockBreakDoor.ts`, `contexts/ClockBreakDoorContext.tsx`, inside the clock's bridge), so the Job Mode card, where this bar is mounted out of sight, draws Break and its *On a break* band itself (`jobModeBreakOffered` in `lib/jobMode/pressBar.ts`, `components/jobMode/JobModeOnBreak.tsx`); since v2.9217 *Done for the day* ends the break and then asks for the day's bids, **Your bids today**, when the day holds a bid and for no role when it holds none (`lib/clock/doneForTheDay.ts`, `components/clock/DoneForTheDayBidDay.tsx`, kept through `save_my_bid_day`)) + blue Update Focus; no session and salaried → only the My Time preview clock icon (it needs `onOpenMyTimeDayEditor`, which Dashboard withholds when `dashboardSelfIsSalary`, so there the row renders nothing); otherwise orange Clock In (`CLOCK_IN_ACCENT_UNDER_WORDS` under `CLOCK_IN_ACCENT_TEXT` — since v2.6186 the deep safety orange `#c75000` under white words in both themes, `lib/orangeUnderWords.ts`; v2.5981 had near-black words on `#ff6600` — as on Complete Clock In, the Job Mode card's and the press bar's orange press, `DAY_PRESS_TEXT`, and the strip's three orange headers) + B7's quick-time door + preview icon when `todaySessions` exist. Clock Out and Update Focus disable on any of `actionLoading || updateFocusLoading || clockOutSaving || clockOutTallyGateLoading`; Clock In on `!canClockIn || actionLoading`. `embedded` drops the wrapper's bottom margin.
- **Behavior:** open session → red `formatElapsed(totalSecondsToday) Clock Out` (hidden when `salaryUiActive`; "Checking…" while the tally gate loads) + **Break** (`BreakPress`, offered by `breakOffered` wherever Clock Out is; one press sends the clock out with no window and the row becomes `OnBreakRow` with **Back to work**, **Clock In…** and *Done for the day* until a session opens or the day turns; the rule is `lib/clock/clockBreak.ts`, the two presses `hooks/useClockBreak.ts`, the break in hand one `localStorage` entry by person; since v2.9203 the bar also tells **the break's door** what is true and hands it its three presses (`lib/clock/clockBreakDoor.ts`, `contexts/ClockBreakDoorContext.tsx`, inside the clock's bridge), so the Job Mode card, where this bar is mounted out of sight, draws Break and its *On a break* band itself (`jobModeBreakOffered` in `lib/jobMode/pressBar.ts`, `components/jobMode/JobModeOnBreak.tsx`); since v2.9217 *Done for the day* ends the break and then asks for the day's bids, **Your bids today**, when the day holds a bid and for no role when it holds none (`lib/clock/doneForTheDay.ts`, `components/clock/DoneForTheDayBidDay.tsx` over the window `components/clock/BidDayKeepWindow.tsx`, which the Job Mode header's **Bids · 3 ›** opens too, kept through `save_my_bid_day`)) + blue Update Focus; no session and salaried → only the My Time preview clock icon (it needs `onOpenMyTimeDayEditor`, which Dashboard withholds when `dashboardSelfIsSalary`, so there the row renders nothing); otherwise orange Clock In (`CLOCK_IN_ACCENT_UNDER_WORDS` under `CLOCK_IN_ACCENT_TEXT` — since v2.6186 the deep safety orange `#c75000` under white words in both themes, `lib/orangeUnderWords.ts`; v2.5981 had near-black words on `#ff6600` — as on Complete Clock In, the Job Mode card's and the press bar's orange press, `DAY_PRESS_TEXT`, and the strip's three orange headers) + B7's quick-time door + preview icon when `todaySessions` exist. Clock Out and Update Focus disable on any of `actionLoading || updateFocusLoading || clockOutSaving || clockOutTallyGateLoading`; Clock In on `!canClockIn || actionLoading`. `embedded` drops the wrapper's bottom margin.
- **Tests:** none (no render smoke for the component).
- **Extraction status:** stays with the parent; it is the component.

Expand Down
5 changes: 5 additions & 0 deletions docs/GLOSSARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4533,6 +4533,10 @@ Since v2.9165 the Dashboard's My Time section has **Your bids today** for the pe
It is closed until pressed and reads the day when it opens, it shows for the roles that work on bids (`worksOnBids`), and only on the person's own section.
A salaried estimator, who has no clock out, keeps the day's list there.
Since v2.9194 the My Time day editor draws a day's kept list above its timeline (`my-time-day-editor/MyTimeDayBids.tsx`): the same sentence and labels, with no **Open the bid** (`noBidDoor`), and no read on a person's own day unless their role works on bids.
Since v2.9282 the Job Mode card's header counts the bids of the day so far while the clock is on the office job or on no job: **Bids · 3 ›** where the job's name was and *On JP000 · Office* under it (`lib/jobMode/jobModeBids.ts`, `hooks/useJobModeBids.ts`, `jobMode/JobModeBidsPress.tsx`, the person's answers of 2026-12-03).
That count is the clock out's own, the bids the person changed with a kept list winning, read from the person's own day for the roles that work on bids, and a day with no bid yet keeps the job's header.
A press on it opens **Your bids today** in a window, read when it opens, with **Keep my list · N bids** (`clock/BidDayKeepWindow.tsx`, the window *Done for the day* opens too).
An empty list names a typed note only on the clock out's sheet, and everywhere else it names the next press that is there (`bidDayEmptyWords`).

**Database**: `user_bid_activity`, `bid_day_entries`, `bump_user_bid_activity`, `get_my_bid_day`, `save_my_bid_day` · kernels `lib/bids/bidInFront.ts`, `lib/clock/bidDay.ts`, `lib/clock/bidDayLabels.ts` · hooks `useBidActivityBeat`, `useClockOutBidDay`, `useSessionsBidDay` · guides `/help/clock-out-with-the-bids-of-the-day`, `/help/approve-my-teams-hours`

Expand All @@ -4545,6 +4549,7 @@ A quick add and a rejected session are left out of the day, and a session still
On People → Hours the line sits beside the later session, measured in the active, pending and approved lists together, and a list sorted by length draws none.
Where the line does not sit between its two sessions, it leads with the person's name.
In the My Time day editor the strip between two groups of sessions reads the same words.
My time's week list draws no gap line, since it is one row a job for the week and holds no two sessions side by side (the person, 2026-12-03).

**Code**: kernel `lib/clock/sessionGaps.ts` · `components/clock-sessions/ClockSessionsTable.tsx` (`gapsAmong`) · `components/my-time-day-editor/MyTimeDayTimelineBody.tsx`

Expand Down
57 changes: 57 additions & 0 deletions docs/recent-features/v2.9282.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# v2.9282 — Job Mode: the card counts the bids of your day, and a press opens the list (2026-12-03)

Punch list #469, the Job Mode step. Client only. No migration, no function change, nothing owed on prod. It reads `get_my_bid_day` and writes through `save_my_bid_day`, both on prod since punch list #445.

## What was asked

The owner, 2026-12-02: a day spent on bids is to look like the bids worked on, not like the office job the clock was on. People → Hours reads a day's *kept* list for that. The card named the Job Mode card as the next place and drew nothing for it.

## The calls, and the person's answers (2026-12-03)

The *kept* rule would almost never change the Job Mode header: a list is kept at clock out, and after a clock out the card shows no session. So three calls were put, each with a pick.

- **What the header shows on the office job:** the bids of the day so far, from the person's own list, kept or not. The pick.
- **Which bids count:** the bids the person changed, with a kept list winning. The pick.
- **A press on it:** it opens the list in a window with **Keep my list**. The pick put was no press, and the person chose the press.

## What it does

- While the clock is on the office job, or on no job, and the person's role works on bids, the header reads **Bids · 3 ›** where the job's name was. The line under it reads *On JP000 · Office*, or *Clocked in with no job*.
- With no bid yet, on a job in the field, on a bid, or for a role that does not work on bids, the header is as it was.
- A press opens **Your bids today** over the card: the clock out's own list and strip, **Keep my list · N bids** and **Close**. It reads the day when it opens. It says *Reading your day…* while it reads, and says so when the day cannot be read.
- After the window closes the card reads its count again.

## How

- New kernel `src/lib/jobMode/jobModeBids.ts`: `jobModeBidsNeedsOffice`, `jobModeBidsAsked`, `bidsSoFar` (the clock out's own `keptCount`), `jobModeBidsHeader` (over `bidDayJobWords`) and the window's words.
- New hook `src/hooks/useJobModeBids.ts`: the office job's id once, then the person's own day. A read that fails leaves the job's header.
- New `src/components/jobMode/JobModeBidsPress.tsx`: the press, and the window over `useClockOutBidDay`.
- New `src/components/clock/BidDayKeepWindow.tsx`: the window *Done for the day* drew, lifted out so both doors use it, each with its own words. `DoneForTheDayBidDay.tsx` draws it now.
- `DashboardJobModeCard.tsx`: the hook, the header's first branch, and the window held by the card so a reload that redraws the header leaves it open.

## Chosen in the build, to be read by the owner

- **The count is as fresh as the card's last read.** It is read when the card draws, after a clock press and after the window closes. It does not tick while the card sits open.
- **The line *Not on today's schedule* stays** under the count where it stood under the office job.
- **A job whose papers are still owed keeps its masked header.**
- **The window takes the cursor when it opens and gives it back when it closes.** That holds for *Done for the day*'s window too, whose cursor the walker found outside it. Its two presses are 44 px tall now, up from 40.

## A words mend that rode with it

My time's **Your bids today** drew the clock out's empty words on a day with no bid: *Add the bids you worked on, or say what you did below.* Nothing is below on My time. The words are `bidDayEmptyWords` in `src/lib/clock/bidDay.ts` now. The clock out's sheet passes `noteBelow` and reads as it did. My time and the two windows name the next press that is there: tick an opened bid, add from the board, or *A bid you change on the Bids page today shows here.*

## Tests

- `jobModeBids.test.ts` (12 cases): when the day is read, what is counted, a kept list winning, the header's words.
- `DashboardJobModeCard.bids.render.test.tsx` (6 cases): the header on the office job and on no job, the window with its keep and its reread, the window's reading and not-read words, the job's own header on a day with no bid and on a failed read, and no read on a field job or for a role that does not work on bids.
- `bidDay.test.ts`: `bidDayEmptyWords`.
- `DoneForTheDayBidDay.render.test.tsx` passes unchanged over the shared window.
- Not seen in a browser: this thread signs in to nothing, and View as keeps no bid trace.

## Words

The guides `clock-out-with-the-bids-of-the-day` and `job-mode-clocking`. The glossary's *Bids of the day* and *Gap line*. The clock map. The cards `to-dos/bids-on-my-time/README.md` (the six answers and the looks) and `to-dos/clock-break/README.md` (the gap line on the week's list is closed, not drawn: the person's answer to call W3).

## The look owed

On the card under *The looks owed*. It needs a real sign-in as a ZZ Test person who works on bids, since View as keeps no bid trace: clock in on the office job with Job Mode on, change one thing on a ZZ Test bid, and the header reads *Bids · 1 ›*. The press opens the list, **Keep my list · 1 bid** keeps it, and **Close** gives the cursor back.
1 change: 1 addition & 0 deletions src/components/ClockInOutButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -732,10 +732,10 @@
}
})()
return () => {
assignedJobsFetchGenRef.current++

Check warning on line 735 in src/components/ClockInOutButton.tsx

View workflow job for this annotation

GitHub Actions / typecheck, lint and the checks

The ref value 'assignedJobsFetchGenRef.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy 'assignedJobsFetchGenRef.current' to a variable inside the effect, and use that variable in the cleanup function
}
// showToast via ref only — including showToast here caused a loop when any toast updated ToastProvider and gave consumers a new reference chain in some builds.
}, [

Check warning on line 738 in src/components/ClockInOutButton.tsx

View workflow job for this annotation

GitHub Actions / typecheck, lint and the checks

React Hook useEffect has a missing dependency: 'openSession'. Either include it or remove the dependency array
clockInModalOpen,
updateFocusModalOpen,
clockOutReviewOpen,
Expand Down Expand Up @@ -801,7 +801,7 @@
}
})()
return () => {
missingReportsFetchGenRef.current++

Check warning on line 804 in src/components/ClockInOutButton.tsx

View workflow job for this annotation

GitHub Actions / typecheck, lint and the checks

The ref value 'missingReportsFetchGenRef.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy 'missingReportsFetchGenRef.current' to a variable inside the effect, and use that variable in the cleanup function
}
}, [
clockOutReviewOpen,
Expand Down Expand Up @@ -1093,7 +1093,7 @@
return () => {
cancelled = true
}
}, [

Check warning on line 1096 in src/components/ClockInOutButton.tsx

View workflow job for this annotation

GitHub Actions / typecheck, lint and the checks

React Hook useEffect has a missing dependency: 'openSession'. Either include it or remove the dependency array
clockOutReviewOpen,
updateFocusModalOpen,
openSession?.id,
Expand Down Expand Up @@ -2620,6 +2620,7 @@
list={bidDay.list}
board={bidDay.board}
disabled={clockOutSaving}
noteBelow
onToggle={bidDay.toggle}
onAddFromBoard={(bidId) => {
const pick = workingBoardBidPicks.find((b) => b.id === bidId)
Expand Down
160 changes: 160 additions & 0 deletions src/components/clock/BidDayKeepWindow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/**
* The day's list of bids in a window, with one press that keeps it. Two doors open it: *Done for the day* after a
* break (punch list #473, `DoneForTheDayBidDay`) and the Job Mode header's count (punch list #469,
* `JobModeBidsPress`). Each hands in its own words and its own read of the day. The list is the clock out's own
* (`ClockOutBidDay`), and the save is `save_my_bid_day`.
*
* The window takes the cursor when it opens and gives it back to where it was when it closes.
*/
import { useEffect, useRef, useState, type CSSProperties } from 'react'
import { createPortal } from 'react-dom'
import ClockOutBidDay from './ClockOutBidDay'
import type { BidDayPick, ClockOutBidDay as BidDay } from '../../hooks/useClockOutBidDay'
import { useToastContext } from '../../contexts/ToastContext'
import { useModalStackEntry } from '../../hooks/useModalStackEntry'
import { saveMyBidDay } from '../../lib/clock/bidDayIo'
import { DEAD_PRESS_FILL, DEAD_PRESS_TEXT } from '../../lib/deadPress'
import { formatErrorMessage } from '../../utils/errorHandling'

const GREEN = '#15803d'
const btn: CSSProperties = {
minHeight: 44,
padding: '0 0.85rem',
borderRadius: 8,
borderWidth: 1,
borderStyle: 'solid',
borderColor: 'var(--border-strong)',
background: 'var(--surface)',
color: 'var(--text-strong)',
fontFamily: 'inherit',
fontSize: '0.875rem',
fontWeight: 600,
cursor: 'pointer',
}
const muted: CSSProperties = { margin: 0, fontSize: '0.8125rem', color: 'var(--text-muted)' }

export type BidDayKeepWindowWords = {
title: string
lead: string
officeWords: string
closeLabel: string
keepingLabel: string
keepLabel: (kept: number) => string
keptToast: (kept: number) => string
notKeptLead: string
/** A last quiet line, or '' for none. */
later: string
}

type Props = {
words: BidDayKeepWindowWords
bidDay: BidDay
boardPicks: readonly BidDayPick[]
/** Words drawn in place of the list while there is no list to draw: the day being read, or not read. */
inPlaceOfList?: string | null
/** The window's own test id; its two presses take `-keep` and `-close` after it. */
testId: string
/** The list was kept, with how many bids. The window closes after it. */
onKept?: (kept: number) => void
onClose: () => void
}

export function BidDayKeepWindow({ words, bidDay, boardPicks, inPlaceOfList = null, testId, onKept, onClose }: Props) {
const { showToast } = useToastContext()
const [saving, setSaving] = useState(false)
const hasList = !inPlaceOfList
const canKeep = hasList && bidDay.list.worked.length > 0 && !saving

// The cursor goes into the window, and back to the press that opened it.
const windowRef = useRef<HTMLDivElement | null>(null)
useEffect(() => {
const before = document.activeElement instanceof HTMLElement ? document.activeElement : null
windowRef.current?.focus()
return () => {
if (before && before.isConnected) before.focus()
}
}, [])

// Escape closes the window; a window opened over it keeps the press for itself.
const isTopmost = useModalStackEntry()
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
if (e.key !== 'Escape' || e.defaultPrevented || !isTopmost()) return
e.preventDefault()
e.stopPropagation()
if (!saving) onClose()
}
window.addEventListener('keydown', onKey, true)
return () => window.removeEventListener('keydown', onKey, true)
}, [onClose, isTopmost, saving])

const keep = async () => {
if (!canKeep) return
setSaving(true)
try {
const kept = await saveMyBidDay(bidDay.workDate, bidDay.entries())
showToast(words.keptToast(kept), 'success')
onKept?.(kept)
onClose()
} catch (e) {
// The window stays: the person can press again, or close it and keep the list later.
showToast(`${words.notKeptLead}: ${formatErrorMessage(e, 'the save did not go through')}`, 'error')
setSaving(false)
}
}

return createPortal(
<div
style={{ position: 'fixed', inset: 0, zIndex: 720, background: 'rgba(0,0,0,0.5)', display: 'flex', alignItems: 'flex-start', justifyContent: 'center', padding: 'calc(4vh + var(--app-top-chrome, 0px)) 0.75rem 4vh', overflowY: 'auto' }}
onClick={(e) => {
if (e.target === e.currentTarget && !saving) onClose()
}}
>
<div
ref={windowRef}
tabIndex={-1}
role="dialog"
aria-modal="true"
aria-label={words.title}
data-testid={testId}
style={{ width: 'min(560px, 100%)', background: 'var(--surface)', color: 'var(--text-strong)', border: '1px solid var(--border)', borderRadius: 12, padding: '1rem', display: 'grid', gap: '0.6rem', boxShadow: '0 12px 32px rgba(0,0,0,0.25)', outline: 'none' }}
>
<h2 style={{ margin: 0, fontSize: '1.05rem' }}>{words.title}</h2>
<p style={{ margin: 0, fontSize: '0.875rem' }}>{words.lead}</p>
{hasList ? (
<ClockOutBidDay
list={bidDay.list}
board={bidDay.board}
disabled={saving}
onToggle={bidDay.toggle}
onAddFromBoard={(bidId) => {
const pick = boardPicks.find((b) => b.id === bidId)
if (pick) bidDay.add(pick)
}}
/>
) : (
<p role="status" style={{ ...muted, fontSize: '0.875rem' }}>
{inPlaceOfList}
</p>
)}
<p style={muted}>{words.officeWords}</p>
<div style={{ display: 'flex', gap: '0.5rem', flexWrap: 'wrap', alignItems: 'center' }}>
<button
type="button"
disabled={!canKeep}
onClick={() => void keep()}
style={{ ...btn, background: canKeep ? GREEN : DEAD_PRESS_FILL, borderColor: canKeep ? GREEN : DEAD_PRESS_FILL, color: canKeep ? '#ffffff' : DEAD_PRESS_TEXT, cursor: canKeep ? 'pointer' : 'default' }}
data-testid={`${testId}-keep`}
>
{saving ? words.keepingLabel : words.keepLabel(hasList ? bidDay.list.keptCount : 0)}
</button>
<button type="button" disabled={saving} onClick={onClose} style={btn} data-testid={`${testId}-close`}>
{words.closeLabel}
</button>
</div>
{words.later ? <p style={muted}>{words.later}</p> : null}
</div>
</div>,
document.body,
)
}
Loading
Loading