refactor: untangle the dependencies between Core and the TUI #7

Merged
Superkooka merged 11 commits from refactor/session-dependencies into main 2026-11-18 20:00:40 +00:00
Owner
No description provided.
The services of ProjectSession took the session itself, so each could
reach every other one and its constructor didn't tell what it used.

They now take a SessionContext, which holds the project, the language
and the background work, and the services they use: DictionarySet takes
the disk watch, SpellChecker the dictionaries, ReportService the disk
watch and the spelling, and the update, import and build the store.
The API of ProjectSession doesn't change.
refactor(core): read and write the project only through Core/Storage
All checks were successful
/ docs (push) Successful in 4s
/ format (push) Successful in 1m35s
/ test (push) Successful in 4m24s
167b56116d
IProjectStore took a path on each call and mixed every domain, while the
save, the documents, the disk watch, the fills, the build and the words
read and wrote the project folder themselves.

IProjectFiles now holds every read and write of one project folder, and
ProjectFiles implements it on the disk. ProjectLayout names the files,
ProjectStorage gives the files of any folder and the SourceMods, which
take over the Workshop and the source mod reading. EntryFiles holds the
save of an entry and the read the review queue needs.

A project without a translation folder no longer logs a warning at each
count of the index. Tests fake one operation by deriving OverridableFiles.
Core wrote the sentences of several refusals: the build, the config, the
update and the import, a source mod that can't be read and DeepL. The
setup flows, which pick the wording of their questions, lived in Core.

Each refusal is now a closed record, worded by the Notes class of its
feature: SourceModProblem, ModBuildRefusal, ConfigRefusal, DeepLFailure,
and the manifest and interruption cases of the update and the import. A
string stays only for the message of a system or parser error, in a
field named for it. The setup flows move to Tui/Features/Setup, and the
rules they apply to NewProjectChoices.

An interrupted update or import now says it stopped unexpectedly, and a
manifest broken during an update says it can't be used.
Browse, Check, Report, Review, Edit, Help, Manifest and Update depended on
each other, mostly to read the name of a command, and the entry editor
that three features share lived in Browse.

The entry editor moves to Features/Entry. Every command name moves to
Commands/CommandNames, so that a guide, a help or a message names any
command without depending on the feature that runs it. ReportContext
moves to Check, which the report opens. A feature now depends on another
only to reuse its behavior, and never both ways.
refactor(tui): check for a language in one place
Some checks failed
/ docs (push) Successful in 4s
/ format (push) Successful in 1m43s
/ test (push) Has been cancelled
9da0848ac6
Six commands checked themselves that the manifest declares a language,
each with its own copy of the sentence, and two copied the wait for the
index.

LanguagePage.RequireLanguage gives the current language, or says that
the manifest declares none, from LanguageNotes. The wait for the index
moves to TaskNotes. The sentences stay the same.
refactor(tui): word every message in the Notes class of its feature
All checks were successful
/ docs (push) Successful in 4s
/ format (push) Successful in 1m38s
/ test (push) Successful in 4m24s
d0ebf4422f
The build, the fill, the DeepL fill, the addition of a language and the
setup wrote some of their messages in place, so a contributor couldn't
tell which of the two styles to follow.

Every sentence a feature shows in a message, a notification or a warning
now lives in its Notes class: BuildNotes.Built, AutoFillNotes.Filled,
DeepLNotes.Filled, LanguageNotes.CouldNotAdd and the new SetupNotes. The
count of unreadable files that three features showed moves to TaskNotes.
The guidelines state the rule. The sentences stay the same.
refactor(core): split the folders into domain and infrastructure
All checks were successful
/ docs (push) Successful in 4s
/ format (push) Successful in 1m40s
/ test (push) Successful in 4m25s
084c070f84
Core had 21 folders, eight of them with one or two files, and Domain
mixed the model with task progress while the project and the open
file lived in Projects.

Domain now holds the model: TranslationProject and TranslationDocument
join the entries and statuses. Infrastructure groups what the rules
rely on without deciding: Background (with WorkProgress), Files,
Logging, Steam, Storage, Text and Versioning. The translation file and
source mod loaders and ProjectPaths move to Storage, and the mapping
between a status and its name in a file leaves the loader for
TranslationStatusNames. Projects keeps the lifecycle of a project.
The tests follow the same layout, and the Core page of the docs lists
the folders.
ci: build the project in the Nix dev shell
All checks were successful
/ docs (push) Successful in 5s
/ format (push) Successful in 6m13s
/ aot (push) Successful in 6m17s
/ test (push) Successful in 7m16s
ec3718fcc4
The format and test jobs installed the SDK with setup-dotnet, which
could differ from the one of flake.lock, and the Nix jobs cloned the
repository by hand because the nix image has no Node.js.

Every job that builds the project now runs in the nix image: a first
step installs Node.js from nixpkgs, so the checkout and cache actions
work there. Formatting and tests run through nix develop, with the SDK
of the flake.
Tui.Tests compiled the files of Core.Tests/Support through a link, so
the same fixtures built in two assemblies and showed twice in the IDE.
They now live in CK3TranslationTool.TestSupport, a library that both
test projects reference.

The TUI scripts play one step per main loop iteration, and Terminal.Gui
caps the loop at 25 iterations per second: every step waited 40 ms.
TuiTestApp lifts the cap, and Tui.Tests runs in about 33 s instead of
2 min 22 s.
DeepLQuota, DeepLFill and ProjectDeepL await the client instead of blocking
on it, and take a CancellationToken. BackgroundWork runs async work through
StartAwaiting and RunAwaiting, the only place where Core waits on a task. A
cancelled fill writes what came back and still gives its summary.

DeepLClient gives its slot back when a request is cancelled, so that
cancellations no longer lower the requests sent at the same time for good.

TranslationProject.Config replaces ProjectSession.Config, which parsed the
manifest again at each read. A manifest that can't be read on disk now has
no config, like one that can't be understood.

The NuGet locks move to nix/ to lighten the root of the repository.

Les deux renommages vers nix/ sont déjà stagés. Ajoute le reste avec git add -A avant de committer.
ci: install the SDK of global.json in the format and test jobs
All checks were successful
/ docs (push) Successful in 6s
/ format (push) Successful in 2m22s
/ test (push) Successful in 3m14s
/ aot (push) Successful in 4m42s
3bb78f5675
The format and test jobs ran in the nix image and downloaded the whole
dev shell on every push, clang and llvm included, which took them from
about 1.5 and 4.5 minutes to 6 and 7.

They install the SDK again with setup-dotnet, at the exact version that
global.json names. The aot job, which runs in Nix anyway, fails when that
version differs from the SDK of flake.lock.
Superkooka changed title from refactor/session-dependencies to refactor: untangle the dependencies between Core and the TUI 2026-11-18 19:51:38 +00:00
Superkooka deleted branch refactor/session-dependencies 2026-11-18 20:00:40 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Superkooka/CK3TranslationTool!7
No description provided.