A transcriptional rheostat couples past activity to future sensory responses