Skip to content

Conversation

@zamderax
Copy link
Contributor

@zamderax zamderax commented Jan 14, 2026

  • add row IDs to TableData for stable selection tracking in updating tables
  • add automatic selection tracking that prefers row IDs and falls back to the first column
  • update the selectable updating example/docs and add tests for reordering and duplicate names

@zamderax zamderax requested a review from a team as a code owner January 14, 2026 01:19
@zamderax zamderax requested review from cschmatzler and fortmarek and removed request for a team January 14, 2026 01:19
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jan 14, 2026
@zamderax zamderax changed the title Track updating selections with row IDs feat: track updating selections with row IDs Jan 14, 2026
@zamderax
Copy link
Contributor Author

I updated the mise task headers from to to silence the deprecation warning in newer mise versions. Happy to revert if you’d rather keep the old header.

@cschmatzler cschmatzler requested a review from pepicrft January 16, 2026 16:02
Copy link
Member

@fortmarek fortmarek left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the PR and sorry for taking longer to review this. I wonder if we can take the opportunity to rethink the API a bit to make supporting this use case more elegant 👀

/// An interactive table that keeps updating as new data arrives.
struct UpdatingSelectableTable<Updates: AsyncSequence> where Updates.Element == TableData {
/// @unchecked Sendable: rendering and state access are serialized by internal queues.
struct UpdatingSelectableTable<Updates: AsyncSequence>: @unchecked Sendable where Updates.Element == TableData {
Copy link
Member

Choose a reason for hiding this comment

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

I'd love us to figure out a way not to add the @unchecked Sendable – is there a way to implement the behavior with structured concurrency constructs?

public let rows: [TableRow]

/// Optional row identifiers aligned to `rows` (used for selection tracking in updating tables)
public let rowIDs: [AnyHashable]?
Copy link
Member

Choose a reason for hiding this comment

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

instead of a rowIDs property, I'd consider making the TableRow conform to Identifiable and basically make it more like a SwiftUI List. I'd love the API to be more like:

TableData(
  data,
  columns: columns,
  rows: [
     TerminalRow { element in
        element.title
      },
     TerminalRow { element in
        element.subtitle
      }
  ])

And if data would be Identifiable, the selection could work based on the ID (without having an explicit rowIDs property). It would require some type gymnastics to make this non-breaking, but I think it should be possible.

Wdyt? cc @pepicrft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants