There are currently multiple bugs/inconsistencies when the active object can be hidden while being edited.
The 3D views "active_object" checks visibility, returning NULL when when it's hidden. This has the result of showing the 3D view as being in object-mode when the active object is hidden.
There is an exception to this rule - edit-mode always returns the active object, ignoring the hidden state.
As far as I know, this is mostly a result of incremental tweaks & fixes, not a design decision.
The logic to always be in object-mode with a hidden active object isn't working properly.
- When the collection is hidden, the object can be sculpted onto, but when the object is hidden it can't be.
- The tool system currently follows the active object, ignoring it's hidden state.
- T83013: Crash when using annotation tool on object hidden in sculpt mode. Note, fixing this isn't so complicated, it's just an example of the current behavior being error prone.
Fix the current behavior:
Fully support object mode behavior when the active object in a mode is hidden.
- Take into account the hidden state of the collection.
- Make the tool system respect the active-objects hidden state, refreshing the tool system on visibility changes.
- Make transform logic use contexts active object.
Ignore visibility flag when editing:
While I'm not so keen on this, adding for completeness.
We could ignore the visibility option when the active object isn't in object mode.
Extend the edit-mode exception:
Extend the edit-mode exception to all object editing modes.
- When in object-mode, use the visibility state, otherwise always treat the object as visible (P1956). This means you won't be able to enter sculpt mode on a hidden object (same as edit-mode), but you will still be able to exit.
- Any operators that cause problems when activated on an invisible object - can warn/error on activation.
In most cases fixing the current behavior is reasonable, however this further complicates code in a way that doesn't help users.
This is a corner case that shouldn't crash or fail entirely, but I don't think we should be spending development time to support these corner cases.
For example, if we treat collection visibility the same as object visibility, we would need to support scenes with an animated collection-visibility properly updating cursors/gizmos etc... since it would be effectively animating the object's mode.
If we choose not to support this corner-case, we have the current situation where visibility sometimes changes the object mode, other times not.
I'd suggest we extend the edit-mode exception, or at least opt for a change that keeps behavior straightforward / simple.