Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Ivy233 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideAPIAdd UUID-and-name monitor lookup with UUID-only fallback so callers can distinguish identical-EDID displays without breaking stale-name configurations.
Uses of the APIUse UUID-plus-name matching when applying monitor settings and selecting mirror primaries, and safely resolve the primary fill-mode monitor.
ImplementationAssign stable UUIDs from each refresh's complete X-output and DRM-connector view, falling back to X names when identical EDIDs make connector identity ambiguous.
Migrate legacy duplicate-UUID screen and user settings only when EDID fingerprints and monitor identity can be mapped safely, preserving layouts, OnlyOne choices, and fill modes.
Preserve distinct saved monitor names when a UUID is duplicated, and resolve configuration entries by name or unambiguous geometry before changing primary state.
TestsAdd regression and randomized tests for UUID assignment, duplicate-UUID lookup and primary behavior, migration safety, and compatibility fallbacks.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 8 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="display1/util.go" line_range="440-441" />
<code_context>
+ continue
}
+
+ if connectorName == outputName {
+ exactMatches = append(exactMatches, connectorName)
+ } else {
+ otherMatches = append(otherMatches, connectorName)
</code_context>
<issue_to_address>
**Saved layouts lose monitor positions**
When a saved system layout contains identical-EDID monitors under their former shared UUID, `updateUuid` leaves these `|v1` UUIDs unmigrated or maps repeated UUIDs to the same first monitor, so `getSysScreenConfig` looks up a different monitor-set key and returns an empty config. The saved layout is not applied.
Migrate each entry with a duplicate old UUID to its corresponding connector-specific UUID before rebuilding the saved system-layout key.
Also at `display1/util.go:448`.
</issue_to_address>
### Comment 2
<location path="display1/util.go" line_range="440-441" />
<code_context>
+ continue
}
+
+ if connectorName == outputName {
+ exactMatches = append(exactMatches, connectorName)
+ } else {
+ otherMatches = append(otherMatches, connectorName)
</code_context>
<issue_to_address>
**Saved monitor positions are lost**
When a user upgrades with saved configs for identical-EDID monitors under their former shared UUID, `updateUuid` leaves some `|v1` UUIDs unchanged or maps repeated UUIDs to the first monitor, so `applySysMonitorConfigs` cannot match the other monitors’ saved configs or applies the first config’s position to them. The monitors are disabled or their saved positions are lost.
Migrate each saved monitor config to the corresponding connector-specific UUID using the monitor’s identity rather than UUID alone.
Also at `display1/manager.go:2447`.
</issue_to_address>
### Comment 3
<location path="display1/manager.go" line_range="1922" />
<code_context>
// TODO 这里为什么需要更新 Name?
updateSysMonitorConfigsName(configs, m.monitorMap)
- configs.setPrimary(primaryMonitor.uuid)
+ configs.setPrimaryByUuidAndName(primaryMonitor.uuid, primaryMonitor.Name)
}
</code_context>
<issue_to_address>
**Primary selection collapses monitor configs**
When the user changes the primary in Extend mode while multiple connected monitors share a UUID, `updateSysMonitorConfigsName` matches configs by UUID alone, so when identical-EDID monitors share a UUID it overwrites every saved config name with the first matching monitor’s name. `setPrimaryByUuidAndName` then saves those collapsed names, and `applySysMonitorConfigs` matches by UUID and name exactly, so the other monitors lose their configs and are disabled on a later apply.
Update config names by matching both UUID and the existing monitor name, or otherwise preserve the distinct names for configs with duplicate UUIDs.
</issue_to_address>
### Comment 4
<location path="display1/displayconf.go" line_range="721-722" />
<code_context>
+ }
+ }
+
+ // Name 不匹配时回退到旧行为,避免旧配置导致显示器被直接禁用。
+ return cfgs.getByUuid(uuid)
+}
+
</code_context>
<issue_to_address>
**Legacy configs still collapse**
When saved configs contain multiple entries with the same UUID and their names do not match the connected monitors, `getByUuidAndName` falls back to the first UUID match for each monitor, so monitors sharing a legacy UUID and having names that no longer match all receive the same saved position. `setPrimary` can also rewrite every such config’s name to the first matching monitor, leaving the saved configurations indistinguishable; apply then restores the overlap.
When UUID fallback finds multiple configs, preserve or resolve their per-monitor identity instead of applying the first entry to every monitor.
Also at `display1/manager.go:1922`.
</issue_to_address>
### Comment 5
<location path="display1/displayconf.go" line_range="731" />
<code_context>
- } else {
- mc.Primary = false
- }
+ mc.Primary = mc.UUID == uuid && (name == "" || mc.Name == name)
}
}
</code_context>
<issue_to_address>
**Mirror primary selection is lost**
When a saved mirror config is found by UUID fallback because its saved name differs from the connected monitor’s name, `getByUuidAndName` returns the UUID match, but `setPrimaryByUuidAndName` requires an exact UUID-and-name match and clears every config’s `Primary` flag. The mirror config loses its inherited primary and falls back to an unintended default primary.
Set the primary flag on the config returned by the UUID-and-name lookup, including when that lookup used its UUID fallback.
Also at `display1/manager.go:1714`.
</issue_to_address>
### Comment 6
<location path="display1/duplicate_uuid_test.go" line_range="74" />
<code_context>
+ edid := bytes.Repeat([]byte{0x78}, 128)
+ seen := make(map[string]string)
+ for _, connector := range []string{"DP-1", "DP-2", "DP-3", "DP-4"} {
+ uuid := getOutputUuid(connector, connector, edid)
+ if other, ok := seen[uuid]; ok {
+ t.Fatalf("connector %s and %s got the same UUID %s", other, connector, uuid)
</code_context>
<issue_to_address>
**Standard names are not verified**
When `getOutputUuid` uses the output name instead of the standard name for a valid EDID, testGetOutputUuidIdenticalEdidUsesDistinctStdNames passes the connector as both `name` and `stdName` on line 74, so `getOutputUuid` can ignore `stdName` and still produce distinct UUIDs from the distinct connector names; the test misses that regression.
Pass differing output and standard names, then assert the UUIDs reflect the standard names.
</issue_to_address>
### Comment 7
<location path="display1/duplicate_uuid_test.go" line_range="149" />
<code_context>
+ if got := monitors.GetByUuidAndNameOrUuid("duplicate-uuid", "DP-2"); got == nil || got.Name != "DP-2" {
+ t.Fatalf("GetByUuidAndNameOrUuid returned %+v, want DP-2", got)
+ }
+ if got := monitors.GetByUuidAndNameOrUuid("duplicate-uuid", "DP-9"); got == nil {
+ t.Fatal("GetByUuidAndNameOrUuid should fall back to UUID for unknown name")
+ }
</code_context>
<issue_to_address>
**Wrong duplicate fallback passes**
When the requested name is unknown and multiple monitors share the UUID, testMonitorsGetByUuidAndNameOrUuid only checks for non-nil on line 149, so returning the wrong monitor when the name is unknown and UUIDs are duplicated still passes; the compatibility fallback can select the wrong display.
Assert that the duplicate-UUID fallback returns the same monitor as the existing UUID-only lookup.
</issue_to_address>
### Comment 8
<location path="display1/duplicate_uuid_test.go" line_range="111" />
<code_context>
+ t.Fatal("getByUuidAndName should fall back to UUID for unknown name")
+ }
+
+ cfgs.setPrimaryByUuidAndName(uuid, "DP-2")
+ primaryCount := 0
+ for _, cfg := range cfgs {
</code_context>
<issue_to_address>
**Stale primary flags go undetected**
When a different config is already marked primary before selection, testSysMonitorConfigsGetByUuidAndName initializes every config with `Primary` false (lines 84–89), so an implementation that sets DP-2 primary but fails to clear an existing primary passes the count check at lines 113–123; callers can end up with multiple primary configs.
Initialize another config as primary before selection and assert that only DP-2 remains primary.
</issue_to_address>4f91093 to
2e7ab04
Compare
|
试图关闭PR重开以重新触发sourcery-ai的评估。 |
There was a problem hiding this comment.
Hey - I've found 10 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="display1/displayconf.go" line_range="829" />
<code_context>
+ logger.Debugf("duplicate uuid user config %q already exists, keep legacy key %q for retry", newKey, key)
+ continue
+ }
+ cfg.Screens[newKey] = result
+ logger.Infof("migrate duplicate uuid user config to %q", newKey)
+ delete(cfg.Screens, key)
</code_context>
<issue_to_address>
**Older user preferences win migration**
When multiple legacy user-config keys migrate to the same current monitor key and contain different preferences, `UserConfig.migrateDuplicateUuidScreens` processes sorted legacy keys and installs the first result for a new key; later configs targeting that key are skipped. When multiple historical keys represent the same current monitor set, the lexically first key's user preferences become active even if another key is the relevant one, so users see the wrong saved preferences.
Resolve competing user-config candidates deterministically using an explicit preference-selection rule instead of letting sorted key order choose the active config.
</issue_to_address>
### Comment 2
<location path="display1/displayconf.go" line_range="817-818" />
<code_context>
+ for modeKey, modeCfg := range screenCfg {
+ if strings.HasPrefix(modeKey, KeyModeOnlyOnePrefix) {
+ oldUuid := strings.TrimPrefix(modeKey, KeyModeOnlyOnePrefix)
+ for _, monitor := range migration.groups[oldUuid] {
+ result[KeyModeOnlyOnePrefix+monitor.uuid] = modeCfg
+ }
+ continue
</code_context>
<issue_to_address>
**Saved only-one settings disappear**
When a migrated screen entry has an OnlyOne setting whose UUID is absent from its migration group, the migration loop adds no replacement and continues, then deletes the old screen entry, so users lose the saved setting.
Preserve the original OnlyOne entry when its UUID has no migration group.
</issue_to_address>
### Comment 3
<location path="display1/displayconf.go" line_range="159" />
<code_context>
- needSave := m.userConfig.updateUuid(monitors)
+ needSave := m.userConfig.migrateDuplicateUuidScreens(monitors)
+ if m.userConfig.updateUuid(monitors) {
+ needSave = true
+ }
</code_context>
<issue_to_address>
**Partial topology deletes legacy layouts**
When a legacy duplicate-UUID key is rejected because fewer matching monitors are connected, but its old UUID still resolves to one of those monitors, `migrateDuplicateUuidScreens` rejects a legacy key when only a subset of its identical-EDID monitors is connected, but the subsequent `updateUuid` can still resolve the repeated legacy UUID to the one connected monitor, delete the old key, and move its config under a key containing that monitor’s UUID more than once. When the full monitor set reconnects, the original layout is no longer available under its expected key.
Keep rejected duplicate-UUID keys out of the ordinary UUID updater, or make that updater reject mappings where repeated UUIDs resolve to the same monitor.
Also at `display1/displayconf.go:213`.
</issue_to_address>
### Comment 4
<location path="display1/displayconf.go" line_range="681-682" />
<code_context>
+ case DisplayModeExtend:
+ modeCfg = screenCfg.Extend
+ case DisplayModeOnlyOne:
+ for _, config := range screenCfg.OnlyOneMap {
+ modeCfg = config
+ break
+ }
</code_context>
<issue_to_address>
**Wrong saved layout wins**
When multiple legacy keys map to the same new key while the display mode is OnlyOne and candidates have different OnlyOne entries, `scoreDuplicateUuidCandidate` scores an arbitrary `OnlyOneMap` entry instead of the one selected by `OnlyOneUuid`; map iteration can change which candidate wins, so migration restores the wrong saved layout.
Score the `OnlyOneMap` entry selected by `OnlyOneUuid` rather than the first entry encountered.
</issue_to_address>
### Comment 5
<location path="display1/displayconf.go" line_range="628-629" />
<code_context>
+ monitorCfg.UUID = monitor.uuid
+ monitorCfg.Name = monitor.Name
+ onlyOneMap[monitor.uuid] = config
+ if oldUuid == c.OnlyOneUuid {
+ result.OnlyOneUuid = monitor.uuid
+ }
+ }
</code_context>
<issue_to_address>
**Saved display selection is lost**
When a duplicate-UUID screen config has an `OnlyOneUuid` whose `OnlyOneMap` entry is absent or cannot be mapped, `migrateDuplicateUuid` leaves the legacy UUID in `OnlyOneUuid` while migrating the screen key, so `applyModeOnlyOne` cannot find the selected monitor and falls back to the default primary.
Do not migrate the screen key while its `OnlyOneUuid` cannot be mapped to a current monitor.
Also at `display1/displayconf.go:634-638`.
</issue_to_address>
### Comment 6
<location path="display1/displayconf.go" line_range="1113" />
<code_context>
+// SPDX-FileCopyrightText: 2022-2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
</code_context>
<issue_to_address>
**Saved monitor positions collapse**
When multiple saved monitor configs share a UUID and none of their names match the current monitor names, `getByUuidAndName` falls back to `getByUuid`, which returns the first config for each monitor, so `applySysMonitorConfigs` assigns the same saved position to multiple monitors.
Avoid the first-match UUID fallback when multiple configs share a UUID and no name matches.
</issue_to_address>
### Comment 7
<location path="display1/xorg.go" line_range="500-503" />
<code_context>
+
+ stdNames := make(map[string]string, len(resolved))
+ for name, r := range resolved {
+ if !r.exact && ownerCount[r.claim] > 1 {
+ logger.Debugf("monitor %v: std name %q and EDID shared by %d outputs, fall back to X output name",
+ name, r.claim.stdName, ownerCount[r.claim])
+ continue
+ }
+ stdNames[name] = r.claim.stdName
</code_context>
<issue_to_address>
**Connector probing changes monitor UUIDs**
When DRM connector EDIDs are only partially available during one refresh and become available on a later refresh, a second matching connector becomes readable after a refresh that fell back to X output names, so `assignStdNames` now emits connector-based UUIDs for those outputs. Configs saved under the fallback UUIDs are not covered by the duplicate-UUID migration, and callers lose the saved layout when the IDs change.
Keep UUID assignment stable across connector-probe readiness changes, or migrate configurations when a monitor’s UUID changes from an X-name fallback to a connector name.
</issue_to_address>
### Comment 8
<location path="display1/migration_test.go" line_range="212" />
<code_context>
+ t.Fatal("migrated screen config not found")
+ }
+ dp2UUID := getOutputUuid("DP-2", "", monitors[0].edid)
+ if screen.OnlyOneMap[dp2UUID] == nil {
+ t.Fatalf("OnlyOneMap keys = %v, want %q", keysOfModeConfigs(screen.OnlyOneMap), dp2UUID)
+ }
</code_context>
<issue_to_address>
**Only-one migration can stay stale**
When onlyOneMap migration leaves the nested monitor UUID unchanged, when migration updates an `OnlyOneMap` key but leaves its nested monitor UUID as the legacy UUID, `TestMigrateDuplicateUuidScreensOnlyOne` checks only the new key and selector, while `TestMigrateDuplicateUuidScreensOnlyOneByGeometry` checks the name and selector but not the UUID. Both pass although the migrated monitor config cannot be resolved by its new UUID.
Assert that each migrated OnlyOneMap entry’s nested monitor UUID equals the corresponding current monitor UUID.
Also at `display1/migration_test.go:497`.
</issue_to_address>
### Comment 9
<location path="display1/stdname_property_test.go" line_range="59" />
<code_context>
+ shuffled := make([]testOutput, len(outputs))
+ copy(shuffled, outputs)
+ rng.Shuffle(len(shuffled), func(i, j int) { shuffled[i], shuffled[j] = shuffled[j], shuffled[i] })
+ for name, uuid := range testOutputUuids(t, dir, shuffled) {
+ if uuids[name] != uuid {
+ t.Fatalf("iter %d: output %s UUID depends on enumeration order: %s vs %s",
</code_context>
<issue_to_address>
**Connector-order regression passes**
When the implementation depends on DRM connector enumeration order, when UUID resolution depends on DRM connector enumeration order, `TestAssignStdNamesRandomizedTopologyProperties` only shuffles owners at lines 56–59; its connector list stays fixed, so the UUID comparison still passes.
Run the resolver with the same connector slice in multiple shuffled orders and compare the UUIDs.
</issue_to_address>
### Comment 10
<location path="display1/duplicate_uuid_test.go" line_range="375" />
<code_context>
+ edid := bytes.Repeat([]byte{0x78}, 128)
+ seen := make(map[string]string)
+ for _, connector := range []string{"DP-1", "DP-2", "DP-3", "DP-4"} {
+ uuid := getOutputUuid(connector, connector, edid)
+ if other, ok := seen[uuid]; ok {
+ t.Fatalf("connector %s and %s got the same UUID %s", other, connector, uuid)
</code_context>
<issue_to_address>
**Ignored standard name passes**
When `getOutputUuid` stops incorporating `stdName`, when `getOutputUuid` ignores `stdName` and uses only `name`, `TestGetOutputUuidIdenticalEdidUsesDistinctStdNames` still passes: line 375 varies both arguments, so `name` alone produces distinct UUIDs.
Hold `name` constant while varying `stdName`, or assert the exact UUIDs expected for each standard name.
</issue_to_address>2e7ab04 to
8e74605
Compare
8e74605 to
4c697c3
Compare
…ayouts Generate display UUIDs from a per-refresh view of the current topology. All connected X outputs are resolved against a freshly read DRM connector list, so identical-EDID monitors no longer share a UUID and the result cannot depend on hotplug or daemon-restart history. Only outputs that really share a (stdName, EDID fingerprint) pair fall back to their X output name, exact port-name matches keep the legacy UUID, and a single monitor keeps its @connector UUID even when several connectors report the same EDID. Migrate legacy screens configs that were saved with duplicate UUIDs instead of resetting the user's layout. The migration matches the old UUIDs to the current monitors by the EDID fingerprint embedded in each UUID and by the saved output names; it rewrites the screen key, per-monitor UUIDs, OnlyOne entries and fill-mode keys, and refuses to migrate when counts or names are ambiguous. Add regression tests for hotplug/restart stability, monitor replacement, single-monitor multi-connector and duplicate-connector-name cases, randomized topology properties, and legacy duplicate-UUID config migration. Log: Identical-EDID monitors keep independent layouts across hotplug and daemon restart, and existing layouts are migrated instead of reset. Influence: 1. Identical-EDID monitors receive unique UUIDs; a given topology keeps the same UUIDs across hotplug and daemon restarts. 2. A single monitor keeps its legacy UUID even when several DRM connectors report the same EDID. 3. Screens configs saved with duplicate UUIDs are migrated to the new UUIDs when the monitor set and names are unambiguous. fix(display): 保证同 EDID 显示器身份稳定并迁移旧布局 每轮刷新基于当前拓扑重新解析所有 X 输出的标准 connector 名,相同 EDID 的 显示器不再共享 UUID,判定结果也不再依赖热插或 daemon 重启历史。仅当多个 输出确实共享 (标准名, EDID 指纹) 时才回退到 X output 名;端口名精确匹配的 输出保留旧 UUID;只有一台显示器时,即使多个 connector 报告同一 EDID 也保留 @connector 形式的旧 UUID。 新增旧配置迁移:对历史上因重复 UUID 而无法命中的 Screens 配置,按 UUID 中 携带的 EDID 指纹和配置里的输出名映射到当前显示器,重写屏幕 key、各显示器 UUID、OnlyOne 条目和填充模式 key;数量或名称无法唯一确定时放弃迁移,避免 把布局写到错误的显示器,也避免升级后布局被整体重置。 补充热插/重启稳定性、换接显示器、单屏多 connector、跨卡同名 connector、 随机拓扑属性以及旧重复 UUID 配置迁移的回归测试。 Influence: 1. 相同 EDID 显示器获得唯一 UUID,同一拓扑在热插和重启后 UUID 不变。 2. 单屏在多个 connector 报告同一 EDID 时保留旧 UUID。 3. 重复 UUID 的旧屏幕配置在显示器集合与名称可唯一确定时迁移到新 UUID。 Log: 相同 EDID 显示器在热插和重启后保持独立布局,旧布局会迁移而不是重置。 PMS: BUG-382483
4c697c3 to
3b27a72
Compare
Problem
Monitors with identical EDID could be mapped to the first matching DRM connector and receive the same UUID. Since monitor configs were looked up by UUID alone, all matching monitors could receive the first entry's position and refresh rate, causing overlapping layouts after apply or drag.
Fix
Compatibility and validation
go test ./display1/..., race tests, andgo vet ./display1pass.5fa3628fbuild, whose display fix has the same patch-id as this release change. Four simultaneous 4K monitors have not yet been validated.Log: Identical-EDID monitors receive distinct UUIDs and retain independent layouts across apply, save, and daemon restarts; safely mappable legacy layouts are migrated.
Influence:
PMS: BUG-382483
问题
多台显示器的 EDID 完全相同时,旧实现可能将它们映射到第一个匹配的 DRM connector,生成相同 UUID。应用配置时又只按 UUID 取第一条,导致多屏被写入同一组坐标和刷新率,拖拽或 ApplyChanges 后再次重叠。
修复
兼容性与验证
go test ./display1/...、race 测试及go vet ./display1均通过。5fa3628f构建,显示修复补丁与本 release 提交的 patch-id 相同。四块 4K 屏整机尚未验收。Log: 同 EDID 显示器获得独立 UUID,坐标和刷新率可分别保存并在重启后恢复;可安全映射的旧布局同步迁移。
Influence:
PMS: BUG-382483