If a variable is set by a command, and that command enqueues another command, the queued command, and any commands executed by that queued command (when using a method that preserves the chain) will have access to command-shared(I.E. "~~" prefixed) variables.
However, each queued command only has access to the variables set within its chain of commands.
E.G. if you have a command that sets a command-shared variable, which enqueues a command, and then that command is executed again outside of the chain (E.G. by voice), the command it enqueues will have a different version of the variable.
This series of commands will verify that:
Command 1
Pause all command queues
Set text [~~variable] to '{TIMESTAMP}'
Enqueue command, 'get value' into []
Enqueue command, 'get value' into []
get value
Write [Blue] '{TXT:~~variable}' to log
Command 2
Enqueue command, 'get value' into [] (and start queue execution immediately)
Run "Command 1" twice, then run "Command 2"; The resulting log entries will show two identical timestamps, then another two timestamps which are different from the first set of two but identical to eachother, followed by "Not set" for the final entry.
Note, however, that two different commands assigned to the same queue from the same command are not considered part of the same chain (I.E. each command queued will be part of a different chain, branching off at the point they are enqueued).
E.G. if you have a command that sets a value, and a command that retrieves said value, and both are enqueued by a single third command, the command that gets the value will not have access to the value set by the command that sets the value.
Each queued command keeps with it its own individual set of chain-scoped (command-shared) variables, as they were set at the time they were enqueued, as demonstrated by this command:
Pause queue []
Set text [~~variable] to '{TIMESTAMP}'
Enqueue command, 'get value' into []
Set text [~~variable] to '{TIMESTAMP}'
Enqueue command, 'get value' into [] (and start queue execution immediately)
Which will write to different timestamps to the log.
If the behavior you are observing is not consistent with this, provide reproducible example commands so it can be checked.