Android Shard Editor: Clock moves shard to now #340
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Change the little clock icon in the editor as follows:
In the shard the pointer currently is on, add the date and time shards necessary to move the current shard to now.
For example if the shard would be 12:40:00, but now is 13:00:00, insert @130000 after the # of the heading (if that's the start of the shard we would have been in) - same for the date if it doesn't fit.
Plan
Behaviour (decided)
Capture.kt,onTime) moves the shard the cursor is in to now. The old "insert@HHMMSSat the cursor" goes away as the tap's action and stays only as the fallback below.start_line..=end_lineholds the line of the cursor.@HHMMSS, date@YYYYMMDD, datetime@YYYYMMDDHHMMSS, those thatis_moment_markeraccepts among its markers). Then the markers it needs to read as now, relative to what it inherits, are added, as two markers likeappend: bymoment_markers(inherited, now, tz)ofcommands/file/append.rs. This gives@HHMMSSif the date matches,@YYYYMMDD @HHMMSSif not, and nothing if it already reads as now.20261026-…with# @124000 Callat 13:00:00, the result is# @130000 Call. On another day it would be# @20261026 @130000 Call.heading()ofappend.rsdoes), so they stay markers:# @Task @130000 Call,- @130000 item, plain paragraph@130000 text. The indentation and the#/-stay as they are, and single spaces are kept (aswith_whitespaceinstate/edit.rsdoes).extract_datetime_from_marker_list. The root starts fromextract_datetime_from_file_name(name, tz), or fromnowif the name has no date (e.g. an unsaved note without one).moment_markers(file moment, now)gives (at least@HHMMSS) at the cursor, viainsertingMarker. If the root takes its markers from a tagged heading on line 1, that line is edited like any other shard, relative to the file name's moment.Core (
streamd-core)document/(e.g.document/moment.rs):move_to_now(text: &str, file_name: &str, offset: usize, now: DateTime<Utc>, tz: Tz) -> MomentEdit. It parses the text withextract::parser, finds the shard, computes what it inherits, and returns:MomentEdit::Line { range: Range<usize>, replacement: String }: the byte range of the shard's first line (or a smaller span) and its new text, orMomentEdit::AtCursor { markers: Vec<String> }for the root fallback, orMomentEdit::Noneif it already reads as now.It reuses
marker_spans/with_whitespaceofcommands/state/edit.rs(makewith_whitespacepub(crate)) andmoment_markersofappend.rs(move it tolocalize/datetime.rsif that reads better, since it is now shared).api.rs:move_to_now(...)in the facade.local_to_utc).Bindings (
streamd-ffi)moveToNow(text, fileName, offset, now, tz)as a free function, with the offsets converted throughtext.rs(bytes ↔ UTF-16). It returns a record/enumMomentEdit(Line { range: TextRange, replacement },AtCursor { markers },Unchanged). Add a conversion test.App
StreamSession.momentEdit(name, text, cursor, now): the only call into the bindings. Expose it throughCapturing(with the moment of the call fromCaptureAdapter), and use plain app types incore/Capture.kt.Editing.kt: a pureTyped.applying(edit)that splices aLineedit and moves the cursor, and usesinsertingMarkerfor each marker ofAtCursor. Unit-test it inEditingTest.kt.Capture.kt:onTimeasksCapturingwith the draft's current name (Draft.named/destination name) and text, then applies the result. Change the label/description of the tool (tool_timeinstrings.xml) to something like "Move to now".Docs
REQUIREMENTS.md(the requirement of the editor of the app, R35-area / capture),README.md(the editor's toolbar), andAGENTS.md(document/module list, the facade list,Editing.kt,Capturing).Implemented in PR #342.
Time: about 30 minutes (21:36–22:07 UTC), including the full app build with unit and screenshot tests.
Tokens: about 75k.
Findings during the implementation:
@HHMMSSis always kept.nowis truncated to whole seconds before comparing, since markers carry no sub-second part.