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
112 changes: 112 additions & 0 deletions docs/TASKS-archive.md

Large diffs are not rendered by default.

128 changes: 23 additions & 105 deletions docs/TASKS.md

Large diffs are not rendered by default.

476 changes: 476 additions & 0 deletions e2e/note-human-gestures.spec.ts

Large diffs are not rendered by default.

95 changes: 95 additions & 0 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,76 @@ html:is([data-chrome="awake"]:not(:where([data-panel="closed"])), :where([data-p
display: none;
}

/* Folded (T-107): the bubble goes, but the note does not vanish. What is left
is a chip carrying the source's own colour and the first word — small enough
to see the map past, big enough to click, which is the whole fix: folding
used to leave a 9px anchor whose only answer was "open the card about me". */
.pin-chip {
display: none;
align-items: center;
gap: 5px;
padding: 3px 8px 3px 6px;
border-radius: 999px;
background: var(--glass-strong);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid rgba(45, 212, 191, 0.4);
box-shadow: 0 6px 16px rgba(3, 7, 13, 0.4);
max-width: 150px;
}
.note-pin[data-annotation-source="user"] .pin-chip {
border-color: rgba(244, 143, 177, 0.45);
}
.note-pin[data-folded="true"] .pin-chip {
display: inline-flex;
}
.pin-chip-dot {
width: 6px;
height: 6px;
border-radius: 50%;
flex-shrink: 0;
background: var(--agent);
}
.note-pin[data-annotation-source="user"] .pin-chip-dot {
background: var(--human);
}
.pin-chip-label {
font-size: 10.5px;
line-height: 1.2;
color: var(--text-mid);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

/* The provisional pin (T-106): where the note in the popover would land. A
dashed rose ring on a dashed stem — hollow because it is not a note yet, and
click-through because the next click on the map is how it moves. */
.note-draft-pin {
display: flex;
flex-direction: column;
align-items: center;
pointer-events: none;
}
.note-draft-pin .draft-stem {
width: 1.5px;
height: 13px;
background: repeating-linear-gradient(
to bottom,
var(--human) 0 3px,
transparent 3px 6px
);
}
.note-draft-pin .draft-anchor {
width: 11px;
height: 11px;
border-radius: 50%;
background: transparent;
border: 1.6px dashed var(--human);
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
transform: translateY(-2px);
}

/* ---------------------------------------------------- inspector */
.grab {
display: none;
Expand Down Expand Up @@ -1965,6 +2035,31 @@ html:is([data-chrome="awake"]:not(:where([data-panel="closed"])), :where([data-p
font-weight: 650;
line-height: 1.35;
}
/* A note's headline is the note (T-108), so it wraps instead of being clipped:
this card is the only surface that carries every character of one, and the
card measures its own height, so a long note makes a taller card rather than
a truncated one. `anywhere` because a note may be one unbroken string — a URL,
or a language that does not space its words; `pre-wrap` because a note may
carry its own line breaks and they are the writer's.

Bounded, though: `annotate` accepts 500 characters and every one of them may
be a newline, which is 250 lines of card. Above 640px that would run off the
top of the map; below it the card is `position: fixed` against the bottom bar
and could not be scrolled back into view at all. A scrollbar keeps the whole
note reachable on every tier, and 25vh is what makes the card placeable: the
rest of the card measures ~115px, and `cardPlacement` can only ever guarantee
a side that fits while the whole card is shorter than half the viewport minus
its margins. Measured at 1440x900 with 500 newline characters: 225px of note,
340px of card, which fits above a tap in the middle of the map — at 40vh the
same card was 475px, fitted on neither side, and hung its Remove/Keep buttons
41px below the fold. */
.otm-card[data-kind="annotation"] .otm-name {
font-weight: 600;
white-space: pre-wrap;
overflow-wrap: anywhere;
max-height: 25vh;
overflow-y: auto;
}
.otm-cat {
margin-top: 3px;
display: flex;
Expand Down
46 changes: 41 additions & 5 deletions src/components/AddNoteForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ACTIVITY_NOTE_CHARS } from "@/lib/map-tools/activity";
import { truncate } from "@/lib/map-tools/shapes";
import { useMapStore } from "@/lib/store/map-store";
import { emitHumanFx } from "./fx/human-events";
import { useNoteStore } from "./note-store";

/** ~1 m, the same precision the tools report coordinates in. */
const round5 = (n: number) => Math.round(n * 1e5) / 1e5;
Expand All @@ -22,6 +23,16 @@ const round5 = (n: number) => Math.round(n * 1e5) / 1e5;
* written to the store and echoed in `add-note-status`, which is also what an
* agent reads back after submitting.
*
* **Where the note lands depends on who submitted it** (T-106). An agent has no
* cursor, so an agent's submit pins at `view.center` — the place the tool has
* always named and the place its description still names. A person has one:
* while this popover is open, a click on the map places a provisional pin
* (`note-store.ts`, drawn by MapCanvas) and their submit pins there. Without a
* click a person gets the centre too, which is the behaviour this form shipped
* with — panning the map until the spot sits under an invisible crosshair is
* now the fallback rather than the only way. `add-note-target` reports which of
* the two is armed, and the status line names the coordinates actually used.
*
* Who gets credit for the note comes from `SubmitEvent.agentInvoked`, the
* spec's own discriminator. Without a WebMCP client there is no such flag and
* the note is stored as `source: "user"` - the honest default for a form a
Expand All @@ -43,6 +54,7 @@ const round5 = (n: number) => Math.round(n * 1e5) / 1e5;
*/
export function AddNoteForm({ focusable = true }: { focusable?: boolean }) {
const [status, setStatus] = useState("");
const draft = useNoteStore((s) => s.draft);

const onSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
Expand All @@ -55,9 +67,16 @@ export function AddNoteForm({ focusable = true }: { focusable?: boolean }) {
}
const { view, addAnnotation, recordActivity } = useMapStore.getState();
const agentInvoked = (event.nativeEvent as SubmitEvent).agentInvoked === true;
// The draft is a person's answer to "where", so only a person's submit
// reads it: `add_note` promises an agent the map centre, and an agent that
// submits while a human has a pin half-placed must still get the place the
// tool description names. Read from the store rather than from the
// subscribed value, so a click that lands in the same tick as the submit
// cannot pin the note at the place before it.
const at = agentInvoked ? view.center : (useNoteStore.getState().draft ?? view.center);
const stored = addAnnotation({
source: agentInvoked ? "agent" : "user",
at: view.center,
at,
note,
});
// An agent-submitted form is a tool call like any other, and the activity
Expand All @@ -79,10 +98,14 @@ export function AddNoteForm({ focusable = true }: { focusable?: boolean }) {
// drives its (teal) effect.
emitHumanFx({ type: "note", annotation: stored });
}
setStatus(
`Pinned ${stored.id} at ${round5(view.center[0])}, ${round5(view.center[1])}.`,
);
setStatus(`Pinned ${stored.id} at ${round5(at[0])}, ${round5(at[1])}.`);
form.reset();
// The place is spent with the note a person pinned: the next one starts
// unplaced rather than stacking silently on the last one's pin. An agent's
// submit never touches it - the draft belongs to the human who clicked it,
// and a tool call arriving mid-sentence must not take their pin off the map
// (it did not use it either: an agent pins at the centre).
if (!agentInvoked) useNoteStore.getState().clearDraft();
};

return (
Expand All @@ -94,7 +117,14 @@ export function AddNoteForm({ focusable = true }: { focusable?: boolean }) {
onSubmit={onSubmit}
className="note-form"
>
<label htmlFor="add-note-input">Pin a note at the map centre</label>
{/* The visible instruction follows the state; the `tooldescription` and
`toolparamdescription` around it do not, because they are the agent's
contract and an agent's note still goes to the centre. */}
<label htmlFor="add-note-input">
{draft
? "Pin a note where you clicked"
: "Click the map to place a note, or pin it at the centre"}
</label>
<div className="note-form-row">
<input
id="add-note-input"
Expand All @@ -118,6 +148,12 @@ export function AddNoteForm({ focusable = true }: { focusable?: boolean }) {
<p data-testid="add-note-status" className="note-status" aria-live="polite">
{status}
</p>
{/* Off screen: which of the two places the next human submit will use,
without reading a CSS class or measuring a marker. The draft's own
numbers are already rounded to ~1 m by the store that holds them. */}
<span data-testid="add-note-target" className="gm-machine">
{draft ? `${draft[0]}, ${draft[1]}` : "centre"}
</span>
</form>
);
}
Loading
Loading