fix: Several coderabbit suggestions on next branch

This commit is contained in:
jamesread
2025-10-30 15:51:40 +00:00
parent 79a71099f9
commit 83f45d71bf
4 changed files with 28 additions and 13 deletions

View File

@@ -126,12 +126,16 @@ async function fetchActionLogs() {
const args = {
"actionId": actionId,
"startOffset": BigInt(startOffset),
"pageSize": BigInt(Number(pageSize.value)),
}
const response = await window.client.getActionLogs(args)
logs.value = response.logs
pageSize.value = Number(response.pageSize) || 0
const serverPageSize = Number(response.pageSize)
if (Number.isFinite(serverPageSize) && serverPageSize > 0) {
pageSize.value = serverPageSize
}
totalCount.value = Number(response.totalCount) || 0
} catch (err) {
console.error('Failed to fetch action logs:', err)

View File

@@ -217,6 +217,7 @@ func UserFromContext[T any](ctx context.Context, req *connect.Request[T], cfg *c
return &user
}
//gocyclo:ignore
func userFromHeaders[T any](req *connect.Request[T], cfg *config.Config) AuthenticatedUser {
var u AuthenticatedUser
if req == nil {
@@ -234,6 +235,7 @@ func userFromHeaders[T any](req *connect.Request[T], cfg *config.Config) Authent
return u
}
//gocyclo:ignore
func userFromLocalSession[T any](req *connect.Request[T], cfg *config.Config, u AuthenticatedUser) AuthenticatedUser {
if req == nil || u.Username != "" {
return u

View File

@@ -481,10 +481,16 @@ func (api *oliveTinAPI) GetActionLogs(ctx ctx.Context, req *connect.Request[apiv
ret.StartOffset = page.start
return connect.NewResponse(ret), nil
}
for _, le := range filtered[page.start:page.end] {
// Newest-first slicing: compute reversed indices
startIdx := page.total - page.end
endIdx := page.total - page.start
if startIdx < 0 { startIdx = 0 }
if endIdx > int64(len(filtered)) { endIdx = int64(len(filtered)) }
for _, le := range filtered[startIdx:endIdx] {
ret.Logs = append(ret.Logs, api.internalLogEntryToPb(le, user))
}
ret.CountRemaining = page.total - page.end
// Entries older than the returned newest page
ret.CountRemaining = page.start
ret.PageSize = page.size
ret.TotalCount = page.total
ret.StartOffset = page.start

View File

@@ -294,17 +294,20 @@ func overrideSimple(base *Config, overlay *Config) {
}
func overrideNested(base *Config, overlay *Config) {
if overlay.DefaultPolicy.ShowDiagnostics != base.DefaultPolicy.ShowDiagnostics {
base.DefaultPolicy.ShowDiagnostics = overlay.DefaultPolicy.ShowDiagnostics
// Only apply overrides when overlay explicitly enables the option.
// This mirrors the presence-check pattern used elsewhere to avoid
// unintentionally disabling an already-enabled base setting with a default false.
if overlay.DefaultPolicy.ShowDiagnostics {
base.DefaultPolicy.ShowDiagnostics = true
}
if overlay.DefaultPolicy.ShowLogList != base.DefaultPolicy.ShowLogList {
base.DefaultPolicy.ShowLogList = overlay.DefaultPolicy.ShowLogList
if overlay.DefaultPolicy.ShowLogList {
base.DefaultPolicy.ShowLogList = true
}
if overlay.Prometheus.Enabled != base.Prometheus.Enabled {
base.Prometheus.Enabled = overlay.Prometheus.Enabled
if overlay.Prometheus.Enabled {
base.Prometheus.Enabled = true
}
if overlay.Prometheus.DefaultGoMetrics != base.Prometheus.DefaultGoMetrics {
base.Prometheus.DefaultGoMetrics = overlay.Prometheus.DefaultGoMetrics
if overlay.Prometheus.DefaultGoMetrics {
base.Prometheus.DefaultGoMetrics = true
}
}