Skip to content

Fix Sort Being Lost on osrc Refresh#124

Merged
gbeeley merged 1 commit into
masterfrom
fix-refresh-unsort
Jun 16, 2026
Merged

Fix Sort Being Lost on osrc Refresh#124
gbeeley merged 1 commit into
masterfrom
fix-refresh-unsort

Conversation

@Lightning11wins

Copy link
Copy Markdown
Contributor

Refreshing a sorted osrc causes the sort to be lost. This happened for me when I tested refreshing content in a table after the user had clicked a column to sort the content, and the Refresh action dropped the sort. This PR fixes that.

@Lightning11wins Lightning11wins self-assigned this Jun 10, 2026
@Lightning11wins Lightning11wins added bug ai-review Request AI review for PRs. size: trivial Easy to review, probably ~100 lines or fewer. labels Jun 10, 2026
@greptile-apps

greptile-apps Bot commented Jun 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a bug where the active sort order was lost when an osrc (object source) was refreshed. Without this fix, calling the Refresh action re-issued the underlying query without an ORDER BY clause, even when the user had previously sorted by a column.

  • Adds 4 lines to osrc_action_refresh that copy this.orderobject into this.pendingorderobject before re-issuing the query, mirroring exactly how osrc_action_order_object works — the query-build path already reads pendingorderobject to append the ORDER BY clause.
  • The guard !this.pendingorderobject correctly prevents overwriting an in-flight sort change (e.g. a concurrent OrderObject action) with the stale committed sort.

Confidence Score: 5/5

Safe to merge — the change is a targeted 4-line addition that restores an omitted step in the refresh path.

The fix mirrors exactly what osrc_action_order_object already does and slots into the existing pendingorderobject machinery without altering any other code path. The guard against an already-set pendingorderobject correctly handles concurrent sort changes. Both the QueryText and QueryObject refresh branches benefit from the fix because both consume pendingorderobject when building the SQL statement.

No files require special attention.

Important Files Changed

Filename Overview
centrallix-os/sys/js/htdrv_osrc.js Adds sort-preservation logic to osrc_action_refresh; the fix is minimal, correctly guarded, and consistent with how other query paths use pendingorderobject.

Sequence Diagram

sequenceDiagram
    participant User
    participant osrc
    participant QueryHandler

    User->>osrc: OrderObject(sortCol)
    osrc->>osrc: "pendingorderobject = sortCol"
    osrc->>QueryHandler: QueryObject / QueryText
    QueryHandler->>osrc: osrc_cb_query_continue_2()
    osrc->>osrc: "orderobject = pendingorderobject (sortCol)"
    osrc->>osrc: "pendingorderobject = null"

    Note over User,osrc: Later — user triggers Refresh

    User->>osrc: Refresh action
    osrc->>osrc: "[NEW] if !pendingorderobject and orderobject pendingorderobject = orderobject"
    osrc->>QueryHandler: QueryObject / QueryText (includes ORDER BY)
    QueryHandler->>osrc: osrc_cb_query_continue_2()
    osrc->>osrc: "orderobject = pendingorderobject (sortCol)"
    osrc->>osrc: "pendingorderobject = null"
    QueryHandler-->>User: Results returned with sort preserved
Loading

Reviews (1): Last reviewed commit: "Fix sort being lost when an osrc is refr..." | Re-trigger Greptile

@Lightning11wins

Copy link
Copy Markdown
Contributor Author

This PR is ready for human review.

@gbeeley gbeeley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - thanks!

@gbeeley gbeeley merged commit 1f14b1e into master Jun 16, 2026
2 checks passed
@Lightning11wins Lightning11wins deleted the fix-refresh-unsort branch June 16, 2026 20:29
@Lightning11wins Lightning11wins removed the request for review from nboard June 16, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request AI review for PRs. bug size: trivial Easy to review, probably ~100 lines or fewer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants