Jump to page content

State

Caveats

Most if not all pages are just rough notes, and these pages as a whole are far from complete. More notes will be added in time, eventually, maybe.

If, from reading these notes, you conclude that I am off my rocker, you won’t be the first, and you may even be right. These pages may simply position me as an acolyte to the late Gene Ray.

No doubt there are a dozen and one reasons why none of this would ever work, but perhaps somewhere deep down there is a tiny fragment that could be used for something.

Contents

Overview

“State” refers to the persistent storage of data that lies outside of configuration and does not directly represent a user’s work. Examples of state include the jump lists in Windows, recent file lists and so forth. Cached data and offline-accessible material would however be handled by the Cache Manager.

The Windows Registry is effectively a random heap of state and configuration. Layer Config was intended to only store configuration, not state. Whether it would nonetheless be considered pragmatic to store state in Layer Config remains to be determined. Should this be the case, state and configuration would be clearly separated.

Implementations of state have a habit of being painfully intractable. Jump lists in Windows are stored as files under %APPDATA%\Roaming\Microsoft\Windows\Recent\AutomaticDestinations in some inscrutable format. For example, IrfanView’s jump list is held in a file called “70d9ada92108d731.automaticDestinations-ms”, which anyone can of course immediately discern with no effort. There is no method to clear the jump list for a single application; identifying and deleting the respective “automaticDestinations-ms” file to clear the list also has the unwanted side-effect of erasing any pinned items. Jump list entries for files that no longer exist remain seemingly forever. There is no way to disable the jump list for individual programs where it is of no use and adds unwanted clutter to the application’s context menu.

In part this is simply a matter of poor implementation (no clean-up of outdated file references) and poor UI (no manual clearing and limited control). Even so, per accountability principle, having hidden and unmanageable state is intolerable.

Another common example is windows that open off-screen as the saved window position is no longer valid for the desktop co-ordinates. This should not be of concern here as the window manager will automatically reposition windows shown with invalid co-ordinates unless deliberately overridden.

User state

User state is the collection of state information specific to each user.

Session state

Session state refers to an application’s set of open documents and their window positions. There should be a standard mechanism for storing and retrieving this data. This can be used when signing out with open applications, or when upgrading and restarting an application, to allow the user’s working environment to be retained. This could even be extended to a crash-resistant behaviour as found with Web browsers.

For some people, the set of open documents represents a static space and a working memory, i.e. they offload the cognitive task of remembering what they are working on to the computer. Losing this state upon a restart causes an effective loss of working memory.

While some software (e.g. Microsoft Office, Windows File Explorer, and most browsers) already has this facility, it is not universal outside of the modern Mac.

Recent items

Within Microsoft Windows, there are multiple implementations of recent items. Applications have for decades supported internal lists of recently-used items. Open and Save dialog boxes often return to the last-used location for a program, while Mozilla Firefox opens Save dialog boxes on the last-used folder for the site in question. Jump lists maintained by the operating system are completely independent and often conflict horribly with what the application thinks is the files most recently opened: jump lists tend to be far less reliable. JujuEdit’s recent files list excludes any files presently open, which can be a useful reminder that the document is already open in another window.

There is a separate Recent Items list in the older Windows XP-style Open/Save dialog boxes under Windows that is far more comprehensive than the brief list shown under Quick access, but this list is not available to programs that use up-to-date Open and Save dialog boxes. IrfanView and Inkscape have both customised their Open/Save dialog boxes and as such are left with the XP-style type that allows access to Recent Items. (In actual fact, typing “Recent Items” into the Open/Save window’s address bar will call up the old-style Recent Items area, but the UI does not expose this as it did before.)

Per the consistency principle, the list of recently-used files and directories should be part of the user’s state: applications should use user state to store and retrieve such information instead of maintaining private lists, as this ensures that the lists are always correct and up-to-date.

System state

System state covers various datasets created primarily to improve performance. Examples include:

These datasets are all effectively caches: reading all of this data from each package separately would be intolerably slow, hence the need to collate the data into caches. Per the robustness principle, if any one should become damaged, it can be simply wiped and rebuilt from the package data.

Choices in Layer Config could be set to point directly to facilities advertised by packages that are cached as system state, e.g.

This illustrates that configuration and state will be very closely tied together and essentially inseparable.