Repository navigation
feat(api): return a profile row's server title in profile section settings #1900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Quick104
merged 6 commits into
feat/collections-revamp
from
feat/api-profile-section-default-title
Oct 4, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ceab956
feat(api): return a profile row's server title in profile section set…
Quick104 1fd17e9
Merge remote-tracking branch 'origin/feat/home-rows-profile-rule-swit…
Quick104 50a2bd6
Merge remote-tracking branch 'origin/feat/collections-revamp' into fe…
Quick104 e5c15e0
chore(api): drop breaking-change approvals consumed by #1615
Quick104 6989b56
Merge remote-tracking branch 'origin/feat/collections-revamp' into fe…
Quick104 d23fecc
Merge remote-tracking branch 'origin/feat/collections-revamp' into fe…
Quick104 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
internal/api/handlers/sections_settings_default_title_db_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| package handlers | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "strconv" | ||
| "testing" | ||
|
|
||
| "github.com/Silo-Server/silo-server/internal/catalog" | ||
| "github.com/Silo-Server/silo-server/internal/sections" | ||
| "github.com/Silo-Server/silo-server/internal/userstore" | ||
| "github.com/Silo-Server/silo-server/internal/userstore/pgstore" | ||
| ) | ||
|
|
||
| // TestProfileSectionSettingsKeepAdminTitleDB: the settings read over the | ||
| // real section repository and profile store returns the profile's rename as | ||
| // the title and the admin row's own title beside it, and follows a later | ||
| // admin rename for the default while the profile's rename stays. | ||
| func TestProfileSectionSettingsKeepAdminTitleDB(t *testing.T) { | ||
| f := newPagingIntegrationFixture(t) | ||
| ctx := t.Context() | ||
| provider := pgstore.NewPostgresProvider(f.pool) | ||
| store, err := provider.ForUser(ctx, f.account) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| if err := store.CreateProfile(ctx, userstore.Profile{ID: "p1", Name: "p1"}); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| repo := sections.NewRepository(f.pool) | ||
| library := f.library | ||
| create := func(title string, position int) *sections.PageSection { | ||
| t.Helper() | ||
| s, err := repo.Create(ctx, §ions.PageSection{ | ||
| Scope: "library", LibraryID: &library, Position: position, SectionType: sections.SectionRecentlyAdded, | ||
| Title: title, ItemLimit: 20, Config: json.RawMessage(`{}`), Enabled: true, | ||
| }) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| return s | ||
| } | ||
| renamed := create("Recently Added", 0) | ||
| untouched := create("Favorites", 1) | ||
| t.Cleanup(func() { | ||
| _, _ = f.pool.Exec(context.Background(), `DELETE FROM page_sections WHERE id = ANY($1)`, []string{renamed.ID, untouched.ID}) | ||
| }) | ||
|
|
||
| libraryKey := strconv.Itoa(library) | ||
| position := 2 | ||
| if err := store.SaveSectionOverrides(ctx, "p1", "library", libraryKey, []userstore.SectionOverride{ | ||
| {ID: "o-renamed", SectionID: renamed.ID, Title: "Weekend picks"}, | ||
| {ID: "o-gems", IsUserAdded: true, UserSectionType: string(sections.SectionHiddenGems), UserTitle: "Hidden gems", Position: &position}, | ||
| }); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| h := NewSectionHandler(repo, nil) | ||
| h.StoreProvider = provider | ||
| titles := func() map[string][2]string { | ||
| t.Helper() | ||
| resolved, err := h.ResolveProfileSectionSettings(ctx, f.account, "p1", "library", &library, catalog.AccessFilter{}) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| out := map[string][2]string{} | ||
| for _, s := range resolved { | ||
| out[s.ID] = [2]string{s.Title, s.DefaultTitle} | ||
| } | ||
| return out | ||
| } | ||
| assert := func(want map[string][2]string) { | ||
| t.Helper() | ||
| got := titles() | ||
| if len(got) != len(want) { | ||
| t.Fatalf("settings = %q, want %q", got, want) | ||
| } | ||
| for id, w := range want { | ||
| if got[id] != w { | ||
| t.Errorf("section %s (title, default title) = %q, want %q", id, got[id], w) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| assert(map[string][2]string{ | ||
| renamed.ID: {"Weekend picks", "Recently Added"}, | ||
| untouched.ID: {"Favorites", "Favorites"}, | ||
| "o-gems": {"Hidden gems", ""}, | ||
| }) | ||
|
|
||
| renamed.Title = "New this week" | ||
| if err := repo.Update(ctx, renamed); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| assert(map[string][2]string{ | ||
| renamed.ID: {"Weekend picks", "New this week"}, | ||
| untouched.ID: {"Favorites", "Favorites"}, | ||
| "o-gems": {"Hidden gems", ""}, | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
default_titlewithout extending a profile-sections capability leaves newer clients without the required support signal when they connect to an older server or a mixed-version cluster. Such clients must infer support from field presence or the server version/digest before enabling rename/reset behavior, even though repository policy requires new client-visible features to expose a capability endpoint; add an explicit capability field and keep it false or absent on implementations that cannot return the title.AGENTS.md reference: AGENTS.md:L146-L150
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not adding a capability for this.
default_titleis an extra read-only field on an existing response, not optional behavior a client sends. It is serialized on every row (noomitempty), so its presence is the support signal: an older server omits it, and a client then just doesn't show "Renamed from" or offer the original name. Restoring the name saves an emptytitleoverride, which older servers already accept, so nothing new is sent to a server that lacks the field. The contract's capability-document rule covers optional domains and optional request behavior, and the v2 contract is not locked yet. Dismissed on #1913 (follow-up for late findings).