Skip to content

refactor(desktop): move the editor's plain logic out of MyGo's packages - #288

Merged
frostyard-machines merged 1 commit into
mainfrom
refactor/desktop-logic-without-ui
Nov 25, 2026
Merged

frostyard-machines merged 1 commit into
mainfrom
refactor/desktop-logic-without-ui

Conversation

@bketelsen

Copy link
Copy Markdown
Contributor

Summary

Phase 1 of plan 0011, "Logic out of MyGo's packages" (the plan and ADR-0049 are on #287, not yet on main). The plain Go logic that the NSGo client will need now lives in packages that import neither MyGo nor frostui's root module. The MyGo client uses the moved code, and its behaviour does not change: the code moved as it was, only package names and qualifiers changed. The exceptions are listed below.

A new package, internal/desktop/markup, holds what the editor does to a note's Markdown source as plain text. I named it markup because internal/markdown is already notesd's parser, and notes is the document model.

  • git mv from editor: format.go (the formatting commands and smart lists), links.go (LinkAt, TagAt, SubpathLine), properties.go (frontmatter, properties and property types), with format_test.go and properties_test.go.
  • attach.go also moved with git mv. It keeps the parts that use no MyGo type: MaxAttach, File and File.Read, AttachmentFolder, FreePath, PastedName, EmbedFor and CleanName. It gains InsertEmbeds, which is the old insertEmbeds body as a function of the text and the selections.
  • The parts that use mygo/transfer or mygo/ui stay in editor, in upload.go: Uploader, Clipboard, Attach, AttachPaths, paste and drops.
  • Target (a [[ completion) moved from noteeditor.go to links.go, and tagRanges moved from syntax.go (TagAt uses it) as TagRanges. valueText and listItems became ValueText and ListItems for noteview.go.
  • The pure tests moved with the code. review_test.go is split: 13 tests went to markup/review_test.go, and the 3 that drive the editor stay in editor/review_test.go. attach_test.go's naming test went to markup, and the paste test is now editor/upload_test.go.

panes/tree.go → catalog/tree.go (git mv), with its 3 tests in catalog/tree_test.go. parentOf became catalog.Parent, because panes/files.go uses it. The panes package comment moved to panes.go.

catalog no longer imports editor (it uses markup instead) or frostui. Score is a copy of frostui.Match (v0.10.1), and Search uses it.

system/open.go no longer imports frostui:

  • WebURL, VaultFile, OpenableExtensions and the mailto cleaning all stay in this file.
  • SanitizeMailto is frostui's SanitizeMailto (v0.10.1) copied in, error text included, so the app says what it said before.
  • Nothing in system used frostui.Opener. cmd/frostnotes already holds it (openURL, openFile), so nothing had to move there.

Parity with frostui:

  • cmd/frostnotes/frostui_parity_test.go keeps both copies equal to frostui while the MyGo client has frostui. It holds 2 fuzz targets, FuzzSanitizeMailtoIsFrostuis and FuzzScoreIsFrostuisMatch. They compare the copies with frostui.SanitizeMailto (value and error text) and frostui.Match (score and ok). In every unit run they cover their seeds: about 24,700 generated mailto links and 550 query and text pairs.
  • system/open_test.go carries frostui's own mailtoCases and refusal cases.
  • catalog/score_test.go pins 22 scores that I took from frostui.Match.

Other changes:

  • With system free of frostui, cmd/frostnotes-nsgo's go mod tidy drops egoist/mygo, frostyard/frostui and go-text/typesetting (indirect). make flatpak-sources then drops upstream egoist/mygo v0.10.0 from go-sources.json.
  • AGENTS.md (Map) and docs/design/app.md name the new layout. Plan 0011 is not on main, so I did not edit it.

Note on correction records: 9 legacy records in .memory/corrections/ (0027, 0028, 0031, 0032, 0033, 0041, 0048, 0052, 0055) have promoted_to set to internal/desktop/editor/review_test.go. Their guards (except 0041's late-completion check, which stays) are now in internal/desktop/markup/review_test.go. The baseline rule says a record's non-empty promoted_to never changes, so I left the records as they are.

Import check (go list -deps, and go list -deps -test): internal/desktop/markup, catalog and system import neither github.com/egoist/mygo nor github.com/frostyard/frostui. Neither do notes and livepreview.

Risk tier

Risk tier: 3. I matched every changed path against .github/risk-paths.json by script, expanding brace globs and ** (old and new names of renamed files). 2 paths match, both in the L1 sanitizer glob {internal/render/sanitize.go,app/src/reading/sanitize.ts,internal/desktop/system/open.go,internal/desktop/media/media.go,internal/desktop/reading/view.go,internal/desktop/editor/live.go}:

  • internal/desktop/system/open.go: the allow-lists' logic is unchanged.
    • WebURL's checks, VaultFile and OpenableExtensions are unchanged. The only change is that WebURL calls the file's own SanitizeMailto instead of frostui's.
    • That function copies frostui v0.10.1's, in the same order: the control and space check, url.Parse, the scheme check, keeping only to, cc, bcc, subject and body in ASCII case, and dropping ForceQuery and the fragment. Its refusals have the same text.
    • The copy is pinned to frostui by the fuzz target in cmd/frostnotes (value and error text, on about 24,700 seeds; a 20-second go test -fuzz run found no difference), and by frostui's own case table in open_test.go. The existing TestWebURLs and TestVaultFileRules pass unchanged.
    • The file still holds all the allow-list code, so the glob still matches it.
  • internal/desktop/editor/live.go: the only change is Sel and Edit written as markup.Sel and markup.Edit in setTask, plus the import. Nothing in what it draws or hides changes.

Every other path is at the default L3.

Docs housekeeping

  • Cross-links: docs/design/app.md names internal/desktop/markup/attach.go and the new layout; AGENTS.md's Map is updated. No new doc, ADR or spec.
  • Conformance aliases and canonical symlinks are unchanged; AGENTS.md was edited.

Verification

  • make check green (host): exit 0 on the final tree.
  • make flatpak-sources run (the NSGo module's go.mod and go.sum changed by go mod tidy).
  • make desktop-bench: exit 0 (developer machine, AMD Ryzen AI Max+ 395, 100 keystrokes): source mode 2.00 ms, live preview 8.40 ms per keystroke; the gate is 16 ms.
  • Test counts (go test -list), before → after:
    • editor: 61 tests and 1 benchmark → 40 and 1 benchmark.
    • new markup: 21 (61 in total, as before).
    • panes: 18 → 15.
    • catalog: 4 → 8 (+3 tree, +1 score).
    • system: 7 → 9 (+2 mailto).
    • cmd/frostnotes: 0 → 3 (1 test, 2 fuzz targets).
    • window: 73 → 73.

Plan 0011, Phase 1: the logic the NSGo client will need moves to
packages that import neither MyGo nor frostui's root module.

- internal/desktop/markup (new): the formatting commands and smart
  lists, links and tags under the caret, frontmatter and properties,
  and the attachment rules, moved from editor with their tests; editor
  keeps the clipboard, drops and uploads (upload.go).
- panes/tree.go moves to catalog, with its tests.
- catalog uses markup and its own Score, a copy of frostui.Match.
- system/open.go carries frostui's SanitizeMailto; the allow-lists
  stay in the same file.
- cmd/frostnotes' fuzz targets hold both copies to frostui's results.
- The NSGo module no longer needs MyGo or frostui's root module (go mod
  tidy; make flatpak-sources).
@github-actions github-actions Bot added level:L1 Read every line risk:high Touches a path in .github/risk-paths.json labels Nov 25, 2026
@frostyard-machines
frostyard-machines merged commit 74cf3ef into main Nov 25, 2026
15 checks passed
@frostyard-machines
frostyard-machines deleted the refactor/desktop-logic-without-ui branch November 25, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:L1 Read every line risk:high Touches a path in .github/risk-paths.json

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants