mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
* iOS: delete after an autocorrection takes only its space, and the strip offers what you typed
X tester Brandon McConnell (and a TestFlight tester about text replacements, fixed in
uncorrected version." Apple's keyboard doesn't (black box, iOS 27.2 simulator, a
UITextView): after "becuase " became "Because ", delete took only the space and the text
view showed "Becuase" with an undo arrow; space then kept "Because ", a letter continued
the word, a second delete took a letter, a comma went like a space, tapping the bubble put
"Becuase" back without the space, and deleting back to the word later brought the bubble
back. Revisions ("well see " -> "We'll see ", bubble "Well see") and splits ("ofthe" ->
"Of the", bubble "Ofthe") work the same.
Removed: Hex's deliberate "one backspace undoes the correction" (FullKeyboardEngine.
deleteBackward's undo branch and AutocorrectEngine's pending undo, consumed by the next
delete). Replaced by:
- AutocorrectEngine.lastCorrection keeps the latest autocorrection with what was typed,
what went in and an anchor (the text before the cursor right after it); it is offered
while the text before the cursor reads that again (its last 64 characters for long
text), and forgotten on a new field, a new language or a newer correction. The many
clearPendingUndo calls after other input are gone: the anchor check covers them.
- KeyboardSuggestion.Kind.revert: the strip's left slot shows it in place of the word as
it reads, pill-highlighted with Apple's undo arrow (a keyboard can't draw a bubble in
the host's text). Tapping it puts back what was typed, suppresses the fix for the
session, and counts as an undone autocorrection for Learn how I type and Adaptive touch
(whose word taps the delete of the space now keeps for it). Typing logs: autocorrect_undo
with src strip, context why revert.
- Merges, splits and #2144's revisions go through the same record.
- deleteBackward's allowAutocorrectUndo is now takesSwipeBack: it only gates a swipe's
whole-word delete, which stays.
Verified on the Studio (iPhone 17, iOS 27.2 simulator): AutocorrectEngineTests,
FullKeyboardEngineTests and TypingLogTests pass (updated: the keep loop, the revision,
the edge-space join, punctuation and Adaptive touch tests now revert from the strip; new:
testDeleteAfterAnAutocorrectionTakesOnlyItsSpaceAsOnApplesKeyboard with the black-box
cases).
* iOS: smart quotes and dashes as the system keyboard types them, per language
X tester Brandon McConnell: "no smart quotes/etc." Hex typed straight quotes and two
hyphens everywhere. Apple's keyboard (black box, iOS 27.2 simulator, a UITextView with
each trait on and off, a text field, Messages, and 15 of its keyboards):
- ' and " open at the start, after a space or new line, a bracket or an opening quote,
and close elsewhere: 'hi' it's "yes" ("ok") 5'9" became ‘Hi’ it’s “yes” (“ok”) 5’9”.
- A second hyphen makes an em dash (a--b is a—b, a third stays a hyphen, delete takes
the dash whole); " - " stays.
- Autocorrect's apostrophes are ’ (Don’t, I’ll), and the strip shows I’m.
- smartQuotesType or smartDashesType .no turns each off; Messages' composer types
straight quotes and -- (both off there).
- Quotes per keyboard: „ “ ‚ ‘ in German and Swiss German (the apostrophe key types ‘
even inside a word), « » with no-break spaces inside in French, Canadian and Swiss
French, „ ” ‚ ’ in Polish, « » in Norwegian, Russian and Ukrainian, “ ” ‘ ’ in English,
Spanish, Italian, Portuguese and Romanian. Serbian (no simulator keyboard) gets the
English ones.
- smartInsertDeleteType changed nothing it types: after a picked suggestion, , . ! ? ;
: ) took the suggestion's space ("Hello,") with it on or off; " ( @ kept it, and so did
a space typed by hand ("Hello .").
Hex now does the same:
- SmartPunctuation.swift: SmartQuotes per KeyboardLanguage, curled() for typed keys and
for autocorrect, suggestion, swipe and revert text, the em dash in typeIntoField, and
the strip's apostrophes (displayed). Accent picks, emoji and text replacements go in as
they are. KeyboardTextTarget gains smartQuotesType and smartDashesType (the proxy's;
nil, off, for fixtures); .default counts as on, Smart Punctuation's default, which a
keyboard can't read.
- The keys still reason with straight quotes: FullKeyboardEngine reads textBefore, the
field's text with curly quotes made straight one for one (SmartPunctuation.plain), so
tokens, revisions, reverts and swipes keep matching what they typed.
- dropsSuggestionSpace: , . ! ? ; : ) right after a picked suggestion delete its space.
- AutocorrectEngine.midSentenceMarks gains ' (what ’ reads as now).
Verified on the Studio (iPhone 17, iOS 27.2 simulator): AutocorrectEngineTests,
FullKeyboardEngineTests, TypingLogTests and EmojiSuggesterTests pass, with new
testSmartQuotesAndDashesFollowTheFieldAsOnApplesKeyboard, testSmartQuotesFollowTheKeysLanguage
and testMarksGoAgainstAPickedSuggestion. Live in the simulator's HEXKeyboard (Release, App
Group) in a UITextView host: 'hi' it's "yes" well--known dont typed ‘hi’ it’s “yes”
well—known don’t, straight quotes with smartQuotesType .no, well--known with smartDashesType
.no, and the strip showed I’m.
* iOS: the space-bar trackpad moves up and down lines, as the system keyboard's does
X tester Brandon McConnell: "holding down on the space bar only allows scrubbing
horizontally, whereas Apple's keyboard treats it like a cursor on both x/y axes".
Apple's (black box, iOS 27.2 simulator, iPhone 17, a UITextView with 17 pt text and
20.3 pt lines, the caret read back from the host): after the hold, the caret moved a line
every 15 to 16 pt of finger travel up or down, the first after about 8 (crossings at 9,
24, 39, 54, 72 and 87 pt both ways), kept its x, and stayed on the first or last line
past them; in a wrapped paragraph it moved by a wrapped line (about 43 characters in a
360 pt line). Along a line it moved about a character per 6 pt and stopped at the line's
ends.
A keyboard can only move the cursor by characters (adjustTextPosition), so
TrackpadCursor works out the line before or after from the text the field shares around
the cursor: lines split at new lines and every lineLength characters (the keyboard's
width less 40 pt, at 8.2 pt a character, as the field's width and font can't be read),
at the same column, kept across short lines until a move along the line. Vertical steps
are trackpadPointsPerLine (15.5 pt), the first half as far; past the first or last line
the cursor stays and coming back moves it at once. Horizontal movement is unchanged (7.5 pt
a character, crossing line ends as before).
The host's context lags the moves: in the simulator a second line up read the text from
before the first, and after a move the host shared only the cursor's own line. So each
gesture keeps a copy of the text (TrackpadCursor.State) and adds the host's context once it
has caught up (it reads the same either side of the cursor). Lines the host never shares
stay out of reach. KeyboardTextTarget gains documentContextAfterInput.
Not done: Apple's tap with a second finger while holding space starts a selection. The
iOS 27.2 SDK's UITextDocumentProxy has documentContextBeforeInput/AfterInput, selectedText
(read-only), documentInputMode, documentIdentifier, adjustTextPosition(byCharacterOffset:),
setMarkedText(_:selectedRange:) and unmarkText, and UIInputViewController nothing more: no
public API makes or extends a selection, and marked text would type provisional text into
the field, so Hex doesn't fake it.
TrackpadCursor is surface-independent so the dictation bar's trackpad (#2180) can use it
too; it isn't wired there here.
Verified on the Studio (iPhone 17, iOS 27.2 simulator): FullKeyboardEngineTests (new
testTheSpaceBarTrackpadMovesUpAndDownLines), AutocorrectEngineTests and EmojiSuggesterTests
pass. Live in the simulator's HEXKeyboard (Release) in a UITextView with four lines: from
the end, holding space and sliding up moved the cursor 88 -> 64 -> 41 -> 20 (each line up,
same column), further up kept it on the first line, and sliding back down returned it 41 ->
64 -> 88; nothing was typed.
* iOS: key clicks: the keyboard's input view adopts UIInputViewAudioFeedback
TestFlight: "Cannot hear the iOS typing sound when using your keyboard. Need the clicky
sound for my dopamine pls."
Hex already called UIDevice.playInputClick() on every key's touch-down, but the
UIInputViewAudioFeedback conformance sat on FullKeyboardView, a subview; UIKit plays the
click only for the input view itself. In the iOS 27.2 simulator's keyboard log, typing
"abc" and a delete reached AudioServices' system sound 1104 0 times with the old view and
4 times (one per press) with the new one.
- KeyboardInputView (HEXKeyboard): a UIInputView adopting UIInputViewAudioFeedback, with
enableInputClicksWhenVisible true. KeyboardViewController.loadView keeps UIKit's own input
view's style, size and sizing flags but makes it this class; nothing else in the
controller's lifecycle changes.
- Removed: FullKeyboardView's UIInputViewAudioFeedback conformance, which did nothing.
keyFeedback plays the click first, through a playInputClick seam tests count.
- The dictation bar's key feedback clicks too.
- One click for every key (delete, shift, 123 and return included, and each delete repeat):
Apple's keyboard plays other sounds for delete and the modifier keys, but the click is the
only keyboard sound the API offers a keyboard.
- No setting: the click follows Settings › Sounds & Haptics › Keyboard Feedback › Sound
(in the simulator, keyboard-audio NO in com.apple.preferences.sounds made it play none).
Apple's custom keyboard guide lists playing keyboard clicks among the things that need
open access; the simulator played it with the keyboard's Full Access rows removed too, so
Hex calls it either way and iOS decides.
Verified on the Studio (iPhone 17, iOS 27.2 simulator): FullKeyboardEngineTests (new
testEveryKeyClicksOnTouchDown) and HexKeyGestureTests pass; the Release HEXKeyboard
launched, laid out and typed as before in a UITextView host, with the click counts above.
A real iPhone must confirm the sound itself, with Full Access on and off.
291 lines
16 KiB
Markdown
291 lines
16 KiB
Markdown
# Typing logs (Record typing logs)
|
||
|
||
Settings › Privacy › Advanced › **Record typing logs** (off by default, asks for
|
||
consent in a dialog before it turns on, App Group key
|
||
`experiments.typingLogs`) makes Hex's keyboard write raw logs of everything it
|
||
sees: every touch with its position and timing, the key it pressed, what that
|
||
did to the text, the text around the cursor, and dictations. They are for
|
||
testing and training keyboard prediction and per-user touch models on a Mac.
|
||
Nothing is sent anywhere; Privacy › Advanced › Typing logs shares a day's file (or
|
||
all of them) through the share sheet, for example by AirDrop.
|
||
|
||
It is separate from Learn how I type, which keeps only word pairs and per-key
|
||
averages and is unchanged.
|
||
|
||
## Files
|
||
|
||
- `TypingLogs/yyyy-MM-dd.ndjson` in the App Group container
|
||
(`group.anomaly.hex.mobile`), one per local day (Gregorian date in the
|
||
iPhone's time zone). Each event goes to the file of the day its `t` falls in.
|
||
- NDJSON: one JSON object per line, UTF-8, `\n` after every line.
|
||
- Kept 14 days (today and the 13 before). Older files are deleted when the
|
||
keyboard starts a logger and when the Typing logs screen opens.
|
||
- At most 64 MB a day. The first event that would cross the cap is replaced by
|
||
one `cap_reached` line and nothing more is written that day.
|
||
- The keyboard writes nothing without Full Access (it can't reach the App Group)
|
||
and nothing while the experiment is off. The app's keyboard preview and
|
||
simulator fixtures never write logs.
|
||
|
||
Writing: events are appended to an in-memory buffer on the main thread and
|
||
handed to one serial utility queue every 2 s (and when the keyboard goes away,
|
||
on a memory warning, and at 1,500 buffered events), which encodes them and
|
||
appends them with `FileHandle`. Lines from one session are in order; a session
|
||
ends with `session_end` unless the keyboard process was killed first.
|
||
|
||
## Common fields
|
||
|
||
Every line starts with these, in this order:
|
||
|
||
| key | type | meaning |
|
||
| --- | --- | --- |
|
||
| `v` | int | Schema version, `1`. |
|
||
| `t` | int | Wall clock, ms since 1970 (UTC). |
|
||
| `mt` | number | Monotonic ms (`CACurrentMediaTime`, time since boot without sleep). Use it for intervals; `UITouch.timestamp` (`ts`) is on the same clock. |
|
||
| `type` | string | Event type, below. |
|
||
| `session` | string | 12 hex digits, new each time the keyboard appears or moves to another field. |
|
||
| `seq` | int | 1, 2, 3… within a session. A gap means lines were lost (only the cap does that). |
|
||
|
||
Units and spaces:
|
||
|
||
- Positions and sizes are points in the keyboard view's coordinates: origin at
|
||
the top-left of Hex's keyboard view (the suggestion strip's top edge), x to
|
||
the right, y down. The strip is `y` 0–44 in portrait, the keys below it.
|
||
- A rect is `[x, y, width, height]`. Insets are `[top, left, bottom, right]`.
|
||
Points have 2 decimals, ms 3.
|
||
- Character counts are Swift `Character`s (grapheme clusters), what one
|
||
backspace removes.
|
||
- A key id is the character itself for character keys (always one character:
|
||
`"a"`, `"7"`, `"@"`; letters lowercase) and a word for the others: `shift`,
|
||
`delete`, `space`, `return`, `hex`, `globe`, `layer:numbers`,
|
||
`layer:symbols`, `layer:letters`.
|
||
|
||
## Events
|
||
|
||
### `session_start`
|
||
|
||
The keyboard appeared (`trigger`: `appear`), the field changed while it showed
|
||
(`field`), or the experiment was turned on while it showed (`enabled`).
|
||
|
||
- `surface`: `full` (Hex's keys) or `bar` (the dictation bar; no touches).
|
||
- `document`: `UITextDocumentProxy.documentIdentifier`, which changes with the
|
||
field. The host app is not knowable from a keyboard and is never guessed.
|
||
- `traits`: `keyboardType`, `returnKeyType`, `autocapitalization`,
|
||
`autocorrection`, `spellChecking`, `smartQuotes`, `smartDashes`,
|
||
`smartInsertDelete`, `inlinePrediction`, `keyboardAppearance` (UIKit case
|
||
names, e.g. `"emailAddress"`, `"send"`, `"no"`), `textContentType` (its raw
|
||
value or null), `secure`, `enablesReturnKeyAutomatically`.
|
||
- `bounds` `[w, h]` and `safeArea` of the keyboard's root view when the session
|
||
started (may be before layout; `layout` lines carry the real size),
|
||
`orientation` (`portrait`/`landscape`), `appearance` (`light`/`dark`).
|
||
- `device` (`iPhone17,1`; `Simulator:…` in the simulator), `system`
|
||
(`iOS 26.1`), `version` and `build` of Hex, `locale`, `languages` (first
|
||
four preferred), `keyboardLanguage` (the keyboard's `primaryLanguage`),
|
||
`inputMode` (the field's input mode language), `fullAccess`.
|
||
- `settings`: `autocorrect` (Hex's), `spatialAutocorrect`, `key_popups`, `haptics`, `learnHowIType`, `cleanupTagger`,
|
||
`hexKeyPlacement`, `dictationLanguage` (BCP 47, or `automatic`), `keyboardLayout`
|
||
(`en`/`nb`/`es`/`de`, empty for the dictation bar), `style` (dictation style).
|
||
|
||
A `context` line follows at once with the text already in the field.
|
||
|
||
### `skipped`
|
||
|
||
Instead of `session_start` in a field that must not be logged; nothing else is
|
||
written for that session, not even `session_end`. `reason` is
|
||
`secureTextEntry` or `textContentType:<raw value>` for `password`,
|
||
`newPassword`, `oneTimeCode` and every `creditCard…` content type. Also
|
||
`trigger`, `surface`, `keyboardType`, `textContentType`, `secure`. Every other
|
||
field is logged, including ones with autocorrection off.
|
||
|
||
### `session_end`
|
||
|
||
`reason`: `disappear`, `field_changed`, `disabled`, or `replaced`.
|
||
`durationMS`, and counts of `touches` (began), `edits`, `dictations`. A
|
||
`context` line (when the text changed since the last one) and any unwritten
|
||
`candidates` come just before it.
|
||
|
||
### `layout`
|
||
|
||
Written when the key layout or shift changes, and when a session starts.
|
||
|
||
- `hash`: 16 hex digits over every key's id, frame and hit frame and the strip.
|
||
Touches name it in `layout`.
|
||
- `cause`: `session`, `field`, `layout` (width, orientation, globe), `geometry`
|
||
(view size or safe area only), `layer_key` (123/#+=/ABC pressed),
|
||
`layer_auto` (space or return went back to letters), `layer_slide` (hold 123,
|
||
slide, let go), `shift_key`, `typed` (a one-shot shift turned off), `auto`
|
||
(auto-capitalization), `cancel`, `language` (the keyboard layout changed),
|
||
`letters` (its letters' arrangement changed).
|
||
- `layer` (`letters`/`numbers`/`symbols`), `shift` (`off`/`on`/`locked`),
|
||
`shiftHeld` (only when true), `field` (`text`/`url`/`email`), `orientation`,
|
||
`width`, `height` (the keys' layout), `view` `[w, h]`, `safeArea`,
|
||
`horizontalInset` (landscape), `globe`, `hexPlacement`, `language`
|
||
(`en`/`nb`/`es`/`de`), `letters` (`own`/`qwerty`/`qwertz`/`azerty`/`dvorak`,
|
||
Settings › Keyboard › Languages › Layout).
|
||
- The first time a hash appears in a day's file the line also has:
|
||
- `letterWidth` (a 10-key row's; 11-key Norwegian and German letters are
|
||
narrower, see `keys`), `metrics` (`side`, `gap`, `rowGap`, `keyHeight`,
|
||
`stripHeight`, `keysBottom`, `cornerRadius`),
|
||
- `strip`: the suggestion strip's rect, and `slots`: its three suggestion
|
||
slots (left, centre, right),
|
||
- `keys`: `[{id, label, row, frame, hitFrame}]`. `frame` is the drawn keycap,
|
||
`hitFrame` the touch target; hit frames tile the key area (row 0 to 3) with
|
||
no gaps. The Hex key in the strip has row `-1`.
|
||
|
||
Later lines with the same hash in that file say `"repeat": true` instead, so
|
||
look the keys up by hash. Every touch's hash appears in full earlier in the
|
||
same file.
|
||
|
||
### `touch`
|
||
|
||
One finger sample on the keys (not the strip, whose buttons log `ui`/`edit`).
|
||
|
||
- `phase`: `began`, `moved`, `ended`, `cancelled`. `id`: the finger, stable
|
||
from began to ended.
|
||
- `x`, `y`: the raw touch location. `r`: `majorRadius`, `rt`:
|
||
`majorRadiusTolerance` (pt). `force` and `maxForce` only on devices with
|
||
force. `ts`: `UITouch.timestamp` in ms (monotonic, same clock as `mt`).
|
||
- `layout`: the layout hash at the time.
|
||
- `key`: the key the engine resolves. For `began`, the key the engine presses:
|
||
the key under the point, or a neighbouring letter the next-letter odds gave it
|
||
(`FullKeyboardEngine.letterOdds`). For `moved` and `ended`, the key the finger is held
|
||
on: sliding across character keys moves it; any other key keeps the key it
|
||
went down on. `null` when the finger went down outside every key.
|
||
- `under`: the key under the raw point when it differs from `key` (`null`:
|
||
outside every key, on `began`/`ended`/`cancelled`). On `began` it appears
|
||
only when the next-letter odds moved the press to a neighbouring letter, or
|
||
(`null`) when a finger on the strip's lower half while typing went to the row-1
|
||
key below it (`FullKeyboardEngine.takesStripTouch`; `y` is then above the
|
||
keys); otherwise the engine uses the hit frames as logged, so `key` on
|
||
`began` is the key under the point.
|
||
- `moved` is throttled: a sample is written once the finger has moved at least
|
||
2 pt and 8 ms since the last line for it, or when it slides onto another key.
|
||
|
||
Order: `began` and `ended` lines come before the edits they cause (a character
|
||
types on release; delete and shift act on press; a press commits the
|
||
characters of fingers still down, which is rollover). A `moved` line comes
|
||
after what the move did (trackpad cursor steps, accent selection).
|
||
|
||
### `edit`
|
||
|
||
What the keys did to the text, with `op`. To rebuild the text before the
|
||
cursor, for every `edit` (and `dictation`) line remove `deleted` (a string;
|
||
`deletedCount` characters when the text wasn't known) from the end, then append
|
||
`inserted`. `cursor` moves need the `context` lines to resync.
|
||
|
||
| `op` | fields |
|
||
| --- | --- |
|
||
| `insert` | `inserted`, `src`: `key` (a character or space), `accent` (long-press pick), `slide` (hold 123, slide, let go), `bar` (the dictation bar's space) |
|
||
| `delete` | `deleted` (the character), `src`: `key` (on press), `repeat` (held, 75 ms), `repeat_fast` (after 0.85 s, two at a time), `bar` |
|
||
| `delete_word` | `deleted`, `src`: `repeat_word` (held past 1.4 s) |
|
||
| `autocorrect` | `from`, `to`, `deleted` (= `from`), `inserted` (`to` + space). Applied on space. |
|
||
| `autocorrect_undo` | `deleted` (the correction, without its space or mark), `inserted` (what was typed), `src`: `strip`. The strip's revert, offered once delete took the correction's space or mark (or the cursor came back to its end), put back what was typed. |
|
||
| `suggestion` | `slot` (0 left, 1 centre, 2 right), `text` (as shown), `deleted` (the word being typed), `inserted` (the replacement + space), `candidates` (as in `candidates`) |
|
||
| `double_space_period` | `deleted`: `" "`, `inserted`: `". "` |
|
||
| `space_swallowed` | `after`: `suggestion`. A space right after a suggestion typed its own changed nothing. |
|
||
| `return` | `inserted`: `"\n"`, `returnKeyType`, `send` (the key said Send); `ignored: true` and no `inserted` when the key was disabled (empty field) |
|
||
| `paste` | `inserted`: the strip's Paste chip |
|
||
| `undo_dictation` | `deleted` (the dictation), or `deletedCount` when the host showed only its end |
|
||
| `cursor` | `offset`: characters the spacebar trackpad moved the cursor (negative is left) |
|
||
|
||
### `candidates`
|
||
|
||
The suggestions the strip offers: `items`: `[{slot, text, replacement?, kind,
|
||
auto?}]`, `kind` `literal` (left, what you typed), `primary` (centre; `auto`:
|
||
space will apply it), `secondary`. Written only when they changed, lazily: just
|
||
before the next touch goes down and at session end, so each line is what was on
|
||
screen when a finger next went down. The strip hides them while it shows Undo
|
||
dictation, a status, or the clipboard chips.
|
||
|
||
### `context`
|
||
|
||
The host's text around the cursor, as `documentContextBeforeInput` /
|
||
`AfterInput` give it. `why`: `session_start`, `space`, `return`,
|
||
`suggestion`, `delete_word`, `autocorrect_undo`, `revert`, `paste`, `trackpad`,
|
||
`undo_dictation`, `dictation`, `session_end`, or `text_did_change` (the host
|
||
changed the text or moved the cursor: written once things settle for 0.3 s, at
|
||
once when the field emptied). `before` (the last 200 characters), `after` (the
|
||
first 200), `beforeLength` and `afterLength` (before capping; hosts often cut
|
||
the context short themselves), `hasText`. `cleared: true` when the field had
|
||
text and now has none (most apps clear it when they send). An unchanged context
|
||
is not written again.
|
||
|
||
### `ui`
|
||
|
||
Taps that aren't text: `action`:
|
||
|
||
- `accent_open` (`id`, `key`, `options`), `accent_pick` (`id`, `index`, `chosen`,
|
||
`rollover` when another key committed it), `accent_cancel`;
|
||
- `trackpad_start` (`id`; `hold: true` when holding space still for 0.4 s
|
||
started it), `trackpad_end` (`id`, `offset`: total characters);
|
||
- `language_swipe` (`id`, `step`: 1 the next language, -1 the one before) and
|
||
`keyboard_language` (`language`: the layout it switched to), with two or more
|
||
keyboard languages;
|
||
- `hex_key` (`dictation`: `warm`, `keyboard`, `open_hex`), `hex_menu`, `style`
|
||
(`style`, `from`: `hex_menu` or `recording_panel`),
|
||
`dictation_language` (`language`: BCP 47 or `automatic`, from the Hex menu),
|
||
`dictation_stop` (`from: hex_key_release` when lifting a push-to-talk hold
|
||
ends it), `dictation_cancel`;
|
||
- `next_keyboard` (strip chip), `globe`, `undo_dictation` (`applied: false` when
|
||
the text had changed), `touches_cancelled` (`count`).
|
||
|
||
### `dictation`
|
||
|
||
Hex inserted a dictation (from the full keyboard or the dictation bar).
|
||
|
||
- `source`: `keyboard` (in-keyboard dictation) or `app` (a warm session or a
|
||
handoff to Hex). `resultID`, `style`.
|
||
- Each step, when it ran (a step that didn't run is missing): `engine`, `locale`
|
||
(in-keyboard) or `language` (the app), `recordedMS`, `transcribeMS`, `raw`
|
||
(as heard), `fixed` (after Learn how I type's fixes), `spelled` (after custom
|
||
vocabulary, app), `tagged` (after Clean up what I say), `cleaned` (after
|
||
Apple Intelligence, app), `translated`, `formatted` (after the style, app).
|
||
- `text`: the transcript Hex delivered; `inserted`: what went into the field
|
||
(with the spacing `TranscriptFormatter.insertionText` added).
|
||
|
||
A `context` line follows.
|
||
|
||
### `dictation_outcome`
|
||
|
||
What became of a dictation, from `DictationEditTracker` (the same inference
|
||
Learn how I type uses, run separately). `dictationSession` and `dictation` (its
|
||
`seq`) name the `dictation` line it is about. `outcome`: `kept`, `edited`,
|
||
`rewritten`, `undone`, `deleted`, `redictated`. `words`, `changed`, `pairs`:
|
||
`[{kind, heard, inserted, meant, before, after}]`. It settles within 60 s, when
|
||
the keyboard goes away or moves to another field, or on a Send return key, so it
|
||
can be in a later session than its dictation.
|
||
|
||
### `cap_reached`
|
||
|
||
The day's file hit 64 MB. `bytes` (file size before this line), `cap`; `seq` and
|
||
`session` are those of the first event not written.
|
||
|
||
## Size and cost
|
||
|
||
Measured in the simulator (Debug build, `TypingLogTests.testLoggingOverheadAndSize`,
|
||
3,000 taps of ordinary words): about 1 KB per tap, about 5.2 lines (a `began`,
|
||
one `moved`, an `ended`, an `edit`, a `candidates`, plus a `context` per
|
||
word and a `layout` when shift changes). Steady typing at 200 characters a
|
||
minute is about 12 MB an hour, so the 64 MB cap is about 5 hours of nonstop
|
||
typing in a day. On the main thread logging added about 12 µs per tap (35 µs
|
||
without it, 48 µs with); encoding and appending run on the utility queue.
|
||
Real fingers may produce more `moved` lines than the test's one per tap.
|
||
|
||
## Reading a day on a Mac
|
||
|
||
```python
|
||
import json
|
||
layouts, text = {}, ""
|
||
for line in open("2026-11-19.ndjson"):
|
||
e = json.loads(line)
|
||
if e["type"] == "layout" and "keys" in e:
|
||
layouts[e["hash"]] = e["keys"]
|
||
elif e["type"] in ("edit", "dictation"):
|
||
if "deleted" in e: text = text[: len(text) - len(e["deleted"])]
|
||
elif "deletedCount" in e: text = text[: len(text) - e["deletedCount"]]
|
||
text += e.get("inserted", "")
|
||
elif e["type"] == "touch" and e["phase"] == "ended":
|
||
keys = layouts[e["layout"]] # where the finger lifted, against every key's frame
|
||
```
|
||
|
||
(Python counts code points, not grapheme clusters; use a grapheme library for
|
||
emoji and combining marks.)
|