Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .kiro/steering/ui-design-system.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# UI Design System

> **Amendment (2026-11-12, Nornis 3.40, "the sources list opens on the sessions"):** Dave asked
> for the Sources list to be filterable by type and to open on session notes. It has a Type row
> above the Status row, the Codex's pattern (several chips or All). With no `?type=` it shows the
> sessions, every type `SourceTypeDisplay.IsSession` counts (typed, handwritten, imported and
> transcribed), so a backlog import is not hidden; `?type=all` shows everything. A way back to
> the list from a source that is not a session (`Links.SourcesShowing`: Capture after saving,
> the source page's crumb) asks for every type, so the source just left is on the list. A
> list that opens filtered says so with its lit chips, never with a hidden default.

> **Amendment (2026-11-12, Nornis 3.36, "the text on a sheet"):** Dave asked for a source's
> text to sit on white. A source's own text (its notes or transcription, and the text extracted
> from its files) now reads on the sheet it is edited on: the read-only `NotesEditor` keeps the
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
0 for local dev builds. Surfaced in the app via Nornis.Web.AppVersion. -->
<PropertyGroup>
<MajorVersion>3</MajorVersion>
<MinorVersion>39</MinorVersion>
<MinorVersion>40</MinorVersion>
<BuildNumber Condition="'$(BuildNumber)' == ''">0</BuildNumber>
<Version>$(MajorVersion).$(MinorVersion).$(BuildNumber)</Version>
<AssemblyVersion>$(MajorVersion).$(MinorVersion).$(BuildNumber).0</AssemblyVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/Nornis.Web/Components/Pages/Capture.razor
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@
!process ? "Draft saved."
: _extractionEnabled ? "Source saved and queued for processing."
: "Source stored in the record — no extraction.", Severity.Success);
Nav.NavigateTo("/sources");
Nav.NavigateTo(Links.SourcesShowing(_type));
}

private ApiError ShownError(string message) =>
Expand Down
4 changes: 2 additions & 2 deletions src/Nornis.Web/Components/Pages/SourceDetail.razor
Original file line number Diff line number Diff line change
Expand Up @@ -902,8 +902,8 @@
}
Crumbs.Set(Links.Source(_source.Slug, _source.Id),
_source.CampaignId is { } campaignId && _source.CampaignName is not null
? [new Crumb("Sources", "/sources"), new Crumb(_source.CampaignName, Links.Campaign(_source.CampaignSlug, campaignId)), new Crumb(_source.Title)]
: [new Crumb("Sources", "/sources"), new Crumb(_source.Title)]);
? [new Crumb("Sources", Links.SourcesShowing(_source.Type)), new Crumb(_source.CampaignName, Links.Campaign(_source.CampaignSlug, campaignId)), new Crumb(_source.Title)]
: [new Crumb("Sources", Links.SourcesShowing(_source.Type)), new Crumb(_source.Title)]);

_attachments = [];
_mapView = null;
Expand Down
155 changes: 150 additions & 5 deletions src/Nornis.Web/Components/Pages/Sources.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@inject WorldState Worlds
@inject NornisApiClient Api
@inject Nornis.Web.State.AuthSessionState AuthSession
@inject NavigationManager Nav

<PageTitle>Sources — Nornis</PageTitle>

Expand Down Expand Up @@ -78,8 +79,26 @@ else
{
<SourcesNeedingAttention Sources="_sources" OnRetried="LoadSourcesAsync" />

<div class="nornis-filter-row mb-3">
@* The list opens on sessions (3.40); the row says so by having those chips on, and "All"
is one click. Only types the world has are offered, so the row stays short. *@
<div class="nornis-filter-row mb-2" role="group" aria-label="Filter by type">
<span class="nornis-filter-label">Type</span>
<MudChip T="string"
Variant="@(_typeFilter.Count == 0 ? Variant.Filled : Variant.Outlined)"
Color="@(_typeFilter.Count == 0 ? Color.Secondary : Color.Default)"
OnClick="ShowAllTypes">All</MudChip>
@foreach (var type in TypesPresent)
{
var t = type;
<MudChip T="string"
Variant="@(_typeFilter.Contains(t) ? Variant.Filled : Variant.Outlined)"
Color="@(_typeFilter.Contains(t) ? Color.Secondary : Color.Default)"
OnClick="() => ToggleType(t)">@SourceTypeDisplay.Label(t)</MudChip>
}
</div>
<div class="nornis-filter-row mb-3" role="group" aria-label="Filter by status">
<span class="nornis-filter-label">Status</span>
<MudChip T="string" Size="Size.Small"
Variant="@(_statusFilter is null ? Variant.Filled : Variant.Outlined)"
Color="@(_statusFilter is null ? Color.Secondary : Color.Default)"
OnClick="() => _statusFilter = null">All</MudChip>
Expand All @@ -95,7 +114,7 @@ else

@if (FilteredSources.Count == 0)
{
<MudText Typo="Typo.body2" Color="Color.Secondary">No sources are @SourceStatusDisplay.Label(_statusFilter!).ToLowerInvariant().</MudText>
<MudText Typo="Typo.body2" Color="Color.Secondary">@NothingMatches</MudText>
}
<MudPaper Elevation="0" Class="nornis-card nornis-card-pad">
@foreach (var source in FilteredSources)
Expand Down Expand Up @@ -139,18 +158,141 @@ else
[SupplyParameterFromQuery(Name = "campaign")]
public Guid? CampaignQuery { get; set; }

/// <summary>
/// The types to show, comma-separated, or <c>all</c>. Absent means the default (the
/// sessions), so a plain <c>/sources</c> opens on the record of play. The choice lives in
/// the address, as the Codex's does, so Back from a source, a refresh and a shared link all
/// show the same list.
/// </summary>
[SupplyParameterFromQuery(Name = "type")]
public string? TypeQuery { get; set; }

private bool _loading;
private string? _error;
private IReadOnlyList<SourceListItem> _sources = [];
private IReadOnlyList<CampaignDto> _campaigns = [];
private string _campaignFilter = string.Empty;
private string? _statusFilter;

// Empty means every type. It is never a sentinel for "the default": the default is a set
// like any other (SourceTypeDisplay.DefaultFilter), and only the address spells it as absent.
private readonly HashSet<string> _typeFilter = new(SourceTypeDisplay.DefaultFilter, StringComparer.Ordinal);

private IReadOnlyList<SourceListItem> FilteredSources =>
_statusFilter is null
? _sources
: _sources.Where(s => SourceStatusDisplay.Matches(_statusFilter, s.ProcessingStatus)).ToList();
_sources
.Where(s => _typeFilter.Count == 0 || _typeFilter.Contains(s.Type))
.Where(s => _statusFilter is null || SourceStatusDisplay.Matches(_statusFilter, s.ProcessingStatus))
.ToList();

// The chips on offer: the types this list holds, in display order. A type the world has
// never seen would be a chip that can only ever show nothing.
private IEnumerable<string> TypesPresent
{
get
{
var present = _sources.Select(s => s.Type).ToHashSet(StringComparer.Ordinal);
return SourceTypeDisplay.FilterOrder.Where(present.Contains)
.Concat(present.Where(t => !SourceTypeDisplay.FilterOrder.Contains(t)).Order(StringComparer.Ordinal));
}
}

private string NothingMatches
{
get
{
var types = _typeFilter.Count == 0 ? null
: _typeFilter.SetEquals(SourceTypeDisplay.DefaultFilter) ? "sessions" : "sources of the chosen types";
var status = _statusFilter is null ? null : SourceStatusDisplay.Label(_statusFilter).ToLowerInvariant();
return (types, status) switch
{
("sessions", null) => "No sessions here yet. Choose All to see every source.",
({ } t, null) => $"No {t} here.",
(null, { } st) => $"No sources are {st}.",
({ } t, { } st) => $"No {t} are {st}.",
_ => "No sources here.",
};
}
}

private void ToggleType(string type)
{
// Picking a type when every type is showing narrows to that type, as on the Codex.
if (!_typeFilter.Remove(type))
{
_typeFilter.Add(type);
}

// A filter left holding only types this list does not have would show nothing with no
// chip lit to say why; with nothing chosen that can be seen, it is every type.
if (!_typeFilter.Overlaps(TypesPresent))
{
_typeFilter.Clear();
}
SyncUrl();
}

private void ShowAllTypes()
{
_typeFilter.Clear();
SyncUrl();
}

private void ResetTypeFilter()
{
_typeFilter.Clear();
_typeFilter.UnionWith(SourceTypeDisplay.DefaultFilter);
}

// Every time the address changes, not only on first load: the sidebar's Sources link lands
// on this same page instance, and must bring back the default rather than keep "All".
protected override void OnParametersSet() => RestoreTypeFilter();

private void RestoreTypeFilter()
{
ResetTypeFilter();
if (string.IsNullOrWhiteSpace(TypeQuery))
{
return;
}

if (string.Equals(TypeQuery.Trim(), Links.SourcesAllTypes, StringComparison.OrdinalIgnoreCase))
{
_typeFilter.Clear();
return;
}

var asked = TypeQuery.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
.Select(v => SourceTypeDisplay.FilterOrder.FirstOrDefault(t => t.Equals(v, StringComparison.OrdinalIgnoreCase)))
.OfType<string>()
.ToList();

// A link naming no type this version knows keeps the default rather than showing nothing.
if (asked.Count > 0)
{
_typeFilter.Clear();
_typeFilter.UnionWith(asked);
}
}

// Replace, not push: a chip is a refinement of this page, not a step Back should undo.
private void SyncUrl()
{
var type = _typeFilter.Count == 0 ? Links.SourcesAllTypes
: _typeFilter.SetEquals(SourceTypeDisplay.DefaultFilter) ? null
: string.Join(',', SourceTypeDisplay.FilterOrder.Where(_typeFilter.Contains));
var uri = Nav.GetUriWithQueryParameters(new Dictionary<string, object?>
{
["type"] = type,
// The campaign picker writes the address too, or Back from a source would restore
// the campaign this page was opened on rather than the one picked since. "No
// campaign" is not a Guid the parameter can carry, so it is dropped.
["campaign"] = Guid.TryParse(_campaignFilter, out var campaign) ? campaign : null,
});
if (uri != Nav.Uri)
{
Nav.NavigateTo(uri, replace: true);
}
}

// Extraction runs out-of-process; poll while any source is mid-pipeline so the
// list moves Queued -> Processing -> Processed without a manual refresh.
Expand All @@ -171,6 +313,8 @@ else
private void OnWorldChanged() => InvokeAsync(async () =>
{
_campaignFilter = string.Empty;
ResetTypeFilter();
SyncUrl();
await Task.WhenAll(LoadCampaignsAsync(), LoadSourcesAsync());
});

Expand All @@ -189,6 +333,7 @@ else
private async Task OnCampaignFilterChanged(string value)
{
_campaignFilter = value;
SyncUrl();
await LoadSourcesAsync();
}

Expand Down
11 changes: 11 additions & 0 deletions src/Nornis.Web/Navigation/Links.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ public static class Links

public static string Source(string? slug, Guid id) => $"/sources/{Key(slug, id)}";

/// <summary>
/// The sources list, showing sources of <paramref name="type"/>. The list opens on sessions
/// only, so a way back to it from a map or a GM note asks for every type, or the source the
/// reader came from would not be on it.
/// </summary>
public static string SourcesShowing(string type) =>
Services.SourceTypeDisplay.DefaultFilter.Contains(type) ? "/sources" : $"/sources?type={SourcesAllTypes}";

/// <summary>The <c>?type=</c> value that asks the sources list for every type.</summary>
public const string SourcesAllTypes = "all";

public static string LibraryDocument(string? slug, Guid id) => $"/library/{Key(slug, id)}";

public static string Adventure(string? slug, Guid id) => $"/prep/{Key(slug, id)}";
Expand Down
29 changes: 28 additions & 1 deletion src/Nornis.Web/Services/SourceTypeDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,36 @@ public static string Label(string type) =>
/// </summary>
public static string DateLabel(string type) => IsSession(type) ? "Session date" : "Date";

private static bool IsSession(string type) =>
/// <summary>
/// Whether a source records a session at the table, however it was captured: typed,
/// handwritten, imported from the backlog or transcribed. It names the date ("Session date")
/// and decides what the sources list shows before anyone picks a type.
/// </summary>
public static bool IsSession(string type) =>
type is "SessionNote" or "HandwrittenNotes" or "ImportedNote" or "SessionAudio" or "JournalEntry" or "Transcript";

/// <summary>
/// Every type a source can carry, in the order the sources list's Type row shows them: the
/// capture order, then the legacy types, then the ones the system files on its own.
/// </summary>
public static readonly IReadOnlyList<string> FilterOrder =
[
.. CaptureOptions.Select(o => o.Value),
"JournalEntry",
"Transcript",
"Reveal",
"LibraryExcerpt",
"AdventureExport",
];

/// <summary>
/// The types the sources list shows when no type is asked for: the sessions. Dave asked for
/// the list to open on session notes (3.40), so the record of play is not buried under maps,
/// GM notes and Prep filings; the rest are a click away.
/// </summary>
public static readonly IReadOnlySet<string> DefaultFilter =
FilterOrder.Where(IsSession).ToHashSet(StringComparer.Ordinal);

/// <summary>
/// The icon a source wears in a list, by what it is. Every row had the same document icon
/// until 3.32, so a map, a session and a GM note could only be told apart by reading.
Expand Down
Loading
Loading