2 Commits

Author SHA1 Message Date
Copilot
b3888c527e
Improve database explorer column ordering for better readability (#4182)
## Summary
Database explorer in settings now displays priority columns first (`id`,
`entityId`, `serverId`, `name`, `areaId`, `uniqueId`) followed by
remaining columns alphabetically, improving information density and
scannability.

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->
N/A - Backend sorting logic only, UI layout unchanged

## Link to pull request in Documentation repository
<!-- Pull requests that add, change or remove functionality must have a
corresponding pull request in the Companion App Documentation repository
(https://github.com/home-assistant/companion.home-assistant). Please add
the number of this pull request after the "#" -->
Documentation: home-assistant/companion.home-assistant#

## Any other notes

**Implementation:**
- Added private `Dictionary` extension with `sortedKeys()` method for
`[String: String]`
- Applied to both list view (first 3 columns) and detail view (all
columns)
- Priority keys maintain specified order; remaining keys sorted
alphabetically

**Before:**
```swift
ForEach(row.keys.sorted(), id: \.self) { key in
    // Keys sorted alphabetically: areaId, entityId, id, name, other, serverId
}
```

**After:**
```swift
ForEach(row.sortedKeys(), id: \.self) { key in
    // Keys sorted by priority: id, entityId, serverId, name, areaId, other
}
```

<!-- START COPILOT CODING AGENT SUFFIX -->



<!-- START COPILOT ORIGINAL PROMPT -->



<details>

<summary>Original prompt</summary>

> In database explorer inside settings, improve the information
readability, prefer displaying table columns named "id", "entityId,
"serverId", "name", "areaId, "uniqueId" first


</details>



<!-- START COPILOT CODING AGENT TIPS -->
---

 Let Copilot coding agent [set things up for
you](https://github.com/home-assistant/iOS/issues/new?title=+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
2026-01-08 10:08:27 +00:00
Copilot
77fa34669c
Add Database Explorer to debugging menu (#4167)
## Summary

Adds a "Database Explorer" feature to the debugging settings. When
tapped, displays a list of GRDB database tables. Selecting a table shows
all entries (up to 1000 rows) with:
- Text search across all columns
- Server ID filter (when table has `serverId` column and multiple
servers configured)
- Tap-through to view all fields for any row

### Changes
- **DatabaseExplorerView.swift** - Lists all tables from `sqlite_master`
- **DatabaseTableDetailView.swift** - Table entry viewer with filtering,
uses `@StateObject` ViewModel pattern
- **DebugView.swift** - Added navigation link in the existing section
with Event Log and Location History
- Localization strings added for new UI elements

### Security
- Table names validated via parameterized query before use
- SQL identifier quoting applied
- Row limit (1000) prevents memory issues on large tables

## Screenshots
<!-- If this is a user-facing change not in the frontend, please include
screenshots in light and dark mode. -->

## Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#

## Any other notes

Uses existing patterns from `ClientEventsLogView` and
`ServersPickerPillList`. Follows `DesignSystem.Spaces` convention.

<!-- START COPILOT CODING AGENT SUFFIX -->



<!-- START COPILOT ORIGINAL PROMPT -->



<details>

<summary>Original prompt</summary>

> Inside app settings, inside debugging, let's add a "Database explorer"
feature, which when you tap opens a list of GRDB database tables, then
on tap on it it shows all entries for that table with filter by text and
serverId.
> 
> Check GRDB+Initialization so understand the database


</details>



<!-- START COPILOT CODING AGENT TIPS -->
---

 Let Copilot coding agent [set things up for
you](https://github.com/home-assistant/iOS/issues/new?title=+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: bgoncal <5808343+bgoncal@users.noreply.github.com>
2026-01-06 22:13:23 +00:00