fix: use shared-state background color to avoid nil pointer (#876)#894
Open
fsorodrigues wants to merge 1 commit into
Open
fix: use shared-state background color to avoid nil pointer (#876)#894fsorodrigues wants to merge 1 commit into
fsorodrigues wants to merge 1 commit into
Conversation
|
👋 Hi @fsorodrigues, thanks for the pull request! A scan flagged a concern with it. Could you please take a look? [pr-task-completion] This PR's body is missing
Repositories often provide a set of tasks that pull request authors are expected to complete. Those tasks should be marked as completed with a
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #876 — TUI crashes with nil pointer dereference of
markdownStylewhenBackgroundColorMsgnot reachedThis PR introduces background color shared state, default and fallback behaviors, and changes to the
InitializeMarkdownStyleandGetMarkdownRenderfunctions signatures to ensure that*markdownStyleis never nil when dereferenced.AI disclosure (per AI_POLICY.md)
Diagnosis of nil pointer dereference location was done with assistance of GPT-5.4 (via OpenCode). Same AI was also used to identify
GetMarkdownRenderusage extense given the bugfix plan I'm proposing involved altering the function's signature.Solution
Here are the changes introduced:
internal/tui/context/context.goProgramContextstruct:HasDarkBackgroundbool,BackgroundSourcestringinterna/tui/markdown/markdownRenderer.goInitializeMarkdownStyleandGetMarkdownRenderersignatures to include*context.ProgramContext. These ensure the shared state valuesctx.HasBackgroundandctx.BackgroundSourceare available for the create of the markdown renderer.internal/tui/ui.goctx.HasBackgroundandctx.BackgroundSourcecompat.HasDarkBackgroundas boolean forctx.HasDarkBackgroundtea.BackgroundColorMsgwhen reachedinternal/tui/components/issueview/activity.gointernal/tui/components/issueview/issueview.gointernal/tui/components/prview/activity.gointernal/tui/components/prview/prview.gointernal/tui/modelUtils.goGetMarkdownRenderwith context as argumentTesting
Verified the nil pointer derefence panic present on tag v4.24.1 on setup described in #876.
Rebuilt binary with patch (commit 46b5843), removed and reinstalled dash extension from local repo
Started gh dash with debug flag. Verified nil pointer derefence panic is gone and that debug logs describe shared state as expected.
Verified gh dash works normally and renders markdown contents of PRs and issues with expected background